Merge pull request #119 from olajep/let-local-conf-override-global
Let local YCM config file override global config file
This commit is contained in:
commit
9e3aa21a77
11
README.md
11
README.md
@ -314,7 +314,7 @@ or in any directory above it in the hierarchy (recursively); when the file is
|
|||||||
found, it is loaded (only once!) as a Python module. YCM calls a `FlagsForFile`
|
found, it is loaded (only once!) as a Python module. YCM calls a `FlagsForFile`
|
||||||
method in that module which should provide it with the information necessary to
|
method in that module which should provide it with the information necessary to
|
||||||
compile the current file. (You can also provide a path to a global
|
compile the current file. (You can also provide a path to a global
|
||||||
`.ycm_extra_conf.py` file and override this searching behavior. See the Options
|
`.ycm_extra_conf.py` file, which will be used as a fallback. See the Options
|
||||||
section for more details.)
|
section for more details.)
|
||||||
|
|
||||||
This system was designed this way so that the user can perform any arbitrary
|
This system was designed this way so that the user can perform any arbitrary
|
||||||
@ -640,11 +640,10 @@ Default: `<leader>d`
|
|||||||
|
|
||||||
### The `g:ycm_global_ycm_extra_conf` option
|
### The `g:ycm_global_ycm_extra_conf` option
|
||||||
|
|
||||||
Normally, YCM searches for a `.ycm_extra_conf.py` file for compilation flags
|
Normally, YCM searches for a '.ycm_extra_conf.py' file for compilation flags
|
||||||
(see the User Guide for more details on how this works). You can use this option
|
(see the User Guide for more details on how this works). This option specifies
|
||||||
to override this searching behavior by providing a full, absolute path to a
|
a fallback path to a config file which is used if no '.ycm_extra_conf.py' is
|
||||||
global `.ycm_extra_conf.py` file (although you can call the global file whatever
|
found.
|
||||||
you want).
|
|
||||||
|
|
||||||
You can place such a global file anywhere in your filesystem.
|
You can place such a global file anywhere in your filesystem.
|
||||||
|
|
||||||
|
@ -717,10 +717,9 @@ Default: '<leader>d'
|
|||||||
The *g:ycm_global_ycm_extra_conf* option
|
The *g:ycm_global_ycm_extra_conf* option
|
||||||
|
|
||||||
Normally, YCM searches for a '.ycm_extra_conf.py' file for compilation flags
|
Normally, YCM searches for a '.ycm_extra_conf.py' file for compilation flags
|
||||||
(see the User Guide for more details on how this works). You can use this
|
(see the User Guide for more details on how this works). This option specifies
|
||||||
option to override this searching behavior by providing a full, absolute path
|
a fallback path to a config file which is used if no '.ycm_extra_conf.py' is
|
||||||
to a global '.ycm_extra_conf.py' file (although you can call the global file
|
found.
|
||||||
whatever you want).
|
|
||||||
|
|
||||||
You can place such a global file anywhere in your filesystem.
|
You can place such a global file anywhere in your filesystem.
|
||||||
|
|
||||||
|
@ -92,27 +92,31 @@ class Flags( object ):
|
|||||||
|
|
||||||
def _FlagsModuleSourceFileForFile( filename ):
|
def _FlagsModuleSourceFileForFile( filename ):
|
||||||
"""For a given filename, finds its nearest YCM_EXTRA_CONF_FILENAME file that
|
"""For a given filename, finds its nearest YCM_EXTRA_CONF_FILENAME file that
|
||||||
will compute the flags necessary to compile the file. Returns None if no
|
will compute the flags necessary to compile the file. If no
|
||||||
YCM_EXTRA_CONF_FILENAME file could be found. Uses the global ycm_extra_conf
|
YCM_EXTRA_CONF_FILENAME file could be found, try to use
|
||||||
file if one is set."""
|
GLOBAL_YCM_EXTRA_CONF_FILE instead. If that also fails, return None.
|
||||||
|
Uses the global ycm_extra_conf file if one is set."""
|
||||||
if ( GLOBAL_YCM_EXTRA_CONF_FILE and
|
|
||||||
os.path.exists( GLOBAL_YCM_EXTRA_CONF_FILE ) ):
|
|
||||||
return GLOBAL_YCM_EXTRA_CONF_FILE
|
|
||||||
|
|
||||||
|
ycm_conf_file = None
|
||||||
parent_folder = os.path.dirname( filename )
|
parent_folder = os.path.dirname( filename )
|
||||||
old_parent_folder = ''
|
old_parent_folder = ''
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
current_file = os.path.join( parent_folder, YCM_EXTRA_CONF_FILENAME )
|
current_file = os.path.join( parent_folder, YCM_EXTRA_CONF_FILENAME )
|
||||||
if os.path.exists( current_file ):
|
if os.path.exists( current_file ):
|
||||||
return current_file
|
ycm_conf_file = current_file
|
||||||
|
break
|
||||||
|
|
||||||
old_parent_folder = parent_folder
|
old_parent_folder = parent_folder
|
||||||
parent_folder = os.path.dirname( parent_folder )
|
parent_folder = os.path.dirname( parent_folder )
|
||||||
|
if parent_folder is old_parent_folder:
|
||||||
|
break
|
||||||
|
|
||||||
if parent_folder == old_parent_folder:
|
if ( not ycm_conf_file and GLOBAL_YCM_EXTRA_CONF_FILE and
|
||||||
return None
|
os.path.exists( GLOBAL_YCM_EXTRA_CONF_FILE ) ):
|
||||||
|
ycm_conf_file = GLOBAL_YCM_EXTRA_CONF_FILE
|
||||||
|
|
||||||
|
return ycm_conf_file
|
||||||
|
|
||||||
|
|
||||||
def _RandomName():
|
def _RandomName():
|
||||||
|
Loading…
Reference in New Issue
Block a user