clang_pro.vim : auto complete c/c++/java ,using global make a proj to find define and reference
script karma |
Rating 21/13,
Downloaded by 6981 |
Comments, bugs, improvements
|
Vim wiki
|
created by |
yong xie |
|
script type |
utility |
|
description |
This plugin use clang and javacomplete to auto complete c/c++/java codes ,and use gnu global(work better than cscope for c++ and can work for java and php) make a project to find define and callers.
All of the codes in one file . So it is small but powerful.Everyone know vim script can read this plugin and change it for yourself. That is vim's power ,do it yourself. I use it work well for ubuntu and old winxp machine, it may work well on macos X too.
Any one fix bug or use it on mac os give me a email at xieyong88881@163.com ,i will happy.
For get the all utilities of the plugin,make install clang(apt-get install clang) and gnu global(from src ./configure make install). on Windows you must find clang.exe/global.exe for your environment.
Make a file name is clang_pro at the root of your c/c++/java project.(all source file in it's dir or child dir)
As default key bindings,when you open a source file(.h .c .cpp .cc .cxx .java)
push ',' and 'd' keys on the word for define.
push ',' and 'r' for references.
push ',' and 'h' for h/c,cpp switch.
push ',' and 's' for save sessions.
push ',' and 'l' for load sessions.
push ',' and 'e' for error info.(use clang compile for one file find err)
push ',' and 'm' for will build the project using makeprg.(c/c++ for makefile ,java for ant)
When add . :: -> complete menu will pop up for you. You can also use key ctrl-x-o make the complete menu pop up manully.
For new version,add a smart tab complete,can work as ctrl-x-o,select for complete menu,and finish a smart code template for c/c++/java ,you can close it by using let g:clang_auto_tab=0
try code template,such as write 'mai' and press tab,you can change place with tab again.
clang_pro file will work well for keys ,d ,r ,h ,s ,l functions with nothing in it,but for c/c++/java auto complete,it may need compile info lines in clang_pro file, like:
"for c/cpp project,notice for cpp need add stdlib path
set makeprg=cd\ ~/pro;make
let g:clang_options = ' -std=c++11 -I /usr/include/c++/4.8/ -I /usr/include/x86_64-linux-gnu/c++/4.8/ -I ~/test/cpp/include'
"for windows env
"let g:clang_options = ' -std=c++11 -fms-extensions -fms-compatibility -I "C:\Program Files\Microsoft Visual Studio 10.0\VC\include" '
"or for java project
"set makeprg=ant\ -find
"set efm=%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%#
"let g:java_classpath='.:/skyics/ics/out/host/common/obj/JAVA_LIBRARIES/layoutlib_intermediates/classes'
With right settings in clang_pro file for your project. the ",m" ",e"key binding.and auto complete when meeting . -> :: will work well.
This plugin only use clang not libclang.so,it give method to use project file auto make a pch file for speed, most of time it quick enough (first time a little delay,but follow times is quick).
If it is slow for your project, you can write line in your .vimrc or in clang_pro file at root of your project .
let g:clang_auto = 0 "only when you need ,ctrl-x-o to complete it.
other lines can add:
let g:clang_auto_map=0 "close default keys bindings
let g:clang_exe= 'clang' "you can use other clang name
let g:clang_project = 'clang_pro' "you can change the project file.
To other configure, make them in clang_pro file may better.like:
let g:clang_options = ' -std=c++11 -fms-extensions -fms-compatibility -I "C:\Program Files\Microsoft Visual Studio 10.0\VC\include" ' (notice this is in windows os using a clang version compiled by vc++)
let g:clang_use_pch="#include <vector>\n#include <list>"
When the script start ,it will find the clang_pro file and make it work,so can write any vim settings in it .
If you want a project which can quickly find define and callers .
GNU GLOBAL will make a GTAGS in the root of project, you can use the abilities of it.
You can use let g:clang_options to make clang work right, most of time ,include -I and macro define -D is needed.
And if the c/c++ header file is large for compile,you can use g:clang_use_pch add pch file for clang, use \n to split these headers.
the quickfix windows will not pop at auto complete.
It is better to make the function of getting err info alone,the quickfix windows will not pop at auto complete. |
|
install details |
just put clang_pro.vim in your ~/.vim/plugin
install clang and GNU GLOBAL,(apt-get install clang and for new version in global source from http://gnu.april.org/software/global/ using configure/make install
install javacomplete from http://www.vim.org/scripts/script.php?script_id=1785
make a file named clang_pro at the root of your c/c++/java project. the content can be like
when using a c/cpp pro using autotools for makefile,the sample content can be:
set makeprg=export\ PATH=$PATH:/opt/buildroot-gcc342/bin;cd\ ~/wifidog;make
let g:clang_options = '-I ./include -I ../include'
"notice must use "\" before when there are ' ' in commands
when using a java pro using ant for make,the sample content can be:
set efm=%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%#
set makeprg=ant
let g:java_classpath='.:/skyics/ics/out/host/common/obj/JAVA_LIBRARIES/layoutlib_intermediates/classes'
When the script start ,it will find the clang_pro file and make it work,so can write any vim settings in it .
As default ,GNU GLOBAL will make a GTAGS in the root of project, you can
use the abilility of it which can quickly find define and callers. You can use let g:clang_options to make clang work well, most of time ,include and macro define is needed.
If you do not want a project using gtags,write: let g:clang_use_global = 0.
And if the head file is large,you can use g:clang_use_pch add pch file for clang, use \n to split these headers. for example: let g:clang_use_pch="#include <vector>\n#include <list>" |
|
script versions (upload new version)
Click on the package to download.
clang_pro.vim |
4.2 |
2015-03-10 |
7.0 |
yong xie |
using completeopt=menuone,longest for complete menu |
clang_pro.vim |
4.1.1 |
2015-01-09 |
7.0 |
yong xie |
add some c template code |
clang_pro.vim |
4.1 |
2014-10-10 |
7.0 |
yong xie |
make first complete quick |
clang_pro.vim |
4.0 |
2014-09-20 |
7.0 |
yong xie |
add a smart tab complete,can work as ctrl-x-o,select for complete menu,and finish a smart code template for c/c++/java ,you can close it by using let g:clang_auto_tab=0 |
clang_pro.vim |
3.10 |
2014-09-15 |
7.0 |
yong xie |
make -std=c++11 as default cpp flag,remove complete word which start with '_' |
clang_pro.vim |
3.9 |
2014-09-05 |
7.0 |
yong xie |
add code from gtags.vim,so not need gtags.vim anymore. |
clang_pro.vim |
3.8.1 |
2014-08-31 |
7.0 |
yong xie |
add ',e' work for java |
clang_pro.vim |
3.8 |
2014-08-28 |
7.0 |
yong xie |
add key binding ",e" for error info,now only work for cpp |
clang_pro.vim |
3.7 |
2014-08-19 |
7.0 |
yong xie |
fix c++ head/source file switch can't use .cc file bug. |
clang_pro.vim |
3.6 |
2014-08-15 |
7.0 |
yong xie |
remove '#' make clang complete more clear |
clang_pro.vim |
3.5 |
2014-07-09 |
7.0 |
yong xie |
only bug fix |
clang_pro.vim |
3.4 |
2014-06-13 |
7.0 |
yong xie |
add default key ,m for :make<CR> |
clang_pro.vim |
3.3 |
2014-06-06 |
7.0 |
yong xie |
add default keys
,s for saveSession.
,l for loadSession when in clang_pro subdir |
clang_pro.vim |
3.2 |
2014-06-03 |
7.0 |
yong xie |
add default key map
nmap ,d for find define
nmap ,r for find reference
nmap ,h for switch h/c,cpp
|
clang_pro.vim |
3.1 |
2014-05-29 |
7.0 |
yong xie |
add cscope compatible,can use command :cs find ...., add command :HCppSwitch for goto h file and c/cpp file |
clang_pro.vim |
3.0 |
2014-05-27 |
7.0 |
yong xie |
add auto java complete |
clang_pro.vim |
2.1 |
2014-05-26 |
7.0 |
yong xie |
make start vim when using clang_pro build gtags pro quickly. |
clang_pro.vim |
2.0.1 |
2014-05-22 |
7.0 |
yong xie |
when has clang_pro file,make let g:clang_use_global = 1 as default,you can put line:
let g:clang_use_global = 0
in your clang_pro file to close gnu global auto create gtags file for your project. |
clang_pro.vim |
2.0 |
2014-05-04 |
7.0 |
yong xie |
add function for session. When has clang_pro file, you can use :ClangSetSesion and :clangGetSession command save and load session at any c/c++ file in project. |
clang_pro.vim |
1.2 |
2014-04-25 |
7.0 |
yong xie |
fix bug for when no clang_pro file complete work err. |
clang_pro.vim |
1.1 |
2014-04-23 |
7.0 |
yong xie |
some bug fix, make -I relative path can work and windows make gtags project err fixed. |
clang_pro.vim |
1.0 |
2014-04-21 |
7.0 |
yong xie |
Initial upload |
ip used for rating: 3.142.242.51
|