Disable coc bindings when coc not loaded.

This commit is contained in:
Alex Manning 2024-07-14 21:52:26 +00:00
parent 3ab0a641a4
commit 69518afa81

View file

@ -59,21 +59,24 @@ let g:vimspector_install_gadgets = ['debugpy']
" Config for Coc originally from their github.
" Use tab for trigger completion with characters ahead and navigate
inoremap <silent><expr> <TAB>
" If node is not available Coc will not be loaded so disable.
if executable('node') " Coc only works if nodejs is available.
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1) :
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
" Make <CR> to accept selected completion item or notify coc.nvim to format
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
" Make <CR> to accept selected completion item or notify coc.nvim to format
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" Use <c-space> to trigger completion
inoremap <silent><expr> <c-@> coc#refresh()
" Use <c-space> to trigger completion
inoremap <silent><expr> <c-@> coc#refresh()
" Dependenciy of the above. fom Coc github.
function! CheckBackspace() abort
" Dependenciy of the above. fom Coc github.
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
endfunction
endif