We now only run extra conf preload for global file

This changes functionality, but since this is an undocumented, non-public API,
it's fine. The reason this is required is because of issue #579; if we try to
run extra conf preload on non-global extra conf, we might not have the
permission to load it. The global extra conf is something the user explicitly
has to set so it's always fine to load that.
This commit is contained in:
Strahinja Val Markovic 2013-10-10 12:55:49 -07:00
parent 7a73eb14d8
commit 78e3607b00
2 changed files with 10 additions and 12 deletions

View File

@ -64,26 +64,24 @@ def ModuleFileForSourceFile( filename ):
return _module_file_for_source_file.setdefault( filename ) return _module_file_for_source_file.setdefault( filename )
def CallExtraConfYcmCorePreloadIfExists(): def CallGlobalExtraConfYcmCorePreloadIfExists():
_CallExtraConfMethod( 'YcmCorePreload' ) _CallGlobalExtraConfMethod( 'YcmCorePreload' )
def Shutdown(): def Shutdown():
# VimClose is for the sake of backwards compatibility; it's a no-op when it # VimClose is for the sake of backwards compatibility; it's a no-op when it
# doesn't exist. # doesn't exist.
_CallExtraConfMethod( 'VimClose' ) _CallGlobalExtraConfMethod( 'VimClose' )
_CallExtraConfMethod( 'Shutdown' ) _CallGlobalExtraConfMethod( 'Shutdown' )
def _CallExtraConfMethod( function_name ): def _CallGlobalExtraConfMethod( function_name ):
vim_current_working_directory = os.getcwd() global_ycm_extra_conf = _GlobalYcmExtraConfFileLocation()
path_to_dummy = os.path.join( vim_current_working_directory, 'DUMMY_FILE' ) if not ( global_ycm_extra_conf and
# The dummy file in the Vim CWD ensures we find the correct extra conf file os.path.exists( global_ycm_extra_conf ) ):
try:
module = ModuleForSourceFile( path_to_dummy )
except UnknownExtraConf:
return return
module = Load( global_ycm_extra_conf, force = True )
if not module or not hasattr( module, function_name ): if not module or not hasattr( module, function_name ):
return return
getattr( module, function_name )() getattr( module, function_name )()

View File

@ -30,7 +30,7 @@ class ServerState( object ):
self._user_options = user_options self._user_options = user_options
self._filetype_completers = {} self._filetype_completers = {}
self._gencomp = GeneralCompleterStore( self._user_options ) self._gencomp = GeneralCompleterStore( self._user_options )
extra_conf_store.CallExtraConfYcmCorePreloadIfExists() extra_conf_store.CallGlobalExtraConfYcmCorePreloadIfExists()
@property @property