sponsor Vim development Vim logo Vim Book Ad

TagManager : Project aware incremental tags manager

 script karma  Rating 0/0, Downloaded by 1839  Comments, bugs, improvements  Vim wiki

created by
Alexey Radkov
 
script type
utility
 
description
Beware: this is a wrapping script over plugin TagHighlight. Hopefully its functionality will eventually appear in TagHighlight.

This plugin is capable of managing both tag jumps and highlights databases simultaneously for different projects. It consists of two standalone applications BuildTags and MakeVimHlTags and this file. To manage tag highlights it uses excellent plugin TagHighlight (http://www.vim.org/scripts/script.php?script_id=2646) as backend. The plugin also needs exuberant ctags and (optionally) cscope packages.

TagManager can manage both jumps and highlights tags incrementally, it means that projects may depend on other projects and user can setup his projects in such a way that he would need to update only small pieces of tags databases related to changes he would have made for a small project: all not changed dependencies would not be rebuilt and would be attached to the small projects as is. For example user can manage a small project my_proj which depends on large 3rd-party libraries libLarge1 and libLarge2 that he would definitely never change (we denote this sort of dependency as my_proj:libLarge1,libLarge2), then when he decide to update the tags of the project my_proj, tags from libLarge1 and libLarge2 will be attached to those from my_proj not having been rebuilt.

The plugin provides 3 commands:

    UpdateProjectJumps
    UpdateProjectHighlights
    UpdateProjectTags

Normally you will need only UpdateProjectTags which is a simple sequence of the first two. Issuing :UpdateProjectTags will update both jumps and highlights tags in the project you are currently in.

To use the plugin efficiently add following lines in your .vimrc:

    if !exists('g:TagHighlightSettings')
        let g:TagHighlightSettings = {}
    endif
    let g:TagHighlightSettings['LanguageDetectionMethods'] =
                                            \ ['Extension', 'FileType']
    let g:TagHighlightSettings['FileTypeLanguageOverrides'] =
                                            \ {'svn': 'c', 'tagbar': 'c'}
    let g:loaded_TagHighlight = 2

Setting variable g:TagHighlightSettings['FileTypeLanguageOverrides'] will let you enjoy tag highlights in tagbar window and when committed svn changes. Line 'let g:loaded_TagHighlight = 2' will prevent loading of TagHighlight before TagManager thus letting the latter to manage initialization of the former itself. This is important because TagManager depends on TagHighlight plugin and autocommands from TagManager must go before corresponding autocommands from TagHighlight. Value 2 will make TagManager aware that variable g:loaded_TagHighlight was only initialized in .vimrc and TagHighlight is really not loaded yet.

You also may want to put scripts BuildTags and MakeVimHlTags in some directory listed in your $PATH environment variable (by default this plugin expects to find them in $HOME/bin/), and create new environment variable $TAGSDIR where all plugin data will be saved. Now you can additionally use BuildTags and MakeVimHlTags as standalone scripts and create tags for vim directly from command line. To see available command-line options run the scripts with option --help.

By default plugin reads configuration file $HOME/.vim-TagManager.conf where a user defines settings for building and updating tags for his projects. Each line in the configuration file corresponds to one project and consists of 5 columns, separated with double semicolon (possibly surrounded by spaces or tabs). The first column is a directory match pattern used to define where the project resides, second column - name of the project with optionally appended (after colon) comma-separated list of other projects upon which this project depends, third column - language for building tag highlights (for example 'c' or 'python'), if user do not want to specify any language (i.e. highlights tags will be built for any languages that TagHighlight supports) then he can put in this column special placeholder - exclamation sign (!) which denotes empty value, fourth column - root directory for building jumps and highlights tags, fifth column - options for MakeVimHlTags, to see them run

    MakeVimHlTags --help

in command line. Please make sure that you understand the difference between values in column 1 and column 4: the former will be used in autocommands for finding out if specific directory matches project directory pattern and thus may contain glob symbols like '*' or '?', whereas the latter denotes the root directory for building tags. Values in any column may refer to environment variables: they will be expanded. An example of configuration file is shipped with this distribution.
 
install details
Prerequisites: sh, perl, ctags, cscope (optionally), vim script TagHighlight (http://www.vim.org/scripts/script.php?script_id=2646)

1. Extract the tarball in your $HOME/.vim directory
2. Copy or move scripts BuildTags and MakeVimHlTags from directory TagManager/ in some directory referred in the $PATH. By default TagManager expects to find them in $HOME/bin/, but if you prefer another path then assign corresponding values (path + script name) to variables g:TagMgrTagsBuilder and g:TagMgrHighlightsBuilder in your .vimrc
3. Define directory where TagManager will store tags databases. This is made by assigning either vim global variable g:TagMgrTagsdir in .vimrc or (preferred) environment variable $TAGSDIR
4. If you prefer highlights in the tagbar (http://www.vim.org/scripts/script.php?script_id=3465) or when you edit messages for subversion commits then add following lines in your .vimrc:

   if !exists('g:TagHighlightSettings')
       let g:TagHighlightSettings = {}
   endif
   let g:TagHighlightSettings['LanguageDetectionMethods'] =
                                           \ ['Extension', 'FileType']
   let g:TagHighlightSettings['FileTypeLanguageOverrides'] =
                                           \ {'svn': 'c', 'tagbar': 'c'}
   let g:loaded_TagHighlight = 2

5. Create configuration file for your projects (default path is $HOME/.vim-TagManager.conf but it can be changed via variable g:TagMgrDataFile). An example is given in file TagManager/vim-TagManager.conf.sample)
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
TagManager-0.2.tgz 0.2 2013-06-04 7.0 Alexey Radkov runtime TagManager in .vimrc is not needed any more; minor internal improvements
TagManager-0.1.tgz 0.1 2012-10-03 7.0 Alexey Radkov Initial upload
ip used for rating: 18.97.9.175

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github