From 79f834f97ea05bf01a13b3bd4cf502de9f07e9ee Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Wed, 30 Jan 2013 13:23:57 -0800 Subject: [PATCH] Now possible to specify a global ycm_extra_conf --- README.md | 18 +++++++++++++++++- plugin/youcompleteme.vim | 3 +++ python/completers/cpp/flags.py | 9 ++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5dfd85c8..d0d8d97d 100644 --- a/README.md +++ b/README.md @@ -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: `` let g:ycm_key_invoke_completion = '' +### 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 --- diff --git a/plugin/youcompleteme.vim b/plugin/youcompleteme.vim index a276ebbf..2a3b4446 100644 --- a/plugin/youcompleteme.vim +++ b/plugin/youcompleteme.vim @@ -85,6 +85,9 @@ let g:ycm_key_previous_completion = let g:ycm_key_invoke_completion = \ get( g:, 'ycm_key_invoke_completion', '' ) +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 diff --git a/python/completers/cpp/flags.py b/python/completers/cpp/flags.py index 78642035..9dc857c6 100644 --- a/python/completers/cpp/flags.py +++ b/python/completers/cpp/flags.py @@ -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 = ''