-
Notifications
You must be signed in to change notification settings - Fork 0
/
ycmrc.py
36 lines (30 loc) · 855 Bytes
/
ycmrc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/python3
# vim:noet:sw=4:ts=4
import os
import ycm_core
cf = ['-std=c17', '-O2', '-D_FORTIFY_SOURCE=2', '-Wall', '-Wextra', '-Wpedantic']
cxxf = cf[:]
cxxf[0] = '-std=c++17'
for s in os.listdir('/usr/include/c++/'):
cxxf.append('-isystem')
cxxf.append('/usr/include/c++/' + s)
del s
def FindSrc(f):
b, e = os.path.splitext(f)
if e.lower() in {'', '.h', '.h++', '.hh', '.hp', '.hpp', '.hxx', '.tcc'}:
for e in ('.cc', '.c++', '.cpp', '.cxx', '.cp', '.c', '.m', '.mm', '.tcc'):
r = b + e
if os.path.exists(r):
return r
r = b + e.upper()
if os.path.exists(r):
return r
return f
def Settings(**k):
if 'cfamily' != k['language']:
return {}
k = k['filename']
k = FindSrc(k)
r = os.path.splitext(k)[1].lower()
r = cf if r in {'.c', '.h', '.i', '.m', '.mi'} else cxxf
return {'flags': r, 'override_filename': k}