Map coc.nvim bindings only if coc is installed

This commit is contained in:
Alexander Gehrke 2021-08-11 12:22:48 +02:00
parent 601ba8f1ec
commit 37fb739795
2 changed files with 21 additions and 19 deletions

View file

@ -1,17 +1,20 @@
map <silent> gd <Plug>(coc-definition) if exists(":CocAction")
set signcolumn=yes
map <silent> gd <Plug>(coc-definition)
map <silent> <M-=> :call CocAction("doHover")<cr> map <silent> <M-=> <cmd>call CocAction("doHover")<cr>
map <silent> <Leader>t <Plug>(coc-type-definition) map <silent> <Leader>t <Plug>(coc-type-definition)
map <silent> <Leader>u <Plug>(coc-references) map <silent> <Leader>u <Plug>(coc-references)
map <silent> <Leader>r <Plug>(coc-rename) map <silent> <Leader>r <Plug>(coc-rename)
map <silent> <Leader>q <Plug>(coc-quickfix) map <silent> <Leader>q <Plug>(coc-quickfix)
map <silent> <Leader>F <Plug>(coc-format) map <silent> <Leader>F <Plug>(coc-format)
map <silent> <Leader>f <Plug>(coc-format-selected) map <silent> <Leader>f <Plug>(coc-format-selected)
vmap <silent> <Leader>f <Plug>(coc-format-selected) vmap <silent> <Leader>f <Plug>(coc-format-selected)
map <silent> <M-a> <Plug>(coc-codeaction) map <silent> <M-a> <Plug>(coc-codeaction)
vmap <silent> <M-a> <Plug>(coc-codeaction-selected) vmap <silent> <M-a> <Plug>(coc-codeaction-selected)
omap <silent> af <Plug>(coc-funcobj-a) omap <silent> af <Plug>(coc-funcobj-a)
omap <silent> if <Plug>(coc-funcobj-i) omap <silent> if <Plug>(coc-funcobj-i)
endif

View file

@ -7,14 +7,13 @@ endif
"inoremap <expr><C-h> deoplete#smart_close_popup()."\<C-h>" "inoremap <expr><C-h> deoplete#smart_close_popup()."\<C-h>"
"inoremap <expr><BS> deoplete#smart_close_popup()."\<C-h>" "inoremap <expr><BS> deoplete#smart_close_popup()."\<C-h>"
inoremap <silent><expr> <TAB> "inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" : " \ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" : " \ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh() " \ '\<C-x><C-o>'
"\ '\<C-x><C-o>'
function! s:check_back_space() function! s:check_back_space()
let col = col('.') - 1 let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s' return !col || getline('.')[col - 1] =~ '\s'
endfunction endfunction
inoremap <silent><expr> <c-space> coc#refresh() "inoremap <silent> <c-space> <C-x><C-o>