Ok, using the old saying "Use the force, read the source" I browsed ccomplete.vim a little. If I knew Vim scripting a little, I'd do the following:

After line 406:
 if we're dealing with C++ file:
   if item['kind'] is 'c', 'u' or 's':
      kind2name = {'c': 'class', 'u': 'union', 's': 'struct'}
      call StructMembers for kind2name[item['kind']] . ':' . tokens[tidx]

That should do the trick. What do you think?

Bram Moolenaar wrote:
Kyku wrote:

Maybe it's not about implementing half of a compiler, but only the features that are used most often. What's more, if one has:

struct foo { /* ... */ };
typedef struct foo foo;

int main() {
  foo myfoo;
  /* ... */
}

then omnicompletion works for myfoo, even if it doesn't see "struct" before foo.

This is correct C, and Vim knows about typedefs, thus it works.
You are using confusing names here.  If you have:

struct foo { /* ... */ };
typedef struct foo foo_t;

int main() {
  foo myfoo;
  /* ... */
}

The it wouldn't work, because it's not valid C.


Reply via email to