I would absolutely recommend tern. I discovered it halfway through my internship (working in Node.js) last summer, and it worked wonderfully with company-mode
and js2-mode
.
js2-mode
by itself is quite powerful. It can handle the usual M-.
jumping within a file most of the time, and tern
complements it nicely with inter-file/module jumping (esp. in the node ecosystem).
The first step to using tern is installing the binary. I personally used npm to do so:
$ sudo npm install -g tern
Then install in Emacs. The relevant section from my init.el
is:
;;; tern
(package-require 'tern)
(add-hook 'js2-mode-hook (lambda () (tern-mode t)))
The final step is to set up a .tern-project
file in the root directory of your project. For Node.js projects, I use this as a starting point:
{
"loadEagerly": [
"src/**.js"
],
"plugins": {
"node": {
}
}
}
If you use company-mode
, then installing company-tern
is also highly recommended:
(package-require 'company-tern)
(eval-after-load 'company
'(add-to-list 'company-backends 'company-tern))
As a note, I did have some trouble with the tern server occasionally dying this past summer (2014). Running the following fixed it consistently:
M-: (delete-process "Tern") RET
I wasn't able to figure out exactly what was causing it, but it happened infrequently enough to be little more than a nuisance.
References: