Ctags + Bundler + Vim = Exuberance
I have meant to do this for a while after reading this article but today I took the plunge and got my setup working nicely with Ctags.
Installation
Super easy on the mac with brew install ctags
I am sure that apt can do the same with ease on Linux.
Get started
Check that ctags -R .
works in your project folder, then open vim and <C-]>
to follow a tagged reference like a method or class name.
autotag.vim
I wanted to update tags in my project when a file gets written, autotag.vim does the trick, I justs dropped it into my pathogen directory.
curl -O https://raw.github.com/craigemery/dotFiles/master/vim/plugin/autotag.vim
Library code tagging.
I wanted tags to be generated for all the gems in Gemfile when I run bundler. It would be great If bundler had some sort of post install hook as has been proposed. In the meantime I am quite happy with this that lives in my ~/bin
I have named it tagundle
but anything will do
#!/usr/bin/env ruby
system("bundle check || bundle")
require 'rubygems'
require 'bundler'
paths = Bundler.load.specs.map(&:full_gem_path)
system("ctags -R -f gems.tags #{paths.join(' ')}")
don't forget the chmod +x
I just run tagundle
instead of bundle to check and install the Gemfile and then update the tags for all the library code in use.
Then to wire this up add set tags+=gems.tags
to ~/.vimrc
I may also at some point generate tags for the ruby source-code…
I also added gems.tags
to my .gititgnore-global
Conclusion
I have been using Ctags for a few hours now, and they seem well worth the 15 minutes it took to get everything set up...