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
rbenvplugin and a gem that automatically generates ctags for rubygems - Let
gitknow that you want to include thectagsbinary and your new hooks in all git tracked repos - Create a
ctags binarythat generates a tags file for each project, and a fewgithooks to keep our tags files up to date - Ensure your git-tracked repos have the newly created hooks and
ctagsbinary - 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
tagsor.tagsfiles from your project repos, or you’re gonna have a bad time
Steps
Install exuberant ctags
Open your terminal and type:
brew install ctagsInstall the
rbenvplugin andctagsgem- 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
ctagsbinary andhooksfilesDownload all of the hooks files and the
ctagsbinary 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 ctagswhenever you move between branches, commit, etc., so your tags file is always up to date!Add
git ctagscommand 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-ctagscd 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-viewpackage is enabled in Atom!Relaunch Atom once
Profit by using the
go to definitionfeature in Atom!
Questions? Comments? Problems? Improvements? Anything??? Comment below and tell me, and I'll do my best to help!