47 lines
1.6 KiB
VimL
47 lines
1.6 KiB
VimL
|
" Use tab for trigger completion with characters ahead and navigate.
|
||
|
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
|
||
|
inoremap <silent><expr> <TAB>
|
||
|
\ pumvisible() ? "\<C-n>" :
|
||
|
\ <SID>check_back_space() ? "\<TAB>" :
|
||
|
\ coc#refresh()
|
||
|
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
|
||
|
|
||
|
function! s:check_back_space() abort
|
||
|
let col = col('.') - 1
|
||
|
return !col || getline('.')[col - 1] =~# '\s'
|
||
|
endfunction
|
||
|
|
||
|
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
|
||
|
inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
|
||
|
|
||
|
" Use <c-space> to trigger completion.
|
||
|
inoremap <silent><expr> <c-space> coc#refresh()
|
||
|
|
||
|
" Remap keys for gotos
|
||
|
nmap <silent> gd <Plug>(coc-definition)
|
||
|
nmap <silent> gy <Plug>(coc-type-definition)
|
||
|
nmap <silent> gi <Plug>(coc-implementation)
|
||
|
nmap <silent> gr <Plug>(coc-references)
|
||
|
|
||
|
" Highlight symbol under cursor on CursorHold
|
||
|
autocmd CursorHold * silent call CocActionAsync('highlight')
|
||
|
|
||
|
" Remap for rename current word
|
||
|
nmap <leader>rn <Plug>(coc-rename)
|
||
|
|
||
|
" Remap for format selected region
|
||
|
xmap <leader>f <Plug>(coc-format-selected)
|
||
|
nmap <leader>f <Plug>(coc-format-selected)
|
||
|
|
||
|
" Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
|
||
|
xmap <leader>a <Plug>(coc-codeaction-selected)
|
||
|
nmap <leader>a <Plug>(coc-codeaction-selected)
|
||
|
|
||
|
" Remap for do codeAction of current line
|
||
|
nmap <leader>ac <Plug>(coc-codeaction)
|
||
|
" Fix autofix problem of current line
|
||
|
nmap <leader>qf <Plug>(coc-fix-current)
|
||
|
|
||
|
" Use `:Format` to format current buffer
|
||
|
command! -nargs=0 Format :call CocAction('format')
|