Ⅰ. 插件描述
Generate ctags into central location for git super-projects and submodules, vim 'setlocal' helper combined with .git/hooks.Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'rafi/vim-tagabana'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'rafi/vim-tagabana'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'rafi/vim-tagabana'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/rafi/vim-tagabana
Ⅳ. 文档说明
# tagabana.vim
Generate ctags into central location for git super-projects and submodules, vim 'setlocal' helper combined with .git/hooks.
Features
- Tiny. ~30LoC
- [ctags generator] as automatic [custom git hooks]
- Vim helper to set
tagswith project's central tag file - Fast! Caches the project-path per tab
- Easy to hack and change
Installation
First, copy the [custom git hooks] to your template at .git_template/hooks:
mkdir -p ~/.git_template/hooks
cp contrib/hooks/* ~/.git_template/hooks
And set your .gitconfig (or .config/git/config) globally:
git config --global init.templatedir '~/.git_template'
Note: Git >=1.7.12 is in line with XDG, e.g. .config/git/template.
Then install this vim plugin using your favorite plugin manager, or copytagabana.vim to your .vim/plugin/ directory and start hacking.
Usage
Git+ctags Work-flow
When you git init, your template hooks will be copied into the new repository.
You can manually copy them into an existing git project. These hooks will
generate the ctags files in your $XDG_CACHE_HOME/vim/tags/ folder every time
you:
- Checkout ([post-checkout])
- Commit ([post-commit])
- Merge ([post-merge])
- Rebase ([post-rewrite])
If the hooks are enabled in the current git config:
# local to a repo
git config hooks.ctags.enable true
# global config
git config --global hooks.ctags.enable true
Then, they will execute the main [ctags generator] script.
Ensure ~/.ctags Configuration
To set different ctags options, create yourself a ~/.ctags, I've included an
example at [contrib/example.ctags]
Vim work-flow
When you open Vim the plugin will try to detect the working-directory of the git
super-project or submodule, and tells Vim to use the generated ctags file in the
central location. This also happens after creating or reading a file. Note:
The plugin caches the tags location per-tab, so mixing different project files
in the same tab won't work as expected. You can easily change this behaviour to
act per-buffer by hacking on tagabana.vim.
Customization
Options
Options you can set in your .vimrc to overwrite default behaviour.
| Option | Default | Description |
|---|---|---|
g:tagabana_tags_dir | $XDG_CACHE_HOME/vim/tags/ | Central directory for tags |
g:tagabana_match_submodule | 0 | Match submodules as well? |
Credits & Contribution
This plugin was developed by Rafael Bodill under the MIT License. Pull requests are welcome.