7

I like using clang with vim.

The one problem that I always have is that whenever I include boost, clang goes through boost library every time I put "." after a an object name. It takes 5-10 seconds.

Since I don't make changes to boost headers, is there a way to cache the search through boost? If not, is there a way to remove boost from the auto-completion search?

update (1) in response to answer by adaszko after :let g:clang_use_library = 1

  1. I type a name of a variable.
  2. I press ^N. Vim starts to search through boost tree. it auto-completes the variable.
  3. i press "." and get the following errors:
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

... and there is no auto-compeltion

update (2) not sure if clang_complete should take care of the issue with boost. vim without plugins does search through boost. superuser has an answer to comment out search through boost dirs with set include=^\\s*#\\s*include\ \\(<boost/\\)\\@!

Community
  • 1
  • 1
kirill_igum
  • 3,953
  • 5
  • 47
  • 73

3 Answers3

4

So, you have at least two options. Option #1 is to set g:clang_use_library to 1. Here's what :help g:clang_use_library says about it:

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.

This requires working setup of Python Vim integration though.

Option #2 is to set g:clang_complete_auto to 0 by which you disable automatic completion after ->, ., :: and may use <C-x> <C-o> instead to manually invoke clang_complete whenever you wish.

I use both.

adaszko
  • 188
  • 5
0

from here, you can add the following to your .vimrc:

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

(the question of caching the search through boost is still open though)

Community
  • 1
  • 1
kirill_igum
  • 3,953
  • 5
  • 47
  • 73
0

I've done a lot of performance enhancements to clang_complete, you can check about this at issue #187. Big part of the problem was just weak script performance due to non optimized code.

oblitum
  • 11,380
  • 6
  • 54
  • 120