Ensuring ident completion works always
A bug turned it off when omni completion was available. Fixes #583.
This commit is contained in:
parent
a534a58477
commit
bc607724f0
@ -84,7 +84,9 @@ class BaseRequest( object ):
|
|||||||
server_location = 'http://localhost:6666'
|
server_location = 'http://localhost:6666'
|
||||||
|
|
||||||
|
|
||||||
def BuildRequestData( start_column = None, query = None ):
|
def BuildRequestData( start_column = None,
|
||||||
|
query = None,
|
||||||
|
include_buffer_data = True ):
|
||||||
line, column = vimsupport.CurrentLineAndColumn()
|
line, column = vimsupport.CurrentLineAndColumn()
|
||||||
filepath = vimsupport.GetCurrentBufferFilepath()
|
filepath = vimsupport.GetCurrentBufferFilepath()
|
||||||
request_data = {
|
request_data = {
|
||||||
@ -93,10 +95,11 @@ def BuildRequestData( start_column = None, query = None ):
|
|||||||
'column_num': column,
|
'column_num': column,
|
||||||
'start_column': start_column,
|
'start_column': start_column,
|
||||||
'line_value': vim.current.line,
|
'line_value': vim.current.line,
|
||||||
'filepath': filepath,
|
'filepath': filepath
|
||||||
'file_data': vimsupport.GetUnsavedAndCurrentBufferData()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if include_buffer_data:
|
||||||
|
request_data[ 'file_data' ] = vimsupport.GetUnsavedAndCurrentBufferData()
|
||||||
if query:
|
if query:
|
||||||
request_data[ 'query' ] = query
|
request_data[ 'query' ] = query
|
||||||
|
|
||||||
|
@ -19,7 +19,9 @@
|
|||||||
|
|
||||||
import vim
|
import vim
|
||||||
from ycm import vimsupport
|
from ycm import vimsupport
|
||||||
|
from ycm import base
|
||||||
from ycm.completers.completer import Completer
|
from ycm.completers.completer import Completer
|
||||||
|
from ycm.client.base_request import BuildRequestData
|
||||||
|
|
||||||
OMNIFUNC_RETURNED_BAD_VALUE = 'Omnifunc returned bad value to YCM!'
|
OMNIFUNC_RETURNED_BAD_VALUE = 'Omnifunc returned bad value to YCM!'
|
||||||
OMNIFUNC_NOT_LIST = ( 'Omnifunc did not return a list or a dict with a "words" '
|
OMNIFUNC_NOT_LIST = ( 'Omnifunc did not return a list or a dict with a "words" '
|
||||||
@ -35,15 +37,21 @@ class OmniCompleter( Completer ):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
def Available( self ):
|
|
||||||
return bool( self._omnifunc )
|
|
||||||
|
|
||||||
|
|
||||||
def ShouldUseCache( self ):
|
def ShouldUseCache( self ):
|
||||||
return bool( self.user_options[ 'cache_omnifunc' ] )
|
return bool( self.user_options[ 'cache_omnifunc' ] )
|
||||||
|
|
||||||
|
|
||||||
def ShouldUseNow( self, request_data ):
|
# We let the caller call this without passing in request_data. This is useful
|
||||||
|
# for figuring out should we even be preparing the "real" request_data in
|
||||||
|
# omni_completion_request. The real request_data is much bigger and takes
|
||||||
|
# longer to prepare, and we want to avoid creating it twice.
|
||||||
|
def ShouldUseNow( self, request_data = None ):
|
||||||
|
if not self._omnifunc:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if not request_data:
|
||||||
|
request_data = _BuildRequestDataSubstitute()
|
||||||
|
|
||||||
if self.ShouldUseCache():
|
if self.ShouldUseCache():
|
||||||
return super( OmniCompleter, self ).ShouldUseNow( request_data )
|
return super( OmniCompleter, self ).ShouldUseNow( request_data )
|
||||||
return self.ShouldUseNowInner( request_data )
|
return self.ShouldUseNowInner( request_data )
|
||||||
@ -96,3 +104,10 @@ class OmniCompleter( Completer ):
|
|||||||
def OnFileReadyToParse( self, request_data ):
|
def OnFileReadyToParse( self, request_data ):
|
||||||
self._omnifunc = vim.eval( '&omnifunc' )
|
self._omnifunc = vim.eval( '&omnifunc' )
|
||||||
|
|
||||||
|
|
||||||
|
def _BuildRequestDataSubstitute():
|
||||||
|
data = BuildRequestData( include_buffer_data = False )
|
||||||
|
data[ 'start_column' ] = base.CompletionStartColumn()
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ class YouCompleteMe( object ):
|
|||||||
# function calls... Thus we need to keep this request somewhere.
|
# function calls... Thus we need to keep this request somewhere.
|
||||||
if ( not self.NativeFiletypeCompletionAvailable() and
|
if ( not self.NativeFiletypeCompletionAvailable() and
|
||||||
self.CurrentFiletypeCompletionEnabled() and
|
self.CurrentFiletypeCompletionEnabled() and
|
||||||
self._omnicomp.Available() ):
|
self._omnicomp.ShouldUseNow() ):
|
||||||
self._latest_completion_request = OmniCompletionRequest( self._omnicomp )
|
self._latest_completion_request = OmniCompletionRequest( self._omnicomp )
|
||||||
else:
|
else:
|
||||||
self._latest_completion_request = CompletionRequest( force_semantic )
|
self._latest_completion_request = CompletionRequest( force_semantic )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user