Make caching optional in the omnicompleter

This commit is contained in:
Jacek Lach 2013-04-08 21:26:34 +01:00
parent 20c535a970
commit 1b4eb6122c
3 changed files with 36 additions and 0 deletions

View File

@ -877,6 +877,18 @@ Default: `[see next line]`
\ 'erlang' : [':'],
\ }
### The `g:ycm_cache_omnifunc` option
Some omnicompletion engines do not work well with the YCM cache - in
particular, they might not produce all possible results for a given prefix. By
unsetting this option you can ensure that the omnicompletion engine is
requeried on every keypress. That will ensure all completions will be
presented, but might cause stuttering and lagginess if the omnifunc is slow.
Default: `1`
let g:ycm_cache_omnifunc = 1
FAQ
---

View File

@ -133,6 +133,8 @@ let g:ycm_semantic_triggers =
\ 'erlang' : [':'],
\ } )
let g:ycm_cache_omnifunc = 1
" On-demand loading. Let's use the autoload folder and not slow down vim's
" startup procedure.
augroup youcompletemeStart

View File

@ -36,12 +36,28 @@ class OmniCompleter( Completer ):
return []
def ShouldUseCache( self ):
return vimsupport.GetBoolValue( "g:ycm_cache_omnifunc" )
def ShouldUseNow( self, start_column ):
if self.ShouldUseCache():
return super( OmniCompleter, self ).ShouldUseNow( start_column )
return self.ShouldUseNowInner( start_column )
def ShouldUseNowInner( self, start_column ):
if not self.omnifunc:
return False
return super( OmniCompleter, self ).ShouldUseNowInner( start_column )
def CandidatesForQueryAsync( self, query, unused_start_column ):
if self.ShouldUseCache():
return super( OmniCompleter, self ).CandidatesForQueryAsync(
query, unused_start_column )
else:
return self.CandidatesForQueryAsyncInner( query, unused_start_column )
def CandidatesForQueryAsyncInner( self, query, unused_start_column ):
if not self.omnifunc:
self.stored_candidates = None
@ -81,6 +97,12 @@ class OmniCompleter( Completer ):
self.omnifunc = vim.eval( '&omnifunc' )
def CandidatesFromStoredRequest( self ):
if self.ShouldUseCache():
return super( OmniCompleter, self ).CandidatesFromStoredRequest()
else:
return self.CandidatesFromStoredRequestInner()
def CandidatesFromStoredRequestInner( self ):
return self.stored_candidates if self.stored_candidates else []