7

我喜欢在 vim 中使用 clang。

我一直遇到的一个问题是,每当我包含 boost 时,每次我输入 "." 时,clang 都会通过 boost 库。在对象名称之后。需要 5-10 秒。

由于我没有对提升标头进行更改,有没有办法通过提升缓存搜索?如果没有,有没有办法从自动完成搜索中删除提升?

更新 (1)以响应 adaszko 在 :let g:clang_use_library = 1 之后的回答

  1. 我键入一个变量的名称。
  2. 我按^N。Vim 开始搜索 boost 树。它自动完成变量。
  3. 我按“。” 并得到以下错误:
Error detected while processing function ClangComplete:
line   35:
Traceback (most recent call last):
Press ENTER or type command to continue
Error detected while processing function ClangComplete:
line   35:
  File "<string>", line 1, in <module>
Press ENTER or type command to continue
Error detected while processing function ClangComplete:
line   35:
NameError: name 'vim' is not defined
Press ENTER or type command to continue
Error detected while processing function ClangComplete:
line   40:
E121: Undefined variable: l:res
Press ENTER or type command to continue
Error detected while processing function ClangComplete:
line   40:
E15: Invalid expression: l:res
Press ENTER or type command to continue
Error detected while processing function ClangComplete:
line   58:
E121: Undefined variable: l:res
Press ENTER or type command to continue
Error detected while processing function ClangComplete:
line   58:
E15: Invalid expression: l:res
Press ENTER or type command to continue

...并且没有自动强制

更新 (2) 不确定 clang_complete 是否应该解决 boost 的问题。没有插件的 vim 会通过 boost 进行搜索。超级用户有一个答案可以通过 boost dirs 注释掉搜索set include=^\\s*#\\s*include\ \\(<boost/\\)\\@!

4

3 回答 3

4

所以,你至少有两个选择。选项 #1 设置g:clang_use_library1. 这是:help g:clang_use_library关于它的内容:

Instead of calling the clang/clang++ tool use libclang directly. This
gives access to many more clang features. Furthermore it automatically
caches all includes in memory. Updates after changes in the same file will
therefore be a lot faster.

这需要 Python Vim 集成的工作设置。

选项 #2 设置g:clang_complete_auto为在 , ,0之后禁用自动完成->,并且可以随时使用手动调用 clang_complete 来代替。.::<C-x> <C-o>

我两个都用。

于 2012-05-11T07:08:06.967 回答
0

这里,您可以将以下内容添加到您的.vimrc

:set include=^\\s*#\\s*include\ \\(<boost/\\)\\@!

(不过,通过 boost 缓存搜索的问题仍然悬而未决)

于 2012-05-11T18:43:43.570 回答
0

我对 clang_complete 做了很多性能增强,你可以在 issue #187中查看。问题的很大一部分是由于未优化的代码而导致的脚本性能较弱。

于 2012-08-30T21:37:25.147 回答