Send requests again when server becomes ready
This commit is contained in:
parent
68d78719a4
commit
c349980bce
@ -22,7 +22,6 @@ set cpo&vim
|
|||||||
" This needs to be called outside of a function
|
" This needs to be called outside of a function
|
||||||
let s:script_folder_path = escape( expand( '<sfile>:p:h' ), '\' )
|
let s:script_folder_path = escape( expand( '<sfile>:p:h' ), '\' )
|
||||||
let s:omnifunc_mode = 0
|
let s:omnifunc_mode = 0
|
||||||
let s:defer_omnifunc = 1
|
|
||||||
|
|
||||||
let s:old_cursor_position = []
|
let s:old_cursor_position = []
|
||||||
let s:cursor_moved = 0
|
let s:cursor_moved = 0
|
||||||
@ -98,19 +97,6 @@ function! youcompleteme#Enable()
|
|||||||
autocmd CompleteDone * call s:OnCompleteDone()
|
autocmd CompleteDone * call s:OnCompleteDone()
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" Setting the omnifunc require us to ask the server if it has a Native
|
|
||||||
" Semantic Completer for the current buffer's filetype. When vim first start
|
|
||||||
" this mean that we have to wait for the server to be up and running which
|
|
||||||
" would block vim's GUI. To avoid this we defer setting the omnifunc the
|
|
||||||
" first time to when we enter Insert mode and then update it on every
|
|
||||||
" BufferVisit as normal.
|
|
||||||
if s:defer_omnifunc
|
|
||||||
augroup ycm_defer_omnifunc
|
|
||||||
autocmd!
|
|
||||||
autocmd InsertEnter * call s:DeferredUntilInsertEnter()
|
|
||||||
augroup END
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Calling this once solves the problem of BufRead/BufEnter not triggering for
|
" Calling this once solves the problem of BufRead/BufEnter not triggering for
|
||||||
" the first loaded file. This should be the last command executed in this
|
" the first loaded file. This should be the last command executed in this
|
||||||
" function!
|
" function!
|
||||||
@ -118,16 +104,6 @@ function! youcompleteme#Enable()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function s:DeferredUntilInsertEnter()
|
|
||||||
let s:defer_omnifunc = 0
|
|
||||||
autocmd! ycm_defer_omnifunc
|
|
||||||
|
|
||||||
if s:AllowedToCompleteInCurrentBuffer()
|
|
||||||
call s:SetOmnicompleteFunc()
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
|
|
||||||
function! youcompleteme#EnableCursorMovedAutocommands()
|
function! youcompleteme#EnableCursorMovedAutocommands()
|
||||||
augroup ycmcompletemecursormove
|
augroup ycmcompletemecursormove
|
||||||
autocmd!
|
autocmd!
|
||||||
@ -470,10 +446,7 @@ function! s:OnBufferRead()
|
|||||||
|
|
||||||
call s:SetUpCompleteopt()
|
call s:SetUpCompleteopt()
|
||||||
call s:SetCompleteFunc()
|
call s:SetCompleteFunc()
|
||||||
|
|
||||||
if !s:defer_omnifunc
|
|
||||||
call s:SetOmnicompleteFunc()
|
call s:SetOmnicompleteFunc()
|
||||||
endif
|
|
||||||
|
|
||||||
exec s:python_command "ycm_state.OnBufferVisit()"
|
exec s:python_command "ycm_state.OnBufferVisit()"
|
||||||
call s:OnFileReadyToParse()
|
call s:OnFileReadyToParse()
|
||||||
@ -514,6 +487,19 @@ endfunction
|
|||||||
|
|
||||||
|
|
||||||
function! s:OnFileReadyToParse()
|
function! s:OnFileReadyToParse()
|
||||||
|
if s:Pyeval( 'ycm_state.ServerBecomesReady()' )
|
||||||
|
" Server was not ready until now and could not parse previous requests for
|
||||||
|
" the current buffer. We need to send them again.
|
||||||
|
exec s:python_command "ycm_state.OnBufferVisit()"
|
||||||
|
exec s:python_command "ycm_state.OnFileReadyToParse()"
|
||||||
|
" Setting the omnifunc requires us to ask the server if it has a native
|
||||||
|
" semantic completer for the current buffer's filetype. Since we only set it
|
||||||
|
" when entering a buffer or changing the filetype, we try to set it again
|
||||||
|
" now that the server is ready.
|
||||||
|
call s:SetOmnicompleteFunc()
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
" We need to call this just in case there is no b:ycm_changetick; this can
|
" We need to call this just in case there is no b:ycm_changetick; this can
|
||||||
" happen for special buffers.
|
" happen for special buffers.
|
||||||
call s:SetUpYcmChangedTick()
|
call s:SetUpYcmChangedTick()
|
||||||
@ -610,6 +596,8 @@ function! s:OnInsertEnter()
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
let s:old_cursor_position = []
|
let s:old_cursor_position = []
|
||||||
|
|
||||||
|
call s:OnFileReadyToParse()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
@ -127,6 +127,7 @@ class YouCompleteMe( object ):
|
|||||||
self._server_popen = None
|
self._server_popen = None
|
||||||
self._filetypes_with_keywords_loaded = set()
|
self._filetypes_with_keywords_loaded = set()
|
||||||
self._ycmd_keepalive = YcmdKeepalive()
|
self._ycmd_keepalive = YcmdKeepalive()
|
||||||
|
self._server_is_ready_with_cache = False
|
||||||
self._SetupLogging()
|
self._SetupLogging()
|
||||||
self._SetupServer()
|
self._SetupServer()
|
||||||
self._ycmd_keepalive.Start()
|
self._ycmd_keepalive.Start()
|
||||||
@ -137,6 +138,9 @@ class YouCompleteMe( object ):
|
|||||||
def _SetupServer( self ):
|
def _SetupServer( self ):
|
||||||
self._available_completers = {}
|
self._available_completers = {}
|
||||||
self._user_notified_about_crash = False
|
self._user_notified_about_crash = False
|
||||||
|
self._filetypes_with_keywords_loaded = set()
|
||||||
|
self._server_is_ready_with_cache = False
|
||||||
|
|
||||||
server_port = utils.GetUnusedLocalhostPort()
|
server_port = utils.GetUnusedLocalhostPort()
|
||||||
# The temp options file is deleted by ycmd during startup
|
# The temp options file is deleted by ycmd during startup
|
||||||
with NamedTemporaryFile( delete = False, mode = 'w+' ) as options_file:
|
with NamedTemporaryFile( delete = False, mode = 'w+' ) as options_file:
|
||||||
@ -339,6 +343,15 @@ class YouCompleteMe( object ):
|
|||||||
self.NativeFiletypeCompletionAvailable() )
|
self.NativeFiletypeCompletionAvailable() )
|
||||||
|
|
||||||
|
|
||||||
|
def ServerBecomesReady( self ):
|
||||||
|
if not self._server_is_ready_with_cache:
|
||||||
|
with HandleServerException( display = False ):
|
||||||
|
self._server_is_ready_with_cache = BaseRequest.GetDataFromHandler(
|
||||||
|
'ready' )
|
||||||
|
return self._server_is_ready_with_cache
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def OnFileReadyToParse( self ):
|
def OnFileReadyToParse( self ):
|
||||||
if not self.IsServerAlive():
|
if not self.IsServerAlive():
|
||||||
self._NotifyUserIfServerCrashed()
|
self._NotifyUserIfServerCrashed()
|
||||||
@ -720,6 +733,7 @@ class YouCompleteMe( object ):
|
|||||||
if filetype in self._filetypes_with_keywords_loaded:
|
if filetype in self._filetypes_with_keywords_loaded:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if self._server_is_ready_with_cache:
|
||||||
self._filetypes_with_keywords_loaded.add( filetype )
|
self._filetypes_with_keywords_loaded.add( filetype )
|
||||||
extra_data[ 'syntax_keywords' ] = list(
|
extra_data[ 'syntax_keywords' ] = list(
|
||||||
syntax_parse.SyntaxKeywordsForCurrentBuffer() )
|
syntax_parse.SyntaxKeywordsForCurrentBuffer() )
|
||||||
|
Loading…
Reference in New Issue
Block a user