Skip to content

Commit

Permalink
Fixed case when compile db is not at project root.
Browse files Browse the repository at this point in the history
Added -isystem flag awareness.
  • Loading branch information
umitkablan committed Feb 20, 2018
1 parent 47666aa commit b44dd45
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion plugin/clang.vim
Expand Up @@ -901,6 +901,7 @@ python << endpython
import vim
import re
import json
from os import path

current = vim.eval("expand('%:p')")
ccd = vim.eval("l:ccd")
Expand All @@ -915,8 +916,12 @@ with open(ccd) as database:
dmatch = re.search(r'(.*)\.(\w+)$', d['file'])

if fmatch.group(1) == dmatch.group(1):
for result in re.finditer(r'-[ID]\s*[^\s]+', d['command']):
for result in re.finditer(r'-D\s*[^\s]+', d['command']):
opts.append(result.group(0))
for result in re.finditer(r'-isystem\s*[^\s]+', d['command']):
opts.append(result.group(0))
for result in re.finditer(r'-I\s*([^\s]+)', d['command']):
opts.append('-I' + path.join(d['directory'], result.group(1)))
break

vim.command("let l:clang_options = '" + ' '.join(opts) + "'")
Expand Down

0 comments on commit b44dd45

Please sign in to comment.