This commit defines: - spacemacs-default-jump-handlers: a list of functions that can jump to definition in ALL modes. - spacemacs-jump-handlers-MODE: a list of functions that can jump to definition in MODE. - spacemacs-jump-handlers: a buffer-local list of functions that can jump to definition. This is made up of the values of the two previous variables whenever a given major mode is activated. - spacemacs/jump-to-definition: a function that tries each function in spacemacs-jump-handlers in order, and stops when one of them takes us somewhere new. - spacemacs|define-jump-handlers: a macro that * defines spacemacs-jump-handlers-MODE, possibly filled with initial functions * defines a function that is added to the hook of the given MODE * binds “SPC m g g” of that MODE to spacemacs/jump-to-definition This is an attempt to harmonize all the different approaches to jumping. Specifically, - Existing intelligent jump packages that work for only a single mode should go to the beginning of spacemacs-jump-handlers-MODE. E.g. anaconda for python, ensime for scala, etc. - Packages like gtags that work for several modes (but potentially not all) and which is dumber than the intelligent jumpers should go the the END of spacemacs-jump-handlers-MODE. - Packages like dumb-jump that work for all modes should go to spacemacs-default-jump-handlers. In all cases the order of the jump handlers in each list should be from most to least intelligent. Fixes #6619 |
||
---|---|---|
.. | ||
img | ||
config.el | ||
funcs.el | ||
packages.el | ||
README.org |
TypeScript layer
Description
This layer adds support for TypeScript and TSX editing.
This layer provides:
- Eldoc-mode
- Documentation at point
- Auto complete
- Flycheck with linter
- Jump to definition, Jump to type definition
- Find occurrences (Imenu-mode)
- Rename symbol
- tsx mode
- formatting
- TypeScript playground integration
Install
Pre-requisites
You will need node.js v0.12.0
or greater
If you want linting run: npm install -g typescript
npm install -g tslint
If you want to use typescript-formatter for formatting run: npm install -g typescript-formatter
For best results, make sure that the auto-completion
(company) and html
layers are enabled.
Layer
To use this configuration layer, add it to your ~/.spacemacs
. You will need to
add typescript
to the existing dotspacemacs-configuration-layers
list in this
file.
(setq-default dotspacemacs-configuration-layers '(typescript))
If you need formatting on save:
(setq-default dotspacemacs-configuration-layers '(
(typescript :variables
typescript-fmt-on-save t)))
You can choose formatting tool:
(setq-default dotspacemacs-configuration-layers '(
(typescript :variables
typescript-fmt-tool 'typescript-formatter)))
Default is 'tide .
Notes
This layer uses:
- tide
- flycheck-typescript-tslint
- typescript-formatter - optional.
The tools use configuration files. You can learn more in their documentation.
Make sure to add tsconfig.json in the project root folder.
tsserver mangles output sometimes issue - #2758, which will result in json parse error. Try node version 0.12.x if you get this error.
Send to playground requires browser.
Currently tsserver doesn't pickup tsconfig.json file changes. You might need to restart server after editing it.
Key bindings
Typescript Major Mode
Key Binding | Description |
---|---|
SPC m = |
reformat the buffer |
SPC m g b |
jump back |
SPC m g g |
jump to entity's definition |
SPC m g t |
jump to entity's type definition |
SPC m g u |
references |
SPC m h h |
documentation at point |
SPC m r r |
rename symbol |
SPC m s p |
send selected region or current buffer to the web playground |
SPC m S r |
restart server |
Reference Major Mode
Key Binding | Description |
---|---|
C-j |
find previous reference |
C-k |
find next reference |
C-l |
goto reference |