From f63208096bd0b5623692839a7091e99008ef5e0a Mon Sep 17 00:00:00 2001 From: Oxbian Date: Thu, 9 May 2024 19:22:20 +0200 Subject: FIX: symlink glitch + removing unused plugins from README --- conf/keymaps.vim | 187 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100644 conf/keymaps.vim (limited to 'conf/keymaps.vim') diff --git a/conf/keymaps.vim b/conf/keymaps.vim new file mode 100644 index 0000000..d68b8c4 --- /dev/null +++ b/conf/keymaps.vim @@ -0,0 +1,187 @@ +""""""""""""""""""""""""""""" +" Keymaps +""""""""""""""""""""""""""""" + +let g:mapleader = "\" +let g:maplocalleader = ',' +nnoremap :WhichKey '' +nnoremap :WhichKey ',' + +" Treat long paragraph as a line +map j gj +map k gk + +"""""""""""""""""""" +" Window movement +"""""""""""""""""""" + +" Go to the bottom window +noremap j + +" Go to the top window +noremap k + +" Go to the right window +noremap l + +" Go to the left window +noremap h + +"""""""""""""""""""""""" +" Remove highlighting +"""""""""""""""""""""""" + +nnoremap hl :nohlsearch + +" Save file +nnoremap :w! + +"""""""""""""""""""""""""" +" Buffer +""""""""""""""""""""""""" + +" Close the current buffer +noremap bd :Bclose:tabclosegT + +" Close all the buffers +noremap ba :bufdo bd + +" Go to the next buffer +noremap bn :bnext + +" Go to the previous buffer +noremap bp :bprevious + +"""""""""""""""""""""""""""" +" Tabs +""""""""""""""""""""""""""" + +" Open a new tab +noremap tn :tabnew + +" Close all others tab +noremap to :tabonly + +" Close current tab page +noremap tc :tabclose + +" Move tabs after another +noremap tm :tabmove + +" Go to the next tab +noremap t :tabnext + +" Let 'tl' toggle between this and the last accessed tab +let g:lasttab = 1 +nnoremap tl :exe "tabn ".g:lasttab +au TabLeave * let g:lasttab = tabpagenr() + +" Opens a new tab with the current buffer's path +" Super useful when editing files in the same directory +noremap te :tabedit =escape(expand("%:p:h"), " ")/ + +" Switch CWD to the directory of the open buffer +noremap cd :cd %:p:h:pwd + +" Specify the behavior when switching between buffers +try + set switchbuf=useopen,usetab,newtab + set stal=2 +catch +endtry + +" Return to last edit position when opening files (You want this!) +au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif + +"""""""""""""""""""""""" +" Netrw +""""""""""""""""""""""" + +" Toggle tree view +nnoremap :Lexplore + +"""""""""""""""""""" +" GitGutter +"""""""""""""""""""" + +let g:gitgutter_enabled=1 " Enable by default gitgutter + +" Go to the previous hunk +nnoremap hp (GitGutterPrevHunk) + +" Go to the next hunk +nnoremap hn (GitGutterNextHunk) + +" Enable / Disable GitGutter +nnoremap ht (GitGutterToggle) + +" Stage Hunk in Git +nnoremap hs (GitGutterStageHunk) + +" Undo Hunk +nnoremap hu (GitGutterUndoHunk) + +" Preview Hunk +nnoremap hP :GitGutterPreviewHunk + +" Always show the status line +set laststatus=2 + +""""""""""""""""""""" +" Spell +""""""""""""""""""""" + +" Toggle and untoggle spell checking +noremap ss :setlocal spell! + +" Next word to spellcheck +noremap sn ]s + +" Previous word to spellcheck +noremap sp [s + +" Add word into the spellcheck dictionary +noremap sa zg + +" show the list of alternatives for the word +noremap s? z= + +""""""""""""""""""" +" LSP +""""""""""""""""""" +inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" + +" Make to accept selected completion item or notify coc.nvim to format +" u breaks current undo, please make your own choice +inoremap coc#pum#visible() ? coc#pum#confirm() + \: "\u\\=coc#on_enter()\" + +nmap gp (coc-diagnostic-prev) +nmap gn (coc-diagnostic-next) + +" GoTo code navigation +nmap gd (coc-definition) +nmap gy (coc-type-definition) +nmap gi (coc-implementation) +nmap gr (coc-references) + +" Use K to show documentation in preview window +nnoremap gh :call ShowDocumentation() + +function! ShowDocumentation() + if CocAction('hasProvider', 'hover') + call CocActionAsync('doHover') + else + call feedkeys('K', 'in') + endif +endfunction + +" Highlight the symbol and its references when holding the cursor +autocmd CursorHold * silent call CocActionAsync('highlight') + +" Symbol renaming +nmap gR (coc-rename) + +" Formatting selected code +xmap gf (coc-format-selected) +nmap gf (coc-format-selected) -- cgit v1.2.3