-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.ycm_extra_conf.py
41 lines (36 loc) · 1.18 KB
/
.ycm_extra_conf.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
37
38
39
40
41
import os
import ycm_core
import logging
import subprocess
import re
vimvs_exe = ""
def Vimvs_getycm( filename ):
global vimvs_exe
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
p = subprocess.Popen([vimvs_exe, '-getycm=' + filename], stdout=subprocess.PIPE, startupinfo=startupinfo)
out,err = p.communicate()
if p.returncode>0:
raise Exception("VIMVS: getycm failed")
strings = re.search("^\s*YCM_CMD:(.*)", out, flags=re.MULTILINE)
if strings is None:
raise Exception("VIMVS: error parsing getycm output. Could not find YCM_CMD line.")
res = []
cmds = strings.group(1).split("|")
for cmd in cmds:
if cmd.strip()!="":
res.append(cmd)
return res
def FlagsForFile( filename, **kwargs ):
global vimvs_exe
if not (kwargs and 'client_data' in kwargs):
raise Exception("VIMVS: client_data not found in kwargs")
client_data = kwargs['client_data']
if not (client_data and 'g:vimvs_exe' in client_data):
raise Exception("VIMVS: g:vimvs_exe not present in client_data")
vimvs_exe = client_data['g:vimvs_exe']
cmd = Vimvs_getycm( filename )
return {
'flags' : cmd,
'do_cache' : True
}