Auto merge of #1727 - micbou:vim-commands, r=Valloric
Define Vim commands only if setup is successful Vim commands (`YcmDebugInfo`, `YcmCompleter`, etc.) should not be defined if an error is encountered when processing the `s:SetUpPython` function. Why? Because those commands will return errors like `name 'ycm_state' is not defined`. Note: due to an unexpected behavior, those commands work fine when libraries are found outdated. See issue #1726. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1727) <!-- Reviewable:end -->
This commit is contained in:
commit
76ff85bf75
@ -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…
x
Reference in New Issue
Block a user