Created
January 12, 2022 10:41
-
-
Save simon-lang/8a343369eaf149a85c176d140fb6c20d to your computer and use it in GitHub Desktop.
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) | |
" use <tab> for trigger completion and navigate to the next complete item | |
function! s:check_back_space() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~ '\s' | |
endfunction | |
inoremap <silent><expr> <Tab> | |
\ pumvisible() ? "\<C-n>" : | |
\ <SID>check_back_space() ? "\<Tab>" : | |
\ coc#refresh() | |
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment