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

View File

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