Merge pull request #172 from zehrizzatti/multiple_filetypes
Fix for multiple filetypes set
This commit is contained in:
commit
e72652e463
@ -134,7 +134,7 @@ class Completer( object ):
|
|||||||
if not line_length or start_column - 1 >= line_length:
|
if not line_length or start_column - 1 >= line_length:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
filetype = vimsupport.CurrentFiletypes()[ 0 ]
|
filetype = self._CurrentFiletype()
|
||||||
triggers = self.triggers_for_filetype[ filetype ]
|
triggers = self.triggers_for_filetype[ filetype ]
|
||||||
|
|
||||||
for trigger in triggers:
|
for trigger in triggers:
|
||||||
@ -266,6 +266,17 @@ class Completer( object ):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def _CurrentFiletype( self ):
|
||||||
|
filetypes = vimsupport.CurrentFiletypes()
|
||||||
|
supported = self.SupportedFiletypes()
|
||||||
|
|
||||||
|
for filetype in filetypes:
|
||||||
|
if filetype in supported:
|
||||||
|
return filetype
|
||||||
|
|
||||||
|
return filetypes[0]
|
||||||
|
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def SupportedFiletypes( self ):
|
def SupportedFiletypes( self ):
|
||||||
pass
|
pass
|
||||||
|
@ -246,5 +246,9 @@ def DiagnosticsToDiagStructure( diagnostics ):
|
|||||||
|
|
||||||
|
|
||||||
def ClangAvailableForBuffer( buffer_object ):
|
def ClangAvailableForBuffer( buffer_object ):
|
||||||
filetype = vim.eval( 'getbufvar({0}, "&ft")'.format( buffer_object.number ) )
|
filetypes = vim.eval( 'getbufvar({0}, "&ft")'.format( buffer_object.number ) )
|
||||||
return filetype in CLANG_FILETYPES
|
supported_fts = [ft for ft in filetypes.split('.') if ft in CLANG_FILETYPES]
|
||||||
|
if supported_fts:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
@ -60,11 +60,19 @@ class YouCompleteMe( object ):
|
|||||||
def GetFiletypeCompleter( self ):
|
def GetFiletypeCompleter( self ):
|
||||||
filetypes = vimsupport.CurrentFiletypes()
|
filetypes = vimsupport.CurrentFiletypes()
|
||||||
|
|
||||||
for filetype in filetypes:
|
completers = [self.GetFiletypeCompleterForFiletype( filetype )
|
||||||
completer = self.GetFiletypeCompleterForFiletype( filetype )
|
for filetype in filetypes ]
|
||||||
if completer:
|
|
||||||
|
if not completers:
|
||||||
|
return None
|
||||||
|
|
||||||
|
# Try to find a native completer first
|
||||||
|
for completer in completers:
|
||||||
|
if completer and completer is not self.omnicomp:
|
||||||
return completer
|
return completer
|
||||||
return None
|
|
||||||
|
# Return the omni completer for the first filetype
|
||||||
|
return completers[0]
|
||||||
|
|
||||||
|
|
||||||
def GetFiletypeCompleterForFiletype( self, filetype ):
|
def GetFiletypeCompleterForFiletype( self, filetype ):
|
||||||
|
Loading…
Reference in New Issue
Block a user