diff options
Diffstat (limited to 'conf/keymaps.vim')
-rw-r--r-- | conf/keymaps.vim | 53 |
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) |