53 lines
1.5 KiB
VimL
53 lines
1.5 KiB
VimL
" Config
|
|
nnoremap <silent><F6> :vsplit<CR><Bar>:CocConfig<CR>
|
|
|
|
if exists('b:coc_enabled=1')
|
|
set completeopt-=preview
|
|
|
|
let g:coc_global_extensions = ['coc-highlight', 'coc-snippets', 'coc-tsserver', 'coc-css', 'coc-html', 'coc-json', 'coc-emmet']
|
|
|
|
inoremap <buffer><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()
|
|
|
|
function! s:check_back_space() abort
|
|
let col = col('.') - 1
|
|
return !col || getline('.')[col - 1] =~# '\s'
|
|
endfunction
|
|
|
|
inoremap <buffer><silent><expr> <C-space> coc#refresh()
|
|
|
|
if exists('*complete_info')
|
|
inoremap <buffer><expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
|
|
else
|
|
inoremap <buffer><expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
|
|
endif
|
|
|
|
" 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
|
|
endif
|