diff --git a/.ycm_extra_conf.py b/.ycm_extra_conf.py index 6d79c46245..793beda795 100644 --- a/.ycm_extra_conf.py +++ b/.ycm_extra_conf.py @@ -42,7 +42,6 @@ import sys # Flags from YCM's default config. flags = [ '-DUSE_CLANG_COMPLETER', -'-std=gnu++14', '-x', 'c++', ] @@ -143,25 +142,27 @@ def GetClangCommandFromNinjaForFilename(v8_root, filename): # Parse flags that are important for YCM's purposes. for flag in clang_line.split(' '): if flag.startswith('-I'): - # Relative paths need to be resolved, because they're relative to the - # output dir, not the source. - if flag[2] == '/': - v8_flags.append(flag) - else: - abs_path = os.path.normpath(os.path.join(out_dir, flag[2:])) - v8_flags.append('-I' + abs_path) - elif flag.startswith('-std'): + v8_flags.append(MakeIncludePathAbsolute(flag, "-I", out_dir)) + elif flag.startswith('-isystem'): + v8_flags.append(MakeIncludePathAbsolute(flag, "-isystem", out_dir)) + elif flag.startswith('-std') or flag.startswith( + '-pthread') or flag.startswith('-no'): v8_flags.append(flag) - elif flag.startswith('-') and flag[1] in 'DWFfmO': - if flag == '-Wno-deprecated-register' or flag == '-Wno-header-guard': - # These flags causes libclang (3.3) to crash. Remove it until things - # are fixed. - continue + elif flag.startswith('-') and flag[1] in 'DWFfmgOX': v8_flags.append(flag) - return v8_flags +def MakeIncludePathAbsolute(flag, prefix, out_dir): + # Relative paths need to be resolved, because they're relative to the + # output dir, not the source. + if flag[len(prefix)] == '/': + return flag + else: + abs_path = os.path.normpath(os.path.join(out_dir, flag[len(prefix):])) + return prefix + abs_path + + def FlagsForFile(filename): """This is the main entry point for YCM. Its interface is fixed. @@ -180,3 +181,9 @@ def FlagsForFile(filename): 'flags': final_flags, 'do_cache': True } + + +def Settings(**kwargs): + if kwargs['language'] == 'cfamily': + return FlagsForFile(kwargs['filename']) + return {}