我一直在努力寻找解决问题的方法,但没有运气,所以这是我的问题。
我们的 C++ 类在多个命名空间中定义。因此,通常,类成员具有属于其他命名空间的类型。对于这些情况,vim 的omnicompletion 功能不起作用。STL 成员和局部变量可以毫无问题地与omnicompletion 一起使用。问题似乎在于成员的变量类型具有命名空间范围标识符时,无论它是自己的命名空间还是其他命名空间。: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
提前致谢