Reputation: 1141
I have installed the plugin clang_complete. I put these settings in my .vimrc:
let g:clang_use_library = 1
let g:clang_auto_select = 0
let g:clang_complete_auto = 1
let g:clang_complete_copen = 1
let g:clang_complete_macros = 1
let g:clang_complete_patters = 1
set completeopt=menu,longest
let g:clang_library_path = '/usr/lib/clang'
"let g:clang_library_path = '/usr/lib/llvm-2.9'
let g:clang_auto_user_options = "-I/usr/include/c++/4.6, .clang_complete"
let g:clang_snippets = 1
let g:clang_snippets_engine = 'clang_complete'
Every time when I open the .cpp file I have got the following error message:
Error detected while processing function <SNR>15_ClangCompleteInit..LoadUserOptions:
line 20:
E121: Undefined variable: getopts#
Loading libclang failed, falling back to clang executable. Are you sure '/usr/bin/clang' contains libclang?
vim is compiled with the python feature. So vim --version is gets:
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Feb 28 2012 13:50:08)
Included patches: 1-154
... +python -python3 ...
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_ATHENA -Wall -g -O2 -D_FORTIFY_SOURCE=1 -I/usr/include/tcl8.5 -D_REENTRANT=1 -D_THREAD_SAFE=1 -D_LARGEFILE64_SOURCE=1
Linking: gcc -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-Bsymbolic-functions -Wl,--as-needed -o vim -lXaw -lXmu -lXext -lXt -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -ldl -lm -ltinfo -lnsl -lselinux -lacl -lattr -lgpm -ldl -L/usr/lib -llua5.1 -Wl,-E -fstack-protector -L/usr/local/lib -L/usr/lib/perl/5.12/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python2.7/config -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions -L/usr/lib -ltcl8.5 -ldl -lpthread -lieee -lm -lruby1.8 -lpthread -lrt -ldl -lcrypt -lm
Can anybody help to resolve the problem?
Upvotes: 4
Views: 4956
Reputation: 5050
You have two problems here.
The value you give for g:clang_auto_user_options
is invalid. The "path" that the clang_complete documentation mentions doesn't mean that a path should be written in the option string; it refers to using Vim's built-in 'path'
option to provide the list of -I
flags.
Use set g:clang_user_options = "-I/usr/include/c++/4.6"
instead, which just gets passed straight through to clang.
Aside: The getopts#
in the error occurs because clang_complete tries to interpret your -I...
string as a part of the name of an options-source function. (The {anything}
clause in the docs.) The -
in getopts#-I/usr/include/c++/4.6#getops()
isn't a valid Vimscript function character so it gets truncated there.
clang_complete expects the g:clang_library_path
directory you specify to contain the libclang.dylib
or libclang.so
directly inside of it (e.g. /usr/lib/clang/libclang.so
in your case).
Not all distributions of clang provide the libclang shared library, so you might need to compile it yourself.
Upvotes: 2