Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reduce the time of clang_complete search through boost

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/\\)\\@!

like image 882
kirill_igum Avatar asked May 10 '12 20:05

kirill_igum


1 Answers

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.

like image 115
adaszko Avatar answered Oct 27 '22 08:10

adaszko