In Atom, by default there's a package called symbols-view. It basically allows you to search for particular functions, classes, variables etc. Most often not by typing but by search based on whatever word the cursor is currently on.
With this all installed and set up I can now press Cmd-alt-Down and it automatically jumps to the definition of that thing. If the result is ambiguous (e.g. two functions called get_user_profile
) it'll throw up the usual search dialog at the top.
To have this set up you need to use something called ctags
. It's a command line tool.
This Stack Overflow post helped tremendously. The ctags
I had installed was something else (presumably put there by installing emacs
). So I did:
$ brew install ctags
And then added
alias ctags="`brew --prefix`/bin/ctags"
...in my ~/.bash_profile
Now I can run ctags -R .
and it generates a binary'ish file called tags
in the project root.
However, the index of symbols in a project greatly varies with different branches. So I need a different tags
file for each branch. How to do that? By hihjacking the .git/hooks/post-checkout
hook.
Now, this is where things get interesting. Every project has "junk". Stuff you have in your project that isn't files you're likely to edit. So you'll need to list those one by one. Anyway, here's what my post-checkout
looks like:
#!/bin/bash
set -x
ctags -R \
--exclude=build \
--exclude=.git \
--exclude=webapp-django/static \
--exclude=webapp-django/node_modules \
.
This'll be run every time I check out a branch, e.g. git checkout master
.
Comments