From 290a65219fbff0bed9fa31c59013b6fa8215d48e Mon Sep 17 00:00:00 2001 From: micbou Date: Mon, 12 Oct 2015 15:27:30 +0200 Subject: [PATCH] Define Vim commands only if setup is successful --- autoload/youcompleteme.vim | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/autoload/youcompleteme.vim b/autoload/youcompleteme.vim index d2ef404a..07700ba2 100644 --- a/autoload/youcompleteme.vim +++ b/autoload/youcompleteme.vim @@ -51,6 +51,7 @@ function! youcompleteme#Enable() return endif + call s:SetUpCommands() call s:SetUpCpoptions() call s:SetUpCompleteopt() call s:SetUpKeyMappings() @@ -305,6 +306,17 @@ function! s:AllowedToCompleteInCurrentFile() endfunction +function! s:SetUpCommands() + command! YcmRestartServer call s:RestartServer() + command! YcmShowDetailedDiagnostic call s:ShowDetailedDiagnostic() + command! YcmDebugInfo call s:DebugInfo() + command! -nargs=* -complete=custom,youcompleteme#SubCommandsComplete + \ YcmCompleter call s:CompleterCommand() + command! YcmForceCompileAndDiagnostics call s:ForceCompileAndDiagnostics() + command! YcmDiags call s:ShowDiagnostics() +endfunction + + function! s:SetUpCpoptions() " Without this flag in cpoptions, critical YCM mappings do not work. There's " no way to not have this and have YCM working, so force the flag. @@ -736,15 +748,11 @@ function! s:RestartServer() py ycm_state.RestartServer() endfunction -command! YcmRestartServer call s:RestartServer() - function! s:ShowDetailedDiagnostic() py ycm_state.ShowDetailedDiagnostic() endfunction -command! YcmShowDetailedDiagnostic call s:ShowDetailedDiagnostic() - function! s:DebugInfo() echom "Printing YouCompleteMe debug information..." @@ -754,8 +762,6 @@ function! s:DebugInfo() endfor endfunction -command! YcmDebugInfo call s:DebugInfo() - function! s:CompleterCommand(...) " CompleterCommand will call the OnUserCommand function of a completer. @@ -790,9 +796,6 @@ function! youcompleteme#OpenGoToList() endfunction -command! -nargs=* -complete=custom,youcompleteme#SubCommandsComplete - \ YcmCompleter call s:CompleterCommand() - function! youcompleteme#SubCommandsComplete( arglead, cmdline, cursorpos ) return join( pyeval( 'ycm_state.GetDefinedSubcommands()' ), \ "\n") @@ -831,8 +834,6 @@ function! s:ForceCompileAndDiagnostics() echom "Diagnostics refreshed." endfunction -command! YcmForceCompileAndDiagnostics call s:ForceCompileAndDiagnostics() - function! s:ShowDiagnostics() let compilation_succeeded = s:ForceCompile() @@ -853,8 +854,6 @@ function! s:ShowDiagnostics() endif endfunction -command! YcmDiags call s:ShowDiagnostics() - " This is basic vim plugin boilerplate let &cpo = s:save_cpo