4

In the clang_complete.txt(the help file), it shows these in clang_complete-compl_kinds:

2.Completion kinds                  *clang_complete-compl_kinds*
Because libclang provides a lot of information about completion, there are
some additional kinds of completion along with standard ones (see >
 :help complete-items for details):

'+' - constructor
'~' - destructor
'e' - enumerator constant
'a' - parameter ('a' from "argument") of a function, method or template
'u' - unknown or buildin type (int, float, ...)
'n' - namespace or its alias
'p' - template ('p' from "pattern")

the question are:
1. i cannot access the complete-items(no this file)
2. can someone tell me how to use the parameter '+' 'a' and so on.
3. or can you tell me how to show function parameters when ( is typed.

thanks!
(forgive my poor english)

Peeter Joot
  • 7,848
  • 7
  • 48
  • 82

1 Answers1

1

It's been a long time, but i'll answer to help future visitors.

I don't fully understand your questions, but I'll answer the 3rd one. Clang complete only launches automatic suggestion/completion when writing '.', '->' or '::', but you can launch it manually.

I use it this way. In this source:

#include <iostream>
using namespace std;

void ExampleFunc (float foo, int &bar)
{
    cout << foo;
    bar++;
}

int main (int argc, char **argv)
{
    int a(0);
    Exa[cursor here]

    return 0;
}

Writing "Exa" you can press <C-X><C-U> and you will get a preview window with:

Example (float foo, int &bar)

and a completion window (the same that appears when you press <C-N> (CTRL-N) in insert mode) with:

Example f void Example(float foo, int &bar)

If there are several matches, you can move down or up with <C-N> or <C-P> and complete with <CR> (enter).

The completion is not perfect, but it should work for many other cases, for example (as you mentioned) templates:

#include <vector>
using namespace std;

int main (int argc, char **argv)
{
    struct MyType {int asdf; float qwer;};
    vector<MyType> vec;
    ve  // suggestions after <C-X><C-U>: 
        //     "vec v vector<MyType> vec" v is for variable
        //     "vector p vector<Typename _Tp>" p is for pattern (template)
        //     constructors with its parameters, etc.

    vec.    // auto-fired suggestions: all std::vector methods
    vec[0]. // auto-fired suggestions: "asdf", "qwer" and MyType methods

    return 0;
}

If those examples don't work for you, you haven't installed the plugin properly.

By the way, you can map <C-X><C-U> to other shortcut.

jmmut
  • 884
  • 9
  • 19