From: Samir Benmendil Date: Tue, 2 May 2023 10:19:44 +0000 (+0100) Subject: vim: only set ycm bindings if ycm is loaded X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/3c847456820c25ae603032bcd4e4dbd60073f093?ds=sidebyside vim: only set ycm bindings if ycm is loaded --- diff --git a/vim/ftplugin/c.vim b/vim/ftplugin/c.vim index 0dca3bc..a2e9e71 100644 --- a/vim/ftplugin/c.vim +++ b/vim/ftplugin/c.vim @@ -9,29 +9,38 @@ augroup fswitch au BufEnter *.c let b:fswitchlocs = 'reg:|source|include/**|' augroup END -" Disable ale as we use ycm -let b:ale_enabled = 0 - -nnoremap gd :YcmCompleter GoTo -nnoremap d :vs:YcmCompleter GoTo -nnoremap gD :YcmCompleter GoToReferences - -nnoremap fi :YcmCompleter FixIt -nnoremap fr :YcmCompleter RefactorRename - -" format with = -call operator#user#define_ex_command('ycmcompleter-format', 'YcmCompleter Format') -map = (operator-ycmcompleter-format) -vnoremap = :YcmCompleter Format -" restore = mapping to g= -nnoremap g= = -vnoremap g= = - -" hover popup -let g:ycm_auto_hover = '' -let b:ycm_hover = { 'command': 'GetDoc', 'syntax': &filetype } -nmap gh (YCMHover) -nmap gH :YcmCompleter GetDoc +if exists("g:loaded_youcompleteme") + " Disable ale as we use ycm + let b:ale_enabled = 0 + + nnoremap gd :YcmCompleter GoTo + nnoremap d :vs:YcmCompleter GoTo + nnoremap gD :YcmCompleter GoToReferences + + " replaced with ca (code action) in neovim + nnoremap fi :YcmCompleter FixIt + " replaced with cr (code rename) in neovim + nnoremap fr :YcmCompleter RefactorRename + + " format with = + call operator#user#define_ex_command('ycmcompleter-format', 'YcmCompleter Format') + map = (operator-ycmcompleter-format) + vnoremap = :YcmCompleter Format + " restore = mapping to g= + nnoremap g= = + vnoremap g= = + + " hover popup + let g:ycm_auto_hover = '' + let b:ycm_hover = { 'command': 'GetDoc', 'syntax': &filetype } + nmap gh (YCMHover) + nmap gH :YcmCompleter GetDoc +else + " I'm way to used to using = to format than to switch to gq + nnoremap = gq + nnoremap == gqq + vnoremap = gq +endif let b:tcomment_options = {'whitespace': 'no'} diff --git a/vim/ftplugin/python.vim b/vim/ftplugin/python.vim index c64e31f..83d8895 100644 --- a/vim/ftplugin/python.vim +++ b/vim/ftplugin/python.vim @@ -1,5 +1,7 @@ setlocal foldlevelstart=1 " at least show content of classes -nnoremap gd :YcmCompleter GoTo -nnoremap d :vs:YcmCompleter GoTo -nnoremap gD :YcmCompleter GoToReferences +if exists("g:loaded_youcompleteme") + nnoremap gd :YcmCompleter GoTo + nnoremap d :vs:YcmCompleter GoTo + nnoremap gD :YcmCompleter GoToReferences +endif