def _ShouldLoad(module_file): """Checks if a module is safe to be loaded. By default this will try to decide using a white-/blacklist and ask the user for confirmation as a fallback.""" if (module_file == GLOBAL_YCM_EXTRA_CONF_FILE or not vimsupport.GetBoolValue('g:ycm_confirm_extra_conf')): return True globlist = vimsupport.GetVariableValue('g:ycm_extra_conf_globlist') for glob in globlist: is_blacklisted = glob[0] == '!' if _MatchesGlobPattern(module_file, glob.lstrip('!')): return not is_blacklisted return vimsupport.Confirm(CONFIRM_CONF_FILE_MESSAGE.format(module_file))
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>. import abc import vim import vimsupport import ycm_core from collections import defaultdict NO_USER_COMMANDS = 'This completer does not define any commands.' MIN_NUM_CHARS = int( vimsupport.GetVariableValue("g:ycm_min_num_of_chars_for_completion")) class Completer(object): """A base class for all Completers in YCM. Here's several important things you need to know if you're writing a custom Completer. The following are functions that the Vim part of YCM will be calling on your Completer: ShouldUseNow() is called with the start column of where a potential completion string should start. For instance, if the user's input is 'foo.bar' and the cursor is on the 'r' in 'bar', start_column will be the 0-based index of 'b' in the line. Your implementation of ShouldUseNow() should return True if your semantic completer should be used and False otherwise.
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>. from completers.completer import Completer from collections import defaultdict import vim import vimsupport import ycm_core from flags import Flags CLANG_FILETYPES = set(['c', 'cpp', 'objc', 'objcpp']) MAX_DIAGNOSTICS_TO_DISPLAY = int( vimsupport.GetVariableValue("g:ycm_max_diagnostics_to_display")) USER_COMMANDS_HELP_MESSAGE = """ Supported commands are: GoToDefinition GoToDeclaration GoToDefinitionElseDeclaration See the docs for information on what they do.""" class ClangCompleter(Completer): def __init__(self): super(ClangCompleter, self).__init__() self.completer = ycm_core.ClangCompleter() self.completer.EnableThreading() self.contents_holder = [] self.filename_holder = []
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>. from completers.completer import Completer from collections import defaultdict import vim import vimsupport import ycm_core from flags import Flags CLANG_FILETYPES = set( [ 'c', 'cpp', 'objc', 'objcpp' ] ) MAX_DIAGNOSTICS_TO_DISPLAY = int( vimsupport.GetVariableValue( "g:ycm_max_diagnostics_to_display" ) ) class ClangCompleter( Completer ): def __init__( self ): self.completer = ycm_core.ClangCompleter() self.completer.EnableThreading() self.contents_holder = [] self.filename_holder = [] self.last_prepared_diagnostics = [] self.parse_future = None self.flags = Flags() self.diagnostic_store = None def SupportedFiletypes( self ):
import os import imp import random import string import sys import vimsupport import vim from fnmatch import fnmatch # Constants YCM_EXTRA_CONF_FILENAME = '.ycm_extra_conf.py' CONFIRM_CONF_FILE_MESSAGE = ('Found {0}. Load? \n\n(Question can be turned ' 'off with options, see YCM docs)') GLOBAL_YCM_EXTRA_CONF_FILE = os.path.expanduser( vimsupport.GetVariableValue("g:ycm_global_ycm_extra_conf")) # Singleton variables _module_for_module_file = {} _module_file_for_source_file = {} def ModuleForSourceFile(filename): return _Load(ModuleFileForSourceFile(filename)) def ModuleFileForSourceFile(filename): """This will try all files returned by _ExtraConfModuleSourceFilesForFile in order and return the filename of the first module that was allowed to load. If no module was found or allowed to load, None is returned."""
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>. import imp import os import ycm_core import random import string import sys import vimsupport YCM_EXTRA_CONF_FILENAME = '.ycm_extra_conf.py' NO_EXTRA_CONF_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): # It's caches all the way down... self.flags_for_file = {} self.flags_module_for_file = {} self.flags_module_for_flags_module_file = {} self.special_clang_flags = _SpecialClangIncludes() self.no_extra_conf_file_warning_posted = False def FlagsForFile(self, filename): try: return self.flags_for_file[filename] except KeyError: