Have you ever wished github's awesome Atom text editor had better support for jumping straight to a class or method definition like Rubymine or Sublime Text? Me too! So, here's a short set of instructions how to get this functionality working on OS X!
To summarize what we're going to do:
- Install exuberant ctags from homebrew
- Install an
rbenv
plugin and a gem that automatically generates ctags for rubygems - Let
git
know that you want to include thectags
binary and your new hooks in all git tracked repos - Create a
ctags binary
that generates a tags file for each project, and a fewgit
hooks to keep our tags files up to date - Ensure your git-tracked repos have the newly created hooks and
ctags
binary - Install a helper package in Atom called
autocomplete-ctags
- Profit!
Quick & Dirty
My good friend Tyler Davis turned this entire post into an awesome setup script if you'd like to avoid doing these steps manually!
note: if you’ve ever installed atom-ctags, remove it, and delete any
tags
or.tags
files from your project repos, or you’re gonna have a bad time
Steps
Install exuberant ctags
Open your terminal and type:
brew install ctags
Install the
rbenv
plugin andctags
gem- Visit https://github.com/tpope/rbenv-ctags and follow the installation instructions
- Visit https://github.com/tpope/gem-ctags and follow the installation instructions
Configure your git template directory
# create a git template directory in your home directory mkdir -p ~/.git_template # tell git you want to use this directory to copy "template" files into all new git repos git config --global init.templatedir '~/.git_template' # tell git you want to alias a command `git ctags` git config --global alias.ctags '!.git/hooks/ctags'
Copy my
ctags
binary andhooks
filesDownload all of the hooks files and the
ctags
binary from here:https://github.com/Lordnibbler/dotfiles/tree/master/git_template/hooks
And copy them into your git template directory (probably at
~/.git_template
). These hooks trigger a run ofgit ctags
whenever you move between branches, commit, etc., so your tags file is always up to date!Add
git ctags
command to your.gitconfig
# tell git you want to alias a command `git ctags` git config --global alias.ctags '!.git/hooks/ctags'
Install the atom package
apm install autocomplete-ctags
cd to a git-tracked project directory
# run this command to copy your hooks and ctags binary to the repo # don't worry, it won't blow away your commit history or do anything destructive! git init # to seed it once, just to prove it works run `git ctags`
Ensure
symbols-view
package is enabled in Atom!Relaunch Atom once
Profit by using the
go to definition
feature in Atom!
Questions? Comments? Problems? Improvements? Anything??? Comment below and tell me, and I'll do my best to help!