Skip to content

Commit 947269e

Browse files
committed
Add .ycm_extra_conf for users that use YCM
1 parent 8c15fa8 commit 947269e

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

.ycm_extra_conf.py

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Copyright 2013 Google, Inc.
2+
# Copyright 2013 Dean Michael Berris <[email protected]>
3+
# Distributed under the Boost Software License, Version 1.0.
4+
# (See accompanying file LICENSE_1_0.txt or copy at
5+
# http://www.boost.org/LICENSE_1_0.txt)
6+
#
7+
# Project-wide configuration for YouCompleteMe Vim plugin.
8+
#
9+
# Based off of Valloric's .ycm_conf_extra.py for YouCompleteMe:
10+
# https://github.com/Valloric/YouCompleteMe/blob/master/cpp/ycm/.ycm_extra_conf.py
11+
#
12+
13+
import os
14+
import ycm_core
15+
16+
flags = [
17+
'-Wall',
18+
'-Wextra',
19+
'-Werror',
20+
'-std=c++03',
21+
'-isystem',
22+
'.',
23+
'-isystem',
24+
'/usr/include',
25+
'-isystem',
26+
'/usr/include/c++/4.6',
27+
'-isystem',
28+
'/usr/include/clang/3.0/include',
29+
'-I',
30+
os.environ['BOOST_ROOT'],
31+
# Always enable debugging for the project when building for semantic
32+
# completion.
33+
'-DBOOST_NETWORK_DEBUG',
34+
]
35+
36+
def DirectoryOfThisScript():
37+
return os.path.dirname(os.path.abspath(__file__))
38+
39+
40+
def MakeRelativePathsInFlagsAbsolute(flags, working_directory):
41+
if not working_directory:
42+
return list(flags)
43+
new_flags = []
44+
make_next_absolute = False
45+
path_flags = ['-isystem', '-I', '-iquote', '--sysroot=']
46+
for flag in flags:
47+
new_flag = flag
48+
if make_next_absolute:
49+
make_next_absolute = False
50+
if not flag.startswith('/'):
51+
new_flag = os.path.join(working_directory, flag)
52+
53+
for path_flag in path_flags:
54+
if flag == path_flag:
55+
make_next_absolute = True
56+
break
57+
if flag.startswith(path_flag):
58+
path = flag[len(path_flag):]
59+
new_flag = path_flag + os.path.join(working_directory, path)
60+
break
61+
62+
if new_flag:
63+
new_flags.append(new_flag)
64+
return new_flags
65+
66+
67+
def FlagsForFile(filename):
68+
relative_to = DirectoryOfThisScript()
69+
final_flags = MakeRelativePathsInFlagsAbsolute(flags, relative_to)
70+
return {'flags': final_flags, 'do_cache': True }

0 commit comments

Comments
 (0)