units
Use physical dimensions at compile-time or run-time.
.ycm_extra_conf.py
Go to the documentation of this file.
1 ## @file ".ycm_extra_conf.py"
2 # @brief Configuration for vim's YouCompleteMe plugin.
3 # @copyright 2019 Thomas E. Vaughan; all rights reserved.
4 # @license BSD three-clause; see LICENSE.
5 
6 import os
7 
8 DIR_OF_THIS_SCRIPT = os.path.abspath( os.path.dirname( __file__ ) )
9 
10 ## Compilation flags that will be used in case there's no
11 # compilation database set (by default, one is not set).
12 #
13 # CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR.
14 flags = [
15 '-Wall',
16 '-Wextra',
17 '-Werror',
18 '-std=c++14',
19 '-x', 'c++',
20 '-isystem', '/usr/include/clang/7/include',
21 '-I', '.',
22 ]
23 
24 ## Variable that seems necessary for new YCM.
25 # SOURCE_EXTENSIONS is used by FindCorrespondingSourceFile.
26 SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
27 
28 ## @name OlderGroup
29 # Functions that seem necessary for older YCM.
30 #
31 # @{
32 def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
33  if not working_directory:
34  return list( flags )
35  new_flags = []
36  make_next_absolute = False
37  path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
38  for flag in flags:
39  new_flag = flag
40  if make_next_absolute:
41  make_next_absolute = False
42  if not flag.startswith( '/' ):
43  new_flag = os.path.join( working_directory, flag )
44  for path_flag in path_flags:
45  if flag == path_flag:
46  make_next_absolute = True
47  break
48  if flag.startswith( path_flag ):
49  path = flag[ len( path_flag ): ]
50  new_flag = path_flag + os.path.join( working_directory, path )
51  break
52  if new_flag:
53  new_flags.append( new_flag )
54  return new_flags
55 
56 ## This seems to be the entry point for older YCM; this function is called by
57 # ycmd to produce flags for a file.
58 def FlagsForFile( filename, **kwargs ):
59  final_flags = MakeRelativePathsInFlagsAbsolute(flags, DIR_OF_THIS_SCRIPT)
60  return {
61  'flags': final_flags,
62  }
63 ## @}
64 
65 ## @name NewerGroup
66 # Functions that seem necessary for newer YCM.
67 #
68 # @{
69 def IsHeaderFile( filename ):
70  extension = os.path.splitext( filename )[ 1 ]
71  return extension in [ '.h', '.hxx', '.hpp', '.hh' ]
72 
74  if IsHeaderFile( filename ):
75  basename = os.path.splitext( filename )[ 0 ]
76  for extension in SOURCE_EXTENSIONS:
77  replacement_file = basename + extension
78  if os.path.exists( replacement_file ):
79  return replacement_file
80  return filename
81 
82 ## This seems to be the entry point for newer YCM.
83 def Settings( **kwargs ):
84  if kwargs[ 'language' ] == 'cfamily':
85  filename = FindCorrespondingSourceFile( kwargs[ 'filename' ] )
86  return {
87  'flags': flags,
88  'include_paths_relative_to_dir': DIR_OF_THIS_SCRIPT,
89  'override_filename': filename
90  }
91  return {}
92 ## @}
93 
def IsHeaderFile(filename)
def FindCorrespondingSourceFile(filename)
def FlagsForFile(filename, kwargs)
This seems to be the entry point for older YCM; this function is called by ycmd to produce flags for ...
def Settings(kwargs)
This seems to be the entry point for newer YCM.
def MakeRelativePathsInFlagsAbsolute(flags, working_directory)