forked from rafi/vim-config
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoc.vim
More file actions
69 lines (55 loc) · 2.15 KB
/
coc.vim
File metadata and controls
69 lines (55 loc) · 2.15 KB
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
" coc.nvim settings
" ---
" Don't load the defx-git plugin file, not needed
let b:defx_git_loaded = 1
" Use <Tab> for trigger completion and navigate to the next complete item
let g:coc_snippet_next = '<tab>'
inoremap <silent><expr> <Tab>
\ pumvisible() ? "\<C-n>" :
\ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
\ <SID>check_back_space() ? "\<Tab>" :
\ coc#refresh()
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
inoremap <silent><expr> <CR> pumvisible() ? coc#_select_confirm() :
\ delimitMate#WithinEmptyPair() ? "\<C-R>=delimitMate#ExpandReturn()\<CR>" :
\"\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
function! s:check_back_space() abort
let col = col('.') - 1
return ! col || getline('.')[col - 1] =~? '\s'
endfunction
augroup user_plugin_coc
autocmd!
autocmd CompleteDone * if pumvisible() == 0 | pclose | endif
augroup END
" use <c-space>for trigger completion
inoremap <silent><expr> <C-space> coc#refresh()
" Movement within 'ins-completion-menu'
imap <expr><C-j> pumvisible() ? "\<Down>" : "\<C-j>"
imap <expr><C-k> pumvisible() ? "\<Up>" : "\<C-k>"
" Scroll pages in menu
inoremap <expr><C-f> pumvisible() ? "\<PageDown>" : "\<Right>"
inoremap <expr><C-b> pumvisible() ? "\<PageUp>" : "\<Left>"
imap <expr><C-d> pumvisible() ? "\<PageDown>" : "\<C-d>"
imap <expr><C-u> pumvisible() ? "\<PageUp>" : "\<C-u>"
" Use `[c` and `]c` to navigate diagnostics
nmap <silent> [c <Plug>(coc-diagnostic-prev)
nmap <silent> ]c <Plug>(coc-diagnostic-next)
" 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)
nmap gs <Plug>(coc-git-chunkinfo)
nmap [g <Plug>(coc-git-prevchunk)
nmap ]g <Plug>(coc-git-nextchunk)
" show commit contains current position
nmap gC <Plug>(coc-git-commit)
" 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
let l:found = CocAction('doHover')
endif
endfunction