gurgeous / bust-a-gem

Adds "Go to Definition" for Ruby projects in VS Code.
https://marketplace.visualstudio.com/items?itemName=gurgeous.bust-a-gem
MIT License
36 stars 8 forks source link

Build Status

Bust A Gem for VS Code

The Bust A Gem extension adds "Go to Definition" for Ruby projects in VS Code. It will create a TAGS file using the ripper-tags gem, and then use the tags for Go to Definition. Fast and easy.

Bust A Gem provides two additional handy features:

Note: Bust A Gem relies on bundler and only works with Ruby projects that have a Gemfile.

Table of Contents

Installation

First, install the extension through VS Code extensions. Search for Bust A Gem.

Second, Bust A Gem uses the excellent ripper-tags gem to build a TAGS file for your project. Open an Integrated Terminal in VS Code (using View > Integrated Terminal) and run gem install ripper-tags. That should put ripper-tags into a spot where VS Code can spawn it. If you are still getting errors about ripper-tags, use Help > Toggle Developer Tools to see more debug info.

Alternate ripper-tags installation

Add gem ripper-tags to your Gemfile and run bundle install. In VS Code Settings, set bustagem.cmd.rip to bundle exec ripper-tags -f TAGS -R --force --extra=q to use bundler.

Ripping

The first time you use "Go to Definition", Bust A Gem will use ripper-tags to create a TAGS file for your project.

Bust A Gem initially just indexes your project. You can also index some of your gem dependencies, which makes it possible to use Go to Definition to jump into a gem. See Settings.

Bust A Gem doesn't rebuild TAGS automatically. Use the "Rebuild" command to rebuild the TAGS File. You'll want to do this periodically as you work on your project, or after a change to Bust A Gem settings.

Settings

Initially, Bust A Gem will only index files in your workspace. Add gem names to bustagem.gems to instruct Bust A Gem to add some of your gems to the TAGS file. Bust A Gem uses bundler and your Gemfile to find those gems. Don't forget to run "Rebuild" to rebuild the TAGS file!

For advanced usage, skip bustagem.gems and set bustagem.cmd.rip to rip the gems you want. This is a better choice if you use multiple workspaces. For example, to rip all gems from your Gemfile:

ripper-tags -f TAGS -R --force --extra=q $(bundle show --paths)

Or a subset (if present):

ripper-tags -f TAGS -R --force --extra=q $(bundle show --paths | grep -E "(activeadmin|shopify|webflow)")

See #18 for details.

Settings Example Notes
bustagem.gems [ "activerecord", "devise", ... ] List of gems to index for the TAGS file.
bustagem.cmd.bundle "bundle show --paths" Command used to list gems.
bustagem.cmd.rip "ripper-tags -f TAGS -R ..." Command used to create the TAGS file.

Caveats and Troubleshooting

A few notes from my experience so far:

Contributing

Feel free to open issues or PRs! We welcome all contributions, even from beginners. If you want to get started with a PR, please do the following:

  1. Read the VS Code Extension Docs, especially Running and Debugging Extensions.
  2. Fork this repo.
  3. Install dependencies with npm install.
  4. Open the repo directory in VS Code and install the recommended VS Code extensions. This is important, because we use tslint and prettier with our Typescript.
  5. Make a code change and test it using F5 / Start Debugging. This is not hard, see the doc links above.
  6. Create a branch and submit a PR!

Changelog

0.1.8 - Apr 2020

0.1.7 - Nov 2018

0.1.6 - Mar 2018

License

This extension is licensed under the MIT License.