56 lines
2.1 KiB
VimL
56 lines
2.1 KiB
VimL
" if exists('b:coc_enabled=1')
|
|
set completeopt-=preview
|
|
|
|
nnoremap <silent><F6> :vsplit<CR><Bar>:CocConfig<CR>
|
|
|
|
let g:coc_global_extensions = ['coc-diagnostic', 'coc-prettier', 'coc-highlight', 'coc-snippets', 'coc-tsserver', 'coc-css', 'coc-html', 'coc-json', 'coc-emmet']
|
|
|
|
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current
|
|
" position. Coc only does snippet and additional edit on confirm.
|
|
if exists('*complete_info')
|
|
inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
|
|
else
|
|
imap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
|
|
endif
|
|
|
|
" use <c-@>for trigger completion
|
|
inoremap <silent><expr> <c-@> coc#refresh()
|
|
|
|
" Navigate diagnostics
|
|
nnoremap <silent> <F7> :<C-u>CocList diagnostics<CR>
|
|
nmap <silent> <F8> <Plug>(coc-diagnostic-prev)
|
|
nmap <silent> <F9> <Plug>(coc-diagnostic-next)
|
|
|
|
" GoTo code navigation.
|
|
nnoremap <buffer><silent> gd <Plug>(coc-definition)
|
|
nnoremap <buffer><silent> gr <Plug>(coc-references)
|
|
|
|
" Use D to show documentation in preview window.
|
|
nnoremap <buffer><silent> D :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
|
|
|
|
" Symbol renaming.
|
|
nnoremap <buffer><leader>rn <Plug>(coc-rename)
|
|
|
|
aug Cursor
|
|
au!
|
|
" au CursorHold * silent call CocActionAsync('highlight')
|
|
au User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
|
|
aug END
|
|
" else
|
|
" set omnifunc=syntaxcomplete#Complete
|
|
" " open omni completion menu closing previous if open and opening new menu without changing the text
|
|
" inoremap <silent> <expr> <C-Space> (pumvisible() ? (col('.') > 1 ? '<Esc>i<Right>' : '<Esc>i') : '') .
|
|
" \ '<C-x><C-o><C-r>=pumvisible() ? "\<lt>C-n>\<lt>C-p>\<lt>Down>" : ""<CR>'
|
|
" " open user completion menu closing previous if open and opening new menu without changing the text
|
|
" inoremap <silent> <expr> <M-Space> (pumvisible() ? (col('.') > 1 ? '<Esc>i<Right>' : '<Esc>i') : '') .
|
|
" \ '<C-x><C-u><C-r>=pumvisible() ? "\<lt>C-n>\<lt>C-p>\<lt>Down>" : ""<CR>'
|
|
" endif
|