vim 中命名空间感知的omnicomplete
我一直试图找到解决我的麻烦的答案,但没有运气,所以这是我的问题。
我们的 C++ 类是在多个命名空间中定义的。因此,类成员通常具有属于其他命名空间的类型。对于这些情况,vim 的全能补全功能不起作用。 STL 成员和局部变量可以毫无问题地使用全能补全。问题似乎出在成员的变量类型具有命名空间范围标识符时,无论它是它自己的命名空间还是其他命名空间。 :ts tagname
命令始终有效。
小虚拟示例:
namespace T { namespace N2 {
class Lorry
{
public:
Lorry(){}
void printInfo(){
}
private:
int speed;
};
}}
namespace T { namespace N2 {
class Truck
{
public:
Truck();
void printInfo();
private:
Lorry lorry;
N2::Lorry lorry2;
};
}}
namespace T { namespace N2 {
Truck::Truck(){}
void Truck::printInfo(){
lorry.printInfo(); // Omnicompletion works
lorry2. // Omnicompletion does not work. Pattern not found!
}
}}
我使用以下映射生成标签文件:
map <C-F12> :!ctags -R --c++-kinds=+pl --fields=+iaS --extra=+q --language-force=C++ .<CR>
以及 .vimrc 中的一些配置:
let OmniCpp_MayCompleteDot = 1 " autocomplete with .
let OmniCpp_MayCompleteArrow = 1 " autocomplete with ->
let OmniCpp_MayCompleteScope = 1 " autocomplete with ::
let OmniCpp_SelectFirstItem = 2 " select first item (but don't insert)
let OmniCpp_NamespaceSearch = 2 " search namespaces in this and included files
let OmniCpp_ShowPrototypeInAbbr = 1 " show function prototype (i.e. parameters) in popup window
let OmniCpp_LocalSearchDecl = 1 " don't require special style of function opening braces
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
提前致谢
I have been trying to find an answer to my trouble with no luck, so here is my question.
Our C++ classes are defined in several namespaces. So, frequently, class members have a type that belongs to other namespace. For those cases, vim's omnicompletion feature does not work. STL members and local variables can be used with omnicompletion without trouble. The trouble seems be to when the variable type of a member has namespace scope identifier, regardless it is its own namespace or other one. :ts tagname
command works always.
Little dummy example:
namespace T { namespace N2 {
class Lorry
{
public:
Lorry(){}
void printInfo(){
}
private:
int speed;
};
}}
namespace T { namespace N2 {
class Truck
{
public:
Truck();
void printInfo();
private:
Lorry lorry;
N2::Lorry lorry2;
};
}}
namespace T { namespace N2 {
Truck::Truck(){}
void Truck::printInfo(){
lorry.printInfo(); // Omnicompletion works
lorry2. // Omnicompletion does not work. Pattern not found!
}
}}
I generate tags file using the following map:
map <C-F12> :!ctags -R --c++-kinds=+pl --fields=+iaS --extra=+q --language-force=C++ .<CR>
and some configuration from .vimrc:
let OmniCpp_MayCompleteDot = 1 " autocomplete with .
let OmniCpp_MayCompleteArrow = 1 " autocomplete with ->
let OmniCpp_MayCompleteScope = 1 " autocomplete with ::
let OmniCpp_SelectFirstItem = 2 " select first item (but don't insert)
let OmniCpp_NamespaceSearch = 2 " search namespaces in this and included files
let OmniCpp_ShowPrototypeInAbbr = 1 " show function prototype (i.e. parameters) in popup window
let OmniCpp_LocalSearchDecl = 1 " don't require special style of function opening braces
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论