typescript: update README.org for multiple backends
This commit is contained in:
parent
59e0c5683a
commit
522eafbd2b
|
@ -7,10 +7,11 @@
|
||||||
- [[#features][Features:]]
|
- [[#features][Features:]]
|
||||||
- [[#install][Install]]
|
- [[#install][Install]]
|
||||||
- [[#pre-requisites][Pre-requisites]]
|
- [[#pre-requisites][Pre-requisites]]
|
||||||
- [[#backend][Backend]]
|
- [[#choosing-a-backend][Choosing a backend]]
|
||||||
- [[#layer][Layer]]
|
- [[#backends][Backends]]
|
||||||
- [[#notes][Notes]]
|
- [[#tide][Tide]]
|
||||||
- [[#configuration][Configuration]]
|
- [[#notes][Notes]]
|
||||||
|
- [[#language-server-protocol][Language Server Protocol]]
|
||||||
- [[#key-bindings][Key bindings]]
|
- [[#key-bindings][Key bindings]]
|
||||||
- [[#typescript-major-mode][Typescript Major Mode]]
|
- [[#typescript-major-mode][Typescript Major Mode]]
|
||||||
- [[#reference-major-mode][Reference Major Mode]]
|
- [[#reference-major-mode][Reference Major Mode]]
|
||||||
|
@ -19,6 +20,7 @@
|
||||||
This layer adds support for TypeScript and TSX editing.
|
This layer adds support for TypeScript and TSX editing.
|
||||||
|
|
||||||
** Features:
|
** Features:
|
||||||
|
- Multiple backends support: Tide and LSP
|
||||||
- Eldoc-mode
|
- Eldoc-mode
|
||||||
- Documentation at point
|
- Documentation at point
|
||||||
- Auto complete
|
- Auto complete
|
||||||
|
@ -31,29 +33,6 @@ This layer adds support for TypeScript and TSX editing.
|
||||||
- TypeScript playground integration
|
- TypeScript playground integration
|
||||||
|
|
||||||
* Install
|
* 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.
|
|
||||||
|
|
||||||
*** Backend
|
|
||||||
Pick the backend for typescript-mode. Options are =tide= and =lsp=.
|
|
||||||
#+BEGIN_SRC emacs-lisp
|
|
||||||
(setq-default dotspacemacs-configuration-layers '(
|
|
||||||
(typescript :variables
|
|
||||||
typescript-backend 'tide)))
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
If you pick =lsp=, you have to install the following dependencies with npm.
|
|
||||||
#+BEGIN_SRC shell
|
|
||||||
npm i -g typescript javascript-typescript-langserver flow-language-server typescript-language-server
|
|
||||||
#+END_SRC
|
|
||||||
|
|
||||||
** Layer
|
|
||||||
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
|
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
|
add =typescript= to the existing =dotspacemacs-configuration-layers= list in this
|
||||||
file.
|
file.
|
||||||
|
@ -80,25 +59,47 @@ You can choose formatting tool:
|
||||||
|
|
||||||
Default is 'tide .
|
Default is 'tide .
|
||||||
|
|
||||||
** Notes
|
** Pre-requisites
|
||||||
This layer uses:
|
You will need =node.js v0.12.0= or greater.
|
||||||
- [[https://github.com/ananthakumaran/tide][tide]]
|
|
||||||
- [[https://github.com/flycheck/flycheck][flycheck]]
|
|
||||||
- [[https://github.com/vvakame/typescript-formatter][typescript-formatter]] - optional.
|
|
||||||
|
|
||||||
*The tools use configuration files. You can learn more in their documentation.*
|
If you want linting run:
|
||||||
|
|
||||||
Make sure to add [[https://github.com/Microsoft/TypeScript/wiki/tsconfig.json][tsconfig.json]] in the project root folder.
|
#+BEGIN_SRC shell
|
||||||
|
npm install -g typescript tslint
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
tsserver mangles output sometimes [[https://github.com/Microsoft/TypeScript/issues/2758][issue - #2758]], which will result in json parse
|
If you want to use typescript-formatter for formatting run:
|
||||||
error. Try node version 0.12.x if you get this error.
|
|
||||||
|
|
||||||
Send to playground requires browser.
|
#+BEGIN_SRC shell
|
||||||
|
npm install -g typescript-formatter
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
Currently tsserver doesn't pickup tsconfig.json file changes. You might need to
|
For best results, make sure that the =auto-completion= (company) and =html=
|
||||||
restart server after editing it.
|
layers are enabled.
|
||||||
|
|
||||||
* Configuration
|
** Choosing a backend
|
||||||
|
To choose a default backend set the layer variable =typescript-backend=:
|
||||||
|
|
||||||
|
#+BEGIN_SRC elisp
|
||||||
|
(setq-default dotspacemacs-configuration-layers '(
|
||||||
|
(typescript :variables typescript-backend 'tide)))
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
Backend can be chosen on a per project basis using directory local variables
|
||||||
|
(files named =.dir-locals.el= at the root of a project), an example to use the
|
||||||
|
=lsp= backend:
|
||||||
|
|
||||||
|
#+BEGIN_SRC elisp
|
||||||
|
;;; Directory Local Variables
|
||||||
|
;;; For more information see (info "(emacs) Directory Variables")
|
||||||
|
|
||||||
|
((typescript-mode (typescript-backend . lsp)))
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
*Note:* you can easily add a directory local variable with ~SPC f v d~.
|
||||||
|
|
||||||
|
* Backends
|
||||||
|
** Tide
|
||||||
Tide comes with an embedded Typescript server, it is recommended to use the
|
Tide comes with an embedded Typescript server, it is recommended to use the
|
||||||
server intalled by =npm= instead. To do so set the variable
|
server intalled by =npm= instead. To do so set the variable
|
||||||
=tide-tsserver-executable= to the path of the =tsserver= executable.
|
=tide-tsserver-executable= to the path of the =tsserver= executable.
|
||||||
|
@ -111,6 +112,24 @@ For example:
|
||||||
tide-tsserver-executable "/usr/local/bin/tsserver")))
|
tide-tsserver-executable "/usr/local/bin/tsserver")))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
|
*** Notes
|
||||||
|
Make sure to add [[https://github.com/Microsoft/TypeScript/wiki/tsconfig.json][tsconfig.json]] in the project root folder.
|
||||||
|
|
||||||
|
tsserver mangles output sometimes [[https://github.com/Microsoft/TypeScript/issues/2758][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.
|
||||||
|
|
||||||
|
** Language Server Protocol
|
||||||
|
You have to install the following dependencies with npm.
|
||||||
|
|
||||||
|
#+BEGIN_SRC shell
|
||||||
|
npm i -g typescript javascript-typescript-langserver flow-language-server typescript-language-server
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
* Key bindings
|
* Key bindings
|
||||||
** Typescript Major Mode
|
** Typescript Major Mode
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue