Are you managing your tag files manually? Are you constantly trying to recall the right command line arguments for ctags-exuberant
? Would you like a very light tag manager to solve your problems? Look no further.
Taggatron allows you to set up rules for creating your tag files, based on the language. It separates tag files for different languages (I decided this was the way I wanted to go, as it is neater and easier to maintain), and incorporates the Autotag script by Craig Emery to update tag files incrementally as you edit your files.
You specify rules for your tag files using a dictionary, as so:
let g:tagcommands = {
\ "php" : {"tagfile":".php.tags","args":"-R"},
\ "javascript" : {"tagfile":".js.tags","args":"-R"}
\}
As you can see, each entry has a key which is the language you want to generate tags for (only those supported by exuberant ctags). There are several configuration options for each tag file:
let g:tagcommands = {
\ "php" : {
\ "tagfile" : ".php.tags", " Location of the tag file
\ "args" : "-R", " Arguments to pass to the command (-f and --languages are added automatically)
\ "cmd" : "ctags-exuberant", " Command to execute
\ "filesappend" : "**" " This is appended to the current working directory, and used as the files argument
\ }
\}
Now, when you write a file whose language has a tag file configuration, a tag file will be automatically generated. If it exists, it will be updated. To force re-creation of the tag file, run:
:TagUpdate
Note: this script works well if you want to use multiple configurations, like a project-style set-up. I have a script that does something like that, called vim-sauce.
Create tags for all files matching the language in and below the current directory:
let g:tagcommands = {
\ "php" : {
\ "tagfile" : ".php.tags",
\ "args" : "-R"
\ }
\}
Create tags for all files matching the language in a sub-directory of the current one:
let g:tagcommands = {
\ "php" : {
\ "tagfile" : "sub/directory/php.tags",
\ "args" : "-R",
\ "filesappend" : "sub/directory/**"
\ }
\}
Create tags for all files matching the language using an absolute directory:
let g:tagcommands = {
\ "php" : {
\ "tagfile" : "/path/to/directory/php.tags",
\ "args" : "-R",
\ "files" : "/path/to/directory/**"
\ }
\}
Along with specifying the commands for generating the tag files, you can specify default tag files to use alongside the ones generated by taggatron, e.g. if you have separate tag files for core libraries:
let g:tagdefaults = "/path/to/other/tag.file"
If you're having trouble, put the script into debug mode to see what's going on:
let g:taggatron_verbose = 1
My thanks goes to Craig Emery for his Autotag script, which I've modified slightly to fit with my script.
This is released under the MIT license.