From 8a4e1394258615aa578f11db76da7626c6a1bd30 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Sun, 6 Nov 2016 13:52:47 -0500 Subject: [PATCH] Add ycm hack to get system includes from clang (until https://github.com/Valloric/YouCompleteMe/issues/2330 is fixed). --- .ycm_extra_conf.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.ycm_extra_conf.py b/.ycm_extra_conf.py index 46d8525fc..c8fc3fc59 100644 --- a/.ycm_extra_conf.py +++ b/.ycm_extra_conf.py @@ -41,9 +41,22 @@ def MakeRelativePathsInFlagsAbsolute( flags, working_directory ): new_flags.append( new_flag ) return new_flags +# Dirty hack until ycm #2330 is solved +def LoadSystemIncludes(): + regex = re.compile(ur'(?:\#include \<...\> search starts here\:)(?P.*?)(?:End of search list)', re.DOTALL); + process = subprocess.Popen(['clang', '-v', '-E', '-x', 'c++', '-'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE); + process_out, process_err = process.communicate(''); + output = process_out + process_err; + includes = []; + for p in re.search(regex, output).group('list').split('\n'): + p = p.strip(); + if len(p) > 0 and p.find('(framework directory)') < 0: + includes.append('-isystem'); + includes.append(p); + return includes; def FlagsForFile( filename, **kwargs ): - final_flags = MakeRelativePathsInFlagsAbsolute( flags, DirectoryOfThisScript() ) + final_flags = MakeRelativePathsInFlagsAbsolute( flags, DirectoryOfThisScript() ) + LoadSystemIncludes() return { 'flags': final_flags, 'do_cache': True