1 # this file is based on the YCMs example/global ycm_extra_conf.py file,
2 # tailored to the needs of the project. This is the described way
3 # to do a custom configuratoin.
9 SOURCE_EXTENSIONS
= [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
23 '-isystem', '/usr/include',
24 '-isystem', '/usr/local/include',
27 # Clang automatically sets the '-std=' flag to 'c++14' for MSVC 2015 or later,
28 # which is required for compiling the standard library, and to 'c++11' for older
30 if platform
.system() != 'Windows':
31 flags
.append( '-std=c++11' )
34 compilation_database_folder
= p
.dirname(p
.abspath(__file__
)) + '/build'
37 def IsHeaderFile( filename
):
38 extension
= p
.splitext( filename
)[ 1 ]
39 return extension
in [ '.h', '.hxx', '.hpp', '.hh' ]
42 def FindCorrespondingSourceFile( filename
):
43 if IsHeaderFile( filename
):
44 basename
= p
.splitext( filename
)[ 0 ]
45 for extension
in SOURCE_EXTENSIONS
:
46 replacement_file
= basename
+ extension
47 if p
.exists( replacement_file
):
48 return replacement_file
52 def Settings( **kwargs
):
53 # Do NOT import ycm_core at module scope.
57 if database
is None and p
.exists( compilation_database_folder
):
58 database
= ycm_core
.CompilationDatabase( compilation_database_folder
)
60 language
= kwargs
[ 'language' ]
62 if language
== 'cfamily':
63 # If the file is a header, try to find the corresponding source file and
64 # retrieve its flags from the compilation database if using one. This is
65 # necessary since compilation databases don't have entries for header files.
66 # In addition, use this source file as the translation unit. This makes it
67 # possible to jump from a declaration in the header file to its definition
68 # in the corresponding source file.
69 filename
= FindCorrespondingSourceFile( kwargs
[ 'filename' ] )
74 'include_paths_relative_to_dir': DIR_OF_THIS_SCRIPT
,
75 'override_filename': filename
78 compilation_info
= database
.GetCompilationInfoForFile( filename
)
79 if not compilation_info
.compiler_flags_
:
82 # Bear in mind that compilation_info.compiler_flags_ does NOT return a
83 # python list, but a "list-like" StringVec object.
84 final_flags
= list( compilation_info
.compiler_flags_
)
86 # NOTE: This is just for YouCompleteMe; it's highly likely that your project
87 # does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR
88 # ycm_extra_conf IF YOU'RE NOT 100% SURE YOU NEED IT.
90 final_flags
.remove( '-stdlib=libc++' )
96 'include_paths_relative_to_dir': compilation_info
.compiler_working_dir_
,
97 'override_filename': filename