【问题标题】:How to reduce the time of clang_complete search through boost如何通过boost减少clang_complete搜索的时间
【发布时间】:2012-05-19 11:06:44
【问题描述】:

我喜欢在 vim 中使用 clang。

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

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

更新 (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 进行搜索。 超级用户有一个 answer 可以使用 set include=^\\s*#\\s*include\ \\(&lt;boost/\\)\\@! 注释掉通过 boost 目录进行的搜索

【问题讨论】:

  • Vim 的变量 g:clang_use_library 的值是多少?
  • @adaszko :let g:clang_use_library 返回g:clang_use_library #0

标签: vim boost clang code-completion clang-complete


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    来自here,您可以将以下内容添加到您的.vimrc

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

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

    【讨论】:

      【解决方案3】:

      所以,您至少有两个选择。选项#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,您可以通过它禁用 在-&gt;.:: 之后自动完成,并且可以改用&lt;C-x&gt; &lt;C-o&gt; 随时手动调用 clang_complete。

      我两个都用。

      【讨论】:

      • 也许这会在未来的版本中得到改进。
      • 在我看来像是 StackOverflow 上一个单独问题的材料 :-)
      猜你喜欢
      • 1970-01-01
      • 2021-06-09
      • 2021-11-28
      • 1970-01-01
      • 2017-02-15
      • 2016-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多