Vim + OmniCppComplete:完成作为STL容器的类成员

Rob*_*nes 11 c++ linux vim ctags omnicomplete

作为STL容器的类成员的完成失败.

对作为STL容器的本地对象的完成工作正常.

例如,给定以下文件:

// foo.h
#include <string>

class foo {
public:
    void set_str(const std::string &);

    std::string get_str_reverse( void );

private:
    std::string str;
};

// foo.cpp
#include "foo.h"

using std::string;

string
foo::get_str_reverse ( void )
{
    string temp;

    temp.assign(str);
    reverse(temp.begin(), temp.end());

    return temp;
}       /* -----  end of method foo::get_str  ----- */

void
foo::set_str ( const string &s )
{
    str.assign(s);
}       /* -----  end of method foo::set_str  ----- */
Run Code Online (Sandbox Code Playgroud)

我使用以下方法为这两个文件生成了标签:

ctags -R --c++-kinds=+pl --fields=+iaS --extra=+q .
Run Code Online (Sandbox Code Playgroud)

当我输入temp.cpp时,我会string按预期获得成员函数列表.但是如果我输入str.omn​​icppcomplete spits out"Pattern Not Found".

我注意到temp.只有我有using std::string;声明才能完成.

如何完成作为STL容器的类成员的工作?

编辑

我发现如果我对标题进行以下修改,那么STL容器成员的完成就会起作用:

// foo.h
#include <string>

using std::string;

class foo {
public:
    void set_str(const string &);

    string get_str_reverse( void );

private:
    string str;
};
Run Code Online (Sandbox Code Playgroud)

基本上,如果我添加using std::string;然后std::string str;成员中删除名称空间限定符并重新生成标记文件,则OmniCppComplete能够完成str..

似乎我是否已经let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]设置了.vimrc.

问题是using在头文件中放置声明似乎是一个很大的禁忌,所以我回到原点.

Unc*_*eiv 0

尝试设置这个变量:

let OmniCpp_NamespaceSearch=1
Run Code Online (Sandbox Code Playgroud)

如果它有效,请不要忘记将其放入您的.vimrc配置文件中!