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
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
call s:SetUpCommands()
|
||||||
call s:SetUpCpoptions()
|
call s:SetUpCpoptions()
|
||||||
call s:SetUpCompleteopt()
|
call s:SetUpCompleteopt()
|
||||||
call s:SetUpKeyMappings()
|
call s:SetUpKeyMappings()
|
||||||
@ -305,6 +306,17 @@ function! s:AllowedToCompleteInCurrentFile()
|
|||||||
endfunction
|
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()
|
function! s:SetUpCpoptions()
|
||||||
" Without this flag in cpoptions, critical YCM mappings do not work. There's
|
" 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.
|
" 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()
|
py ycm_state.RestartServer()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
command! YcmRestartServer call s:RestartServer()
|
|
||||||
|
|
||||||
|
|
||||||
function! s:ShowDetailedDiagnostic()
|
function! s:ShowDetailedDiagnostic()
|
||||||
py ycm_state.ShowDetailedDiagnostic()
|
py ycm_state.ShowDetailedDiagnostic()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
command! YcmShowDetailedDiagnostic call s:ShowDetailedDiagnostic()
|
|
||||||
|
|
||||||
|
|
||||||
function! s:DebugInfo()
|
function! s:DebugInfo()
|
||||||
echom "Printing YouCompleteMe debug information..."
|
echom "Printing YouCompleteMe debug information..."
|
||||||
@ -754,8 +762,6 @@ function! s:DebugInfo()
|
|||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
command! YcmDebugInfo call s:DebugInfo()
|
|
||||||
|
|
||||||
|
|
||||||
function! s:CompleterCommand(...)
|
function! s:CompleterCommand(...)
|
||||||
" CompleterCommand will call the OnUserCommand function of a completer.
|
" CompleterCommand will call the OnUserCommand function of a completer.
|
||||||
@ -790,9 +796,6 @@ function! youcompleteme#OpenGoToList()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
command! -nargs=* -complete=custom,youcompleteme#SubCommandsComplete
|
|
||||||
\ YcmCompleter call s:CompleterCommand(<f-args>)
|
|
||||||
|
|
||||||
function! youcompleteme#SubCommandsComplete( arglead, cmdline, cursorpos )
|
function! youcompleteme#SubCommandsComplete( arglead, cmdline, cursorpos )
|
||||||
return join( pyeval( 'ycm_state.GetDefinedSubcommands()' ),
|
return join( pyeval( 'ycm_state.GetDefinedSubcommands()' ),
|
||||||
\ "\n")
|
\ "\n")
|
||||||
@ -831,8 +834,6 @@ function! s:ForceCompileAndDiagnostics()
|
|||||||
echom "Diagnostics refreshed."
|
echom "Diagnostics refreshed."
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
command! YcmForceCompileAndDiagnostics call s:ForceCompileAndDiagnostics()
|
|
||||||
|
|
||||||
|
|
||||||
function! s:ShowDiagnostics()
|
function! s:ShowDiagnostics()
|
||||||
let compilation_succeeded = s:ForceCompile()
|
let compilation_succeeded = s:ForceCompile()
|
||||||
@ -853,8 +854,6 @@ function! s:ShowDiagnostics()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
command! YcmDiags call s:ShowDiagnostics()
|
|
||||||
|
|
||||||
|
|
||||||
" This is basic vim plugin boilerplate
|
" This is basic vim plugin boilerplate
|
||||||
let &cpo = s:save_cpo
|
let &cpo = s:save_cpo
|
||||||
|
Loading…
Reference in New Issue
Block a user