2018-05-18 03:34:24 +00:00
|
|
|
#+TITLE: Tern layer
|
|
|
|
|
|
|
|
[[file:img/tern.png]]
|
|
|
|
|
2018-09-19 03:54:47 +00:00
|
|
|
* Table of Contents :TOC_4_gh:noexport:
|
2018-05-18 03:34:24 +00:00
|
|
|
- [[#description][Description]]
|
|
|
|
- [[#features][Features:]]
|
|
|
|
- [[#install][Install]]
|
|
|
|
- [[#configuration][Configuration]]
|
|
|
|
- [[#custom-tern-command][Custom tern command]]
|
|
|
|
- [[#re-use-the-server-across-multiple-different-editing-sessions][Re-use the server across multiple different editing sessions]]
|
2018-12-05 03:03:03 +00:00
|
|
|
- [[#key-bindings][Key bindings]]
|
2018-05-18 03:34:24 +00:00
|
|
|
|
|
|
|
* Description
|
|
|
|
This layer adds support for [[http://ternjs.net/][tern]] stand-alone code-analysis engine for
|
|
|
|
JavaScript.
|
|
|
|
|
|
|
|
** Features:
|
|
|
|
- TODO: list the feature of tern supported by tern package
|
|
|
|
|
|
|
|
* Install
|
|
|
|
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
|
|
|
|
add =tern= to the existing =dotspacemacs-configuration-layers= list in this
|
|
|
|
file.
|
|
|
|
|
|
|
|
You can install =tern= globally with the following command:
|
2018-07-10 10:57:25 +00:00
|
|
|
|
2018-05-18 03:34:24 +00:00
|
|
|
#+BEGIN_SRC sh
|
|
|
|
$ npm install -g tern
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
* Configuration
|
|
|
|
** Custom tern command
|
|
|
|
Windows users may need to set the variable =tern-command= in order for emacs to
|
|
|
|
locate and launch tern server successfully. See [[https://github.com/syl20bnr/spacemacs/issues/5733][this open issue for more
|
|
|
|
details]]. The variable can be set by adding the =tern= layer with this
|
|
|
|
configuration layer:
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
2018-09-19 03:54:47 +00:00
|
|
|
(tern :variables tern-command '("node" "/path/to/tern/bin/tern"))
|
2018-05-18 03:34:24 +00:00
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
Note: =tern-command= must be a list of strings.
|
|
|
|
|
|
|
|
** Re-use the server across multiple different editing sessions
|
|
|
|
By default =tern= is setup to not create multiple =.tern-port= files in your
|
|
|
|
repository.
|
|
|
|
|
|
|
|
To make tern re-use the server across multiple different editing sessions (thus
|
|
|
|
creating multiple =.tern-port= files for each document you have open [[http://ternjs.net/doc/manual.html][see here
|
|
|
|
for more details]]) set the variable =tern-disable-port-files= to nil:
|
|
|
|
|
|
|
|
#+BEGIN_SRC emacs-lisp
|
|
|
|
(tern :variables tern-disable-port-files nil)
|
|
|
|
#+END_SRC
|
|
|
|
|
2018-12-05 03:03:03 +00:00
|
|
|
* Key bindings
|
2018-05-18 03:34:24 +00:00
|
|
|
|
2018-12-05 03:03:03 +00:00
|
|
|
| Key binding | Description |
|
2018-05-18 03:34:24 +00:00
|
|
|
|---------------+------------------------------------------------------------------------------------------|
|
|
|
|
| ~SPC m C-g~ | brings you back to last place you were when you pressed M-.. |
|
|
|
|
| ~SPC m g g~ | jump to the definition of the thing under the cursor |
|
|
|
|
| ~SPC m g G~ | jump to definition for the given name |
|
|
|
|
| ~SPC m h d~ | find docs of the thing under the cursor. Press again to open the associated URL (if any) |
|
|
|
|
| ~SPC m h t~ | find the type of the thing under the cursor |
|
|
|
|
| ~SPC m r r V~ | rename variable under the cursor using tern |
|