Skip to content

Instantly share code, notes, and snippets.

@loz
Created April 23, 2012 21:17
Show Gist options
  • Save loz/2473927 to your computer and use it in GitHub Desktop.
Save loz/2473927 to your computer and use it in GitHub Desktop.
Generate gems.tags from your bundle in a project
#!/usr/bin/env ruby
require 'bundler'
require 'bundler/runtime'
puts 'Building gems.tags from bundle'
outpath = 'gems.tags'
begin
runtime = ::Bundler::Runtime.new Dir.pwd, ::Bundler.definition
paths = runtime.specs.map(&:full_gem_path).join(' ').strip
system("find #{paths} -type f -name \\*.rb | ctags -f gems.tags -L -")
rescue
puts 'Unable to build, is there a Gemfile?'
end
@loz
Copy link
Author

loz commented Apr 27, 2012

Here's how to setup this on mac osx

in ~/bin/ create bundler-ctags file with above code in
then chmod a+x ~/bin/bundler-ctags

ensure that $PATH includes ~/bin/
(you can add the following to .bash_profile:

export PATH="$HOME/bin:$PATH"

In your vimrc add:
set tags+=gems.tags

Now you can run:

bundle-ctags in the root of a project where it's Gemfile is.

Now in that project, you can press Ctrl-] to go to the function within it's definition in any gem in the bundle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment