Table of Contents
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:
- As an add-on for project plugin.
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
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:
- Vimprj plugin;
- A simple Vim library plugin Vim-DFUtil;
- ctags. If you use Linux, your distribution is likely to have it in repositories.
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
If you use Project, but you have different projects file, you should set option
g:indexer_projectsSettingsFilename in your
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
Syntax of this file is simple, the best way to explain it is probably to show an example:
[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
AnotherProject is configured in a bit more complicated way: it specifies additional parameter for ctags:
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:
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:
[PROJECTS_PARENT] option:ctags_params="--languages=c++,c,python,java" ~/workspace
The keyword is
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.
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
- you open
file1from project1. Indexer generates tags for all files from project1 and set
- you open
file2from the same project1. Indexer just notes that
file2is file from project1.
- you open
file3from project2. Indexer generates tags for all files from project2 and sets
- you switch to buffer with
file1. Indexer does not generate any tags, it just changes
- you switch to buffer with
file3. Indexer changes &tags back to
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
&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
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.
servername is empty, then Indexer will work anyway, but you need to wait while ctags works. This is not really noticeable at small projects.
It is successfully tested on Vim 7.3, on the following systems:
- Ubuntu 10.4, 12.04
- Windows XP
- Mac OS X Lion
For further information, such as options and so on, refer to
I do not have an indexer.
The tag file <project_tmp> is only generated.
The <project> tag file does not appear.
My OS - CentOS 7.
What to do?
The problem with the indexer is solved. Let g: indexer_backgroundDisabled = 1
Well, I wouldn't consider that as a “solution”, because you have to wait every time while tags are generated. On very small projects it can be a-ok, on bigger ones it becomes noticeable, and background tags generation is very helpful.
I'm afraid I get the same problem as Slava does, only <project>_tmp generated. Here is debug snapshot.
Useful plug-in, but unfortunately it does not work on my Fedora 30 workstation. The problem is that the standard
vimexecutable is not compiled with
+clientserver, so the
–servernameoption is not recognized. Instead, one needs to use
gvim -vto get that feature, but it seems you have hard-coded the name
vimfor the executable into your plugin. Adding
let sVimExecutable = 'vimx'in line 649 of file
plugin/indexer.vimsolves the issue for me. Would it be possible to add a fix for this issue? Thanks in advance!