forked from mizlan/vim-and-cp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cocrc.vim
86 lines (70 loc) · 2.67 KB
/
cocrc.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
" coc {{{
set cmdheight=2 updatetime=0
" Don't pass messages to |ins-completion-menu|.
set shortmess+=c
" Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
if has("patch-8.1.1564")
" Recently vim can merge signcolumn and number column into one
set signcolumn=number
else
set signcolumn=yes
endif
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
" GoTo code navigation.
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)
" Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
autocmd CursorHold * silent call CocActionAsync('highlight')
augroup CocStuff
autocmd!
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
xmap if <Plug>(coc-funcobj-i)
omap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap af <Plug>(coc-funcobj-a)
xmap ic <Plug>(coc-classobj-i)
omap ic <Plug>(coc-classobj-i)
xmap ac <Plug>(coc-classobj-a)
omap ac <Plug>(coc-classobj-a)
nmap <silent> <C-s> <Plug>(coc-range-select)
xmap <silent> <C-s> <Plug>(coc-range-select)
command! -nargs=0 Format :call CocAction('format')
command! -nargs=? Fold :call CocAction('fold', <f-args>)
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
nnoremap <silent><nowait> <leader>cc :<C-u>CocList commands<cr>
nnoremap <silent><nowait> <leader>cd :<C-u>CocList diagnostics<cr>
nnoremap <silent><nowait> <leader>ce :<C-u>CocList extensions<cr>
nnoremap <silent><nowait> <leader>cj :<C-u>CocNext<CR>
nnoremap <silent><nowait> <leader>ck :<C-u>CocPrev<CR>
nnoremap <silent><nowait> <leader>co :<C-u>CocList outline<cr>
nnoremap <silent><nowait> <leader>cp :<C-u>CocListResume<CR>
nnoremap <silent><nowait> <leader>cs :<C-u>CocList -I symbols<cr>
nmap <leader>cr <Plug>(coc-rename)
xmap <leader>cf <Plug>(coc-format-selected)
nmap <leader>cf <Plug>(coc-format-selected)
xmap <leader>ca <Plug>(coc-codeaction-selected)
nmap <leader>ca <Plug>(coc-codeaction-selected)
nmap <leader>cac <Plug>(coc-codeaction)
nmap <leader>cq <Plug>(coc-fix-current)
" }}}