Clang completion plugin for vim
Use of clang to parse and complete C/C++ source files.
clang
installed.plugin/
into ~/.vim/plugin
works.cd ~/.vim/bundle; git clone https://github.com/justmao945/vim-clang.git
.I was a user of clang_complete and it's really a good job, but someday I found that I must write another plugin to overcome some drawbacks of it.
User options can be set for different file types in vim-clang.
let g:clang_c_options = '-std=gnu11'
let g:clang_cpp_options = '-std=c++11 -stdlib=libc++'
vim-clang is faster than clang_complete (not using libclang). vim-clang does not support libclang now, and I don't think it's a good idea to use cindex.py(python binding for clang) directly. If you use clang_complete with libclang and open many C/C++ source files, you'll find that VIM eats up hundreds of MB RAM...
vim-clang is more friendly than clang_complete.
vim-clang supports relative include path in .clang configuration file.
proj/
|-- .clang
|-- include/
|-- main.h
|-- src/
|-- main.c
|-- test/
|-- main_test.c
$ cat .clang
-I.
Better PCH support. vim-clang will find stdafx.h.pch automatically.
YouCompleteMe is more powerful than vim-clang, that has a well designed client-server architecture to deal the memory problem in clang_complete.
Now vim-clang supports to call clang executable asynchronously that it won't block vim during the completion. This is very useful if your project is large and the machine is not very powerful to parse them in tens of milliseconds. In synchronized mode you'll find that's too 'slow' to wait the completion...
This mode is implemented by starting another vim process to notify the finish of the
completion, so +clientserver
option is required to compile the vim(generally added).
GVIM is required to use this mode, seems given --servername ???
to vim
is not working.
Job control is used to run clang when in neovim, which is really very nice! Thank you syswow.
Use cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1
to generate compile_commands.json
To use the compile commands database in vim-clang, set the g:clang_compilation_database
variable in your vimrc to your cmake build path.
let g:clang_compilation_database = './build'
-I
) that are in the .clang files will be passed down to the clang and gcc
makers from Neomake without overriding your configuration.The variables that are affected are:
g:neomake_cpp_clang_maker
g:neomake_cpp_gcc_maker
g:neomake_c_clang_maker
g:neomake_c_gcc_maker
:h clang.txt
Tested on