Now possible to specify a global ycm_extra_conf

This commit is contained in:
Strahinja Val Markovic 2013-01-30 13:23:57 -08:00
parent 5c7adfdec7
commit 79f834f97e
3 changed files with 28 additions and 2 deletions

View File

@ -248,7 +248,9 @@ YCM looks for a `.ycm_extra_conf.py` file in the directory of the opened file
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`
method in that module which should provide it with the information necessary to
compile the current file.
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
section for more details.)
This system was designed this way so that the user can perform any arbitrary
sequence of operations to produce a list of compilation flags YCM should hand
@ -430,6 +432,20 @@ Default: `<C-Space>`
let g:ycm_key_invoke_completion = '<C-Space>'
### The `g:ycm_global_ycm_extra_conf` option
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
to override this searching behavior by providing a full, absolute path to a
global `.ycm_extra_conf.py` file (although you can call the global file whatever
you want).
You can place such a global file anywhere in your filesystem.
Default: ``
let g:ycm_global_ycm_extra_conf = ''
FAQ
---

View File

@ -85,6 +85,9 @@ let g:ycm_key_previous_completion =
let g:ycm_key_invoke_completion =
\ get( g:, 'ycm_key_invoke_completion', '<C-Space>' )
let g:ycm_global_ycm_extra_conf =
\ get( g:, 'ycm_global_ycm_extra_conf', '' )
" This is basic vim plugin boilerplate
let s:save_cpo = &cpo
set cpo&vim

View File

@ -29,6 +29,8 @@ YCM_EXTRA_CONF_FILENAME = '.ycm_extra_conf.py'
NO_OPTIONS_FILENAME_MESSAGE = ('No {0} file detected, so no compile flags '
'are available. Thus no semantic support for C/C++/ObjC/ObjC++.').format(
YCM_EXTRA_CONF_FILENAME )
GLOBAL_YCM_EXTRA_CONF_FILE = vimsupport.GetVariableValue(
"g:ycm_global_ycm_extra_conf" )
class Flags( object ):
def __init__( self ):
@ -88,7 +90,12 @@ class Flags( object ):
def _FlagsModuleSourceFileForFile( filename ):
"""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
YCM_EXTRA_CONF_FILENAME file could be found."""
YCM_EXTRA_CONF_FILENAME file could be found. 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
parent_folder = os.path.dirname( filename )
old_parent_folder = ''