Auto merge of #2722 - micbou:set-complete-func, r=Valloric

[READY] Check completefunc when forcing semantic completion

When `completefunc` is not set (because YCM is not allowed to complete in the current buffer or the server failed to start) and semantic completion is forced with `<C-Space>`, Vim returns the following error:
```
E764: Option 'completefunc' is not set
```
This happens because we don't check if `completefunc` is set to `youcompleteme#CompleteFunc` in that case.

To completely avoid this issue, we always set the `completefunc` before invoking it. This may look inefficient but, in practice, the performance cost is almost nil.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2722)
<!-- Reviewable:end -->
This commit is contained in:
zzbot 2017-07-22 01:45:10 -07:00 committed by GitHub
commit f5b81bc17d

View File

@ -706,10 +706,13 @@ endfunction
function! s:InvokeSemanticCompletion() function! s:InvokeSemanticCompletion()
let s:force_semantic = 1 if &completefunc == "youcompleteme#CompleteFunc"
exec s:python_command "ycm_state.SendCompletionRequest( True )" let s:force_semantic = 1
exec s:python_command "ycm_state.SendCompletionRequest( True )"
call s:PollCompletion()
endif
call s:PollCompletion()
" Since this function is called in a mapping through the expression register " Since this function is called in a mapping through the expression register
" <C-R>=, its return value is inserted (see :h c_CTRL-R_=). We don't want to " <C-R>=, its return value is inserted (see :h c_CTRL-R_=). We don't want to
" insert anything so we return an empty string. " insert anything so we return an empty string.