aboutsummaryrefslogtreecommitdiff
path: root/conf/keymaps.vim
diff options
context:
space:
mode:
authorOxbian <oxbian@mailbox.org>2025-07-23 23:26:46 +0200
committerOxbian <oxbian@mailbox.org>2025-07-23 23:26:46 +0200
commit08dcec61aef0fed78b6d94ff97faeb1312d862e7 (patch)
tree7abd17969446bea404e0da87c24ea40319ba2368 /conf/keymaps.vim
parent4a752828e3d9f1aaab6f16a07a0114417bf2f89e (diff)
downloadvimrc-08dcec61aef0fed78b6d94ff97faeb1312d862e7.tar.gz
vimrc-08dcec61aef0fed78b6d94ff97faeb1312d862e7.zip
feat: using COC as LSP + linter + autocompletion
Diffstat (limited to 'conf/keymaps.vim')
-rw-r--r--conf/keymaps.vim53
1 files changed, 53 insertions, 0 deletions
diff --git a/conf/keymaps.vim b/conf/keymaps.vim
index 351520d..cf04181 100644
--- a/conf/keymaps.vim
+++ b/conf/keymaps.vim
@@ -145,3 +145,56 @@ noremap <leader>sa zg
" show the list of alternatives for the word
noremap <leader>s? z=
+
+""""""""""""""""""""
+" LSP
+""""""""""""""""""""
+
+nmap <silent><nowait> [g <Plug>(coc-diagnostic-prev)
+nmap <silent><nowait> ]g <Plug>(coc-diagnostic-next)
+
+" GoTo code navigation
+nmap <silent><nowait> gd <Plug>(coc-definition)
+nmap <silent><nowait> gy <Plug>(coc-type-definition)
+nmap <silent><nowait> gi <Plug>(coc-implementation)
+nmap <silent><nowait> gr <Plug>(coc-references)
+
+" Use K to show documentation in preview window
+nnoremap <silent> K :call ShowDocumentation()<CR>
+
+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 <leader>gR <Plug>(coc-rename)
+
+" Formatting selected code
+xmap <leader>gf <Plug>(coc-format-selected)
+nmap <leader>gf <Plug>(coc-format-selected)
+
+" Applying code actions to the selected code block
+xmap <leader>ga <Plug>(coc-codeaction-selected)
+nmap <leader>ga <Plug>(coc-codeaction-selected)
+
+" Remap keys for applying code actions at the cursor position
+nmap <leader>gc <Plug>(coc-codeaction-cursor)
+" Remap keys for apply code actions affect whole buffer
+nmap <leader>gs <Plug>(coc-codeaction-source)
+" Apply the most preferred quickfix action to fix diagnostic on the current line
+nmap <leader>gqf <Plug>(coc-fix-current)
+
+" Remap keys for applying refactor code actions
+nmap <silent> <leader>gr <Plug>(coc-codeaction-refactor)
+xmap <silent> <leader>r <Plug>(coc-codeaction-refactor-selected)
+nmap <silent> <leader>r <Plug>(coc-codeaction-refactor-selected)
+
+" Run the Code Lens action on the current line
+nmap <leader>gcl <Plug>(coc-codelens-action)
ArKa projects. All rights to me, and your next child right arm.