Define Vim commands only if setup is successful
This commit is contained in:
parent
d98298ab87
commit
290a65219f
@ -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(<f-args>)
|
||||
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(<f-args>)
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user