Build: docker for clang-14.0.0
[marnav.git] / .ycm_extra_conf.py
blob7902f09be2f7deedda4a519a9f7ad75d368e4bb7
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.
5 import os
6 import platform
7 import os.path as p
9 SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
11 database = None
13 flags = [
14 '-x', 'c++',
15 '-Wall',
16 '-Wextra',
17 '-Werror'
18 '-pedantic',
19 '-std=c++17',
20 '-I.',
21 '-Isrc',
22 '-Iinclude',
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
29 # versions.
30 if platform.system() != 'Windows':
31 flags.append( '-std=c++17' )
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
49 return filename
52 def Settings( **kwargs ):
53 # Do NOT import ycm_core at module scope.
54 import ycm_core
56 global database
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' ] )
71 if not database:
72 return {
73 'flags': flags,
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_:
80 return {}
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.
89 try:
90 final_flags.remove( '-stdlib=libc++' )
91 except ValueError:
92 pass
94 return {
95 'flags': final_flags,
96 'include_paths_relative_to_dir': compilation_info.compiler_working_dir_,
97 'override_filename': filename
100 return {}