Is there an alternative to ctags that works better?

Doug picture Doug · Oct 13, 2011 · Viewed 21.1k times · Source

I have just discovered the taglist plugin for vim, and read about how to use it with ctags.

However, disappointingly ctags is a very simple parser.

Is there an alternative that is more complete?

Specifically I'm looking for something that:

  • expands #define(x, y) x ## y style macros for function declarations

  • processes #include statements

  • allows include paths to be specified for dependencies

I see that clang provides a programatic api for accessing the c AST, so surely this isn't terribly hard to do?

Has someone already done it?

--

Edit:

These ones don't cut it:

  • clang_indexer - Doesn't compile; when it does (after hacking), doesn't work (endless errors).

  • clang_complete - Doesn't seem any better than ctags. No context specific recommendations, no struct completion, no function arguments, no macro expansion; just a list of symbols and the file they came from.

Answer

ldog picture ldog · Oct 18, 2011

I've spent quite some time struggling with this myself.

The closest I ever got was something called gccsense. Unfortunately, the project seems abandoned and moreover it was difficult setting it up because English was not the author's first language.

I ended up approaching the problem from another angle. I made the decision that intellisense/autocomplete was more important to my coding than having all the available features of vim, so I chose an IDE like Eclipse, and then found a plugin for Eclipse that emulates Vim. So far the best kind of plugin like that that I found was Viable.

Here is the full list of options that I have tried and found unsatisfactory:

  • clang - requires you switch from gcc to a different and "better" compiler. The problem is gcc is much more mature [edit apparently you don't need to switch compilers see comments below, I may give this another try in the future.]
  • gccsense - great idea (using gcc to give you the code completion) however work on the project is abandoned :( and the version that is up is beta quality
  • xref in vim - xref is a great standalone tool and works great for parsing C. It can be made to work in vim with vxref, however from my experience xref lacks in parsing current C++ code and development on it has stopped (as well as development on vxref.)
  • eclim - seems to work great for Java support using eclipse, extremely slow and completely unreliable when parsing C++ or C code. What usually happens is everything works for a long while, but then suddenly, the parser stops parsing any new code that you write, and nothing short of loading up eclipse itself and forcing eclipse to reparse the project seems to help. Also, less of an important fact, but more of an annoyance is that eclim takes over handling errors, so it screws up the way vim usually parses errors from gcc meaning you have no access to the quickfix list which is annoying.
  • netbeans + jvi - alot of people swear by this, but I had all sorts of problems with jvi. One major problem I had was jvi would say I'm in normal mode, but really was in insert mode, nothing short of a restart would help.
  • eclipse + viplugin/vrapper - this was beginning to look like the best option; each had its own set of bugs + lacking features, but still was most attractive, until I found viable which seemed to be the most stable and have the most features.

If you do find a solution you are happy with please share it in a comment, because I would be interested in it.