Skip to content

Commit

Permalink
Do not disable omnifunc when YCM semantic completion is disabled
Browse files Browse the repository at this point in the history
Allow users to still trigger Vim's omnifunc through C-Space when the
g:ycm_filetype_specific_completion_to_disable option is set for the current
filetype.
  • Loading branch information
micbou committed Mar 26, 2018
1 parent 37965fe commit 69c58a9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
13 changes: 12 additions & 1 deletion python/ycm/omni_completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,22 @@ def ShouldUseNow( self, request_data ):


def ShouldUseNowInner( self, request_data ):
if request_data.get( 'force_semantic', False ):
if request_data[ 'force_semantic' ]:
return True
if self.CurrentFiletypeCompletionDisabled():
return False
return super( OmniCompleter, self ).ShouldUseNowInner( request_data )


def CurrentFiletypeCompletionDisabled( self ):
filetypes = vimsupport.CurrentFiletypes()
filetype_to_disable = self.user_options[
'filetype_specific_completion_to_disable' ]
if '*' in filetype_to_disable:
return True
return any( [ x in filetype_to_disable for x in filetypes ] )


def ComputeCandidates( self, request_data ):
if self.ShouldUseCache():
return super( OmniCompleter, self ).ComputeCandidates( request_data )
Expand Down
6 changes: 2 additions & 4 deletions python/ycm/youcompleteme.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,7 @@ def RestartServer( self ):
def SendCompletionRequest( self, force_semantic = False ):
request_data = BuildRequestData()
request_data[ 'force_semantic' ] = force_semantic
if ( not self.NativeFiletypeCompletionAvailable() and
self.CurrentFiletypeCompletionEnabled() ):
if not self.NativeFiletypeCompletionAvailable():
wrapped_request_data = RequestWrap( request_data )
if self._omnicomp.ShouldUseNow( wrapped_request_data ):
self._latest_completion_request = OmniCompletionRequest(
Expand Down Expand Up @@ -814,8 +813,7 @@ def CurrentFiletypeCompletionEnabled( self ):
'filetype_specific_completion_to_disable' ]
if '*' in filetype_to_disable:
return False
else:
return not any( [ x in filetype_to_disable for x in filetypes ] )
return not any( [ x in filetype_to_disable for x in filetypes ] )


def ShowDetailedDiagnostic( self ):
Expand Down

0 comments on commit 69c58a9

Please sign in to comment.