Table of Contents

Vim-Indexer

Indexer is a Vim plugin that provides painless transparent tags generation and keeps tags up-to date. Tags are generated in background, so you don't have to wait while your tags are being generated.

Consider reading the article Vim: convenient code navigation for your projects, which explains the topic on Indexer + Vimprj usage very thoroughly.

Indexer can work in two ways:

In either way, it provides painless automatic tags generation for whole project(s) and keeps tags up-to-date.

This plugin can be even more useful when it's used together with plugins omnicppcomplete (for c, c++ development), code_complete.vim and other plugins that use tags. And of course you also will be able to jump from function call to its definition just by pressing Ctrl-] or g].

Installation

The project is hosted at bitbucket. Stable versions are at vim.org. Download source code from there and install it as any other Vim plugin.

There are a couple of dependencies:

Configuration

As I mentioned above, Indexer can work as add-on for Project plugin. Indexer reads project file, parses it and builds tags for all files in project. But it also works fine without Project plugin.

Actually, if you use Project plugin and you use default projects file (~/.vimprojects), then setting Indexer up is very easy: you can just install this plugin, start Vim and open any file from your project. Indexer will detect that opened file is a file from project and automatically generate tags for the whole project. It also set &path and &tags.

If you use Project, but you have different projects file, you should set option g:indexer_projectsSettingsFilename in your vimrc.

If you don't use Project, then you can use .indexer_files file to specify projects and files to index. Default location of this file is ~/.indexer_files. You can change it by modifying variable g:indexer_indexerListFilename.

Syntax of this file is simple, the best way to explain it is probably to show an example:

~/.indexer_files
[CoolProject]

/home/user/cool_project

[AnotherProject]
option:ctags_params = "--languages=c++"

/home/user/another_project/src
/home/user/another_project/lib

I believe the syntax should be obvious: there are two projects, CoolProject and AnotherProject. CoolProject just contains ALL files from /home/user/myproject. AnotherProject is configured in a bit more complicated way: it specifies additional parameter for ctags: –languages=c++. It is needed to make ctags ignore all files except c++ sources. I would recommend you to read and understand ctags help, to be able to write perfect configuration for your projects. You can read it here: http://ctags.sourceforge.net/ctags.html.

The options you need to know first are the following two:

    --languages=[+|-]<list>
    --langmap=<map>[,<map[...]>]

If you have many projects and you are lazy to put every project in this file (like I am), you can put in your ~/.indexer_files something like this:

~/.indexer_files
[PROJECTS_PARENT]
option:ctags_params="--languages=c++,c,python,java"

~/workspace

Workspace directory

The keyword is PROJECTS_PARENT. In this way, each directory in ~/workspace will be interpreted as a separate project: you can open any file from any project in ~/workspace, and the whole project will be indexed.

Please note: suggested ctags options are tested with ctags 5.8. As far as I know, option –languages marked as deprecated in ctags 5.9, but I haven't tested it yet, since the latest version on http://ctags.sourceforge.net is still 5.8. I hope I will have time for this one day.

Multiple projects

Indexer 3.0 and later supports simultaneous work on files from multiple projects. For example, a little story.

Assume we have two projects: “project1” and “project2”, and we use ~/.indexer_files file.

So, you should not care about your projects. It just works. If you have some subprojects, I would recommend to use .vimprj directory with specific settings for your project, in which you can set any options such as &tags, &tabstop, etc. It's up to another plugin actually: Vimprj.

Background tags generation

It works out-of-the-box in Gvim, but not in Vim unfortunately. This is because background tags generation requires your servername to be not empty. (if you don't know what is servername, read :help servername).

If you use Gvim, then servername is GVIM by default. If you use terminal Vim, you need to run vim somehow like that:

$ vim --servername MY_NAME

Of course you can make alias for this command, or do some similar trick.

If servername is empty, then Indexer will work anyway, but you need to wait while ctags works. This is not really noticeable at small projects.

Platforms

It is successfully tested on Vim 7.3, on the following systems:

More

For further information, such as options and so on, refer to :help indexer.