dgy
/
hexagons
Archived
1
0
Fork 0
This repository has been archived on 2021-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
hexagons/.config/nvim/after/plugin/coc.vim

62 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-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
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>'
packadd AutoComplPop
endif