还是决定用ctags写一个全能补全插件, 速度还是不错的, 缺点当然当然是不够准确
不过, 只要准确度能接受也就行了
============================================================
对vim的基本要求, 最好是7.3, 因为 我的是7.3, 7.2我没有测试过, 并且要有 +python 特性
代码: 全选
set nocp
filetype plugin on
代码: 全选
sudo apt-get install python
安装方法, 下载 VLOmniCpp.vba.tar.bz2, 解压后, 用 vim 打开 VLOmniCpp.vba, 然后
代码: 全选
:so %
如果你不想用这个 ctags, 就需要
代码: 全选
ln -s /usr/bin/ctags ~/bin/vlctags
============================================================
基本配置, 暂时只实现以下配置
代码: 全选
" Set MayComplete to '.'
" 0 = disabled
" 1 = enabled
" default = 1
if !exists('g:VLOmniCpp_MayCompleteDot')
let g:VLOmniCpp_MayCompleteDot = 1
endif
" Set MayComplete to '->'
" 0 = disabled
" 1 = enabled
" default = 1
if !exists('g:VLOmniCpp_MayCompleteArrow')
let g:VLOmniCpp_MayCompleteArrow = 1
endif
" Set MayComplete to '::'
" 0 = disabled
" 1 = enabled
" default = 2
if !exists('g:VLOmniCpp_MayCompleteColon')
let g:VLOmniCpp_MayCompleteColon = 1
endif
" When completeopt does not contain longest option, this setting
" controls the behaviour of the popup menu selection
" when starting the completion
" 0 = don't select first item
" 1 = select first item (inserting it to the text)
" 2 = select first item (without inserting it to the text)
" default = 2
if !exists('g:VLOmniCpp_ItemSelectionMode')
let g:VLOmniCpp_ItemSelectionMode = 2
endif
endfunc
代码: 全选
class Base {
int a;
void Func(void)
{
}
};
class Derive : Base {
public:
int b;
protected:
int c;
Base & Func(void);
};
int main(int argc, char *argv[])
{
Derive d;
d.Func();
return 0;
}
代码: 全选
:VTMParseFiles t.cpp
数据库文件由这个选项配置, 默认值如下
代码: 全选
let g:VimTagsManager_DbFile = 'VimLiteTags.db'
注意: 默认情况下, 打开vim, 当前目录都是 ~/ , 如果你想打开vim时在其他目录, 自己写脚本或者到终端切换目录后再打开 vim
============================================================
问题:
1. 暂不支持 using 语句
其他问题, 欢迎汇报.
============================================================
Changelog:
20110535: 1.支持深层次的类模版继承, 算是基本完成了类模版的补全
可如下测试, codelite没有通过 4,5 的测试, codeblocks 也一样
代码: 全选
class A {
public:
int a;
};
class AA {
public:
int aa;
};
template<typename T>
class A2 {
public:
int a2;
T ta2;
};
template<typename T>
class B {
public:
int b;
T tb;
};
template<typename T1, typename T2>
class B2 : public A2<T2> {
public:
int b2;
T1 tb21;
T2 tb22;
};
template<typename T>
class C : public B<T>, public B2<T, A> {
public:
int c;
T tc;
};
int main(int argc, char *argv[])
{
C<AA> c;
c.tc; // test1
c.tb; // test2
c.ta2; // test3
c.tb21; // test4
c.tb22; // test5
c.tb; // test6
c.b; // test7 -> failed
return 0;
}
模版支持测试如下, 记得先生成 tags 数据库, 然后在有 test 字样的前面的 ; 号前按 .
欢迎贡献更完善的测试代码
代码: 全选
class A1 {
public:
int a1;
};
class A2 {
public:
int a2;
};
template<typename T>
class B1 {
public:
int b1;
T t;
T * Get1() { return new T; }
};
template<typename T1, typename T2>
class B2 {
public:
int b2;
A1 a1;
T1 t1;
T2 t2;
T2 * Get2() { return new T2; }
};
template<typename T>
class C : public B1<A1>, public B2<A1, T> {
public:
T c;
B1<A1> b1a1;
void Func()
{
this->t; // test1 -> a1
this->t1; // test2 -> a1
this->t2; // test3 -> failed
}
};
int main(int argc, char *argv[])
{
B2<A1, A2> b2;
b2.t2; // test4
b2.Get2(); // test5
C<A2> c1;
c1.c; // test6
c1.t; // test7
c1.Get2(); // test8
c1.b1a1.t; // test9
return 0;
}