Supporting multiple filetypes set for current file
Vim allows setting the filetype string to something like "cpp.c", which means that the file is both cpp and c (nonsense, but allowed). We need to support such filetype strings.
This commit is contained in:
parent
1779cbbb55
commit
c67658bbce
@ -67,8 +67,9 @@ def EscapeForVim( text ):
|
||||
return text.replace( "'", "''" )
|
||||
|
||||
|
||||
def CurrentFiletype():
|
||||
return vim.eval( "&filetype" )
|
||||
def CurrentFiletypes():
|
||||
ft_string = vim.eval( "&filetype" )
|
||||
return ft_string.split( '.' )
|
||||
|
||||
|
||||
def GetVariableValue( variable ):
|
||||
|
@ -51,7 +51,17 @@ class YouCompleteMe( object ):
|
||||
|
||||
|
||||
def GetFiletypeCompleterForCurrentFile( self ):
|
||||
filetype = vimsupport.CurrentFiletype()
|
||||
filetypes = vimsupport.CurrentFiletypes()
|
||||
|
||||
for filetype in filetypes:
|
||||
completer = self.GetFiletypeCompleterForFiletype( filetype )
|
||||
if completer:
|
||||
return completer
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def GetFiletypeCompleterForFiletype( self, filetype ):
|
||||
try:
|
||||
return self.filetype_completers[ filetype ]
|
||||
except KeyError:
|
||||
@ -92,8 +102,11 @@ class YouCompleteMe( object ):
|
||||
|
||||
|
||||
def FiletypeCompletionEnabledForCurrentFile( self ):
|
||||
return ( vimsupport.CurrentFiletype() not in
|
||||
FILETYPE_SPECIFIC_COMPLETION_TO_DISABLE and
|
||||
filetypes = vimsupport.CurrentFiletypes()
|
||||
filetype_disabled = all([ x in FILETYPE_SPECIFIC_COMPLETION_TO_DISABLE
|
||||
for x in filetypes ])
|
||||
|
||||
return ( not filetype_disabled and
|
||||
self.FiletypeCompletionAvailableForFile() )
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user