diff options
Diffstat (limited to 'vim/.vim/config/ycm_extra_conf.py')
-rw-r--r-- | vim/.vim/config/ycm_extra_conf.py | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/vim/.vim/config/ycm_extra_conf.py b/vim/.vim/config/ycm_extra_conf.py new file mode 100644 index 0000000..3a827dd --- /dev/null +++ b/vim/.vim/config/ycm_extra_conf.py | |||
@@ -0,0 +1,76 @@ | |||
1 | import os | ||
2 | import ycm_core | ||
3 | from clang_helpers import PrepareClangFlags | ||
4 | |||
5 | compilation_database_folder = '' | ||
6 | |||
7 | if compilation_database_folder: | ||
8 | database = ycm_core.CompilationDatabase(compilation_database_folder) | ||
9 | else: | ||
10 | database = None | ||
11 | |||
12 | flags = [ | ||
13 | '-Wall', | ||
14 | '-std=c++11', | ||
15 | '-stdlib=libc++', | ||
16 | '-x', | ||
17 | 'c++', | ||
18 | '-I/usr/local/include', | ||
19 | '-I/usr/include', | ||
20 | '-I/home/clarkzjw/Code/clang3.9.0/include/c++/v1', | ||
21 | '.', | ||
22 | ] | ||
23 | |||
24 | |||
25 | def DirectoryOfThisScript(): | ||
26 | return os.path.dirname(os.path.abspath(__file__)) | ||
27 | |||
28 | |||
29 | def MakeRelativePathsInFlagsAbsolute(flags, working_directory): | ||
30 | if not working_directory: | ||
31 | return flags | ||
32 | new_flags = [] | ||
33 | make_next_absolute = False | ||
34 | path_flags = ['-isystem', '-I', '-iquote', '--sysroot='] | ||
35 | for flag in flags: | ||
36 | new_flag = flag | ||
37 | |||
38 | if make_next_absolute: | ||
39 | make_next_absolute = False | ||
40 | if not flag.startswith('/'): | ||
41 | new_flag = os.path.join(working_directory, flag) | ||
42 | |||
43 | for path_flag in path_flags: | ||
44 | if flag == path_flag: | ||
45 | make_next_absolute = True | ||
46 | break | ||
47 | |||
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 | |||
53 | if new_flag: | ||
54 | new_flags.append(new_flag) | ||
55 | return new_flags | ||
56 | |||
57 | |||
58 | def FlagsForFile(filename): | ||
59 | if database: | ||
60 | # Bear in mind that compilation_info.compiler_flags_ does NOT return a | ||
61 | # python list, but a "list-like" StringVec object | ||
62 | compilation_info = database.GetCompilationInfoForFile(filename) | ||
63 | final_flags = PrepareClangFlags( | ||
64 | MakeRelativePathsInFlagsAbsolute( | ||
65 | compilation_info.compiler_flags_, | ||
66 | compilation_info.compiler_working_dir_), | ||
67 | filename) | ||
68 | |||
69 | else: | ||
70 | relative_to = DirectoryOfThisScript() | ||
71 | final_flags = MakeRelativePathsInFlagsAbsolute(flags, relative_to) | ||
72 | |||
73 | return { | ||
74 | 'flags': final_flags, | ||
75 | 'do_cache': True | ||
76 | } | ||