Created
July 16, 2023 11:13
-
-
Save th3terrorist/9cbf78a7737c14b1fd287b410eed9a5e to your computer and use it in GitHub Desktop.
Coc useful shortcut mappings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" https://github.com/neoclide/coc.nvim#example-vim-configuration | |
inoremap <silent><expr> <c-space> coc#refresh() | |
" gd - go to definition of word under cursor | |
nmap <silent> gd <Plug>(coc-definition) | |
nmap <silent> gy <Plug>(coc-type-definition) | |
" gi - go to implementation | |
nmap <silent> gi <Plug>(coc-implementation) | |
" gr - find references | |
nmap <silent> gr <Plug>(coc-references) | |
" gh - get hint on whatever's under the cursor | |
nnoremap <silent> K :call <SID>show_documentation()<CR> | |
nnoremap <silent> gh :call <SID>show_documentation()<CR> | |
function! s:show_documentation() | |
if &filetype == 'vim' | |
execute 'h '.expand('<cword>') | |
else | |
call CocAction('doHover') | |
endif | |
endfunction | |
" Highlight symbol under cursor on CursorHold | |
autocmd CursorHold * silent call CocActionAsync('highlight') | |
nnoremap <silent> <leader>co :<C-u>CocList outline<cr> | |
nnoremap <silent> <leader>cs :<C-u>CocList -I symbols<cr> | |
" List errors | |
nnoremap <silent> <leader>cl :<C-u>CocList locationlist<cr> | |
" list commands available in tsserver (and others) | |
nnoremap <silent> <leader>cc :<C-u>CocList commands<cr> | |
" restart when tsserver gets wonky | |
nnoremap <silent> <leader>cR :<C-u>CocRestart<CR> | |
" view all errors | |
nnoremap <silent> <leader>cl :<C-u>CocList locationlist<CR> | |
" manage extensions | |
nnoremap <silent> <leader>cx :<C-u>CocList extensions<cr> | |
" rename the current word in the cursor | |
nmap <leader>cr <Plug>(coc-rename) | |
nmap <leader>cf <Plug>(coc-format-selected) | |
vmap <leader>cf <Plug>(coc-format-selected) | |
" run code actions | |
vmap <leader>ca <Plug>(coc-codeaction-selected) | |
nmap <leader>ca <Plug>(coc-codeaction-selected) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment