Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'patch-1' of git://github.com/gokcehan/clang_complete in…

…to issue264
  • Loading branch information...
commit 9b11ee6dde2533c02ae776926021f0549f1b7dfd 2 parents 76975ae + 9cd7b20
Xavier Deguillard authored
5 doc/clang_complete.txt
View
@@ -182,7 +182,10 @@ Set sources for user options passed to clang. Available sources are:
output this information. clang_complete will search upwards from where vi
was started for a database named 'compile_commands.json'.
Note : compilation databases can only be used when 'g:clang_use_library'
- equals 1 and the clang libraries are recent enough (clang>=3.2).
+ equals 1 and the clang libraries are recent enough (clang>=3.2). The
+ compilation database only contains information for the C/C++ sources files,
+ so when editing a header, clang_complete will reuse the compilation
+ arguments from the last file found in the database.
- {anything} else will be treaded as a custom option source in the following
manner: clang_complete will try to load the autoload-function named
getopts#{anything}#getopts, which then will be able to modify
2  plugin/clang_complete.vim
View
@@ -271,7 +271,7 @@ function! s:initClangCompletePython(user_requested)
python import sys
exe 'python sys.path = ["' . s:plugin_path . '"] + sys.path'
- exe 'pyfile ' . s:plugin_path . '/libclang.py'
+ exe 'pyfile ' . fnameescape(s:plugin_path) . '/libclang.py'
py vim.command('let l:res = ' + str(initClangComplete(vim.eval('g:clang_complete_lib_flags'), vim.eval('g:clang_compilation_database'), vim.eval('g:clang_library_path'), vim.eval('a:user_requested'))))
if l:res == 0
return 0
13 plugin/libclang.py
View
@@ -263,13 +263,15 @@ def getCurrentQuickFixList():
#
# 'cwd' : the compiler working directory
#
+# The last found args and cwd are remembered and reused whenever a file is
+# not found in the compilation database. For example, this is the case for
+# all headers. This achieve very good results in practice.
def getCompilationDBParams(fileName):
- args = []
- cwd = None
if compilation_database:
cmds = compilation_database.getCompileCommands(fileName)
if cmds != None:
cwd = cmds[0].directory
+ args = []
skip_next = 1 # Skip compiler invocation
for arg in cmds[0].arguments:
if skip_next:
@@ -282,8 +284,11 @@ def getCompilationDBParams(fileName):
if arg == '-o':
skip_next = 1;
continue
- args += [arg]
- return { 'args': args, 'cwd': cwd }
+ args.append(arg)
+ getCompilationDBParams.last_query = { 'args': args, 'cwd': cwd }
+ return getCompilationDBParams.last_query
+
+getCompilationDBParams.last_query = { 'args': [], 'cwd': None }
# A context manager to handle directory changes safely
from contextlib import contextmanager
Please sign in to comment.
Something went wrong with that request. Please try again.