Updates to ts-plugin README, and a .dir-locals.el
This commit is contained in:
parent
6bec672087
commit
66aed5c882
2 changed files with 74 additions and 3 deletions
6
.dir-locals.el
Normal file
6
.dir-locals.el
Normal file
|
@ -0,0 +1,6 @@
|
|||
((typescript-mode
|
||||
. ((eval . (setq tide-tsserver-executable
|
||||
(concat
|
||||
(let ((d (dir-locals-find-file ".")))
|
||||
(if (stringp d) d (car d)))
|
||||
"node_modules/typescript/lib/tsserver.js"))))))
|
|
@ -40,12 +40,55 @@ then `yarn install`.
|
|||
|
||||
### Emacs with Tide
|
||||
|
||||
It should Just Work.
|
||||
It should Just Work, if the `node_modules` next to `tsconfig.json` has
|
||||
a `typescript/` subdirectory.
|
||||
|
||||
If no such `typescript/` subdirectory exists in `node_modules`, then
|
||||
because
|
||||
[tsserver loads plugins from relative to tsserver.js rather than tsconfig.json](https://github.com/microsoft/TypeScript/issues/42688),
|
||||
you will have to tell `tide-mode` about where your project's
|
||||
`tsserver` lives.
|
||||
|
||||
One easy way to do that is to create a symlink in your `node_modules`:
|
||||
|
||||
```shell
|
||||
ln -s /FULL/PATH/TO/YOUR/PROJECT/node_modules/typescript ./node_modules/
|
||||
```
|
||||
|
||||
Another way to do it is to put a `.dir-locals.el` file in your project
|
||||
root, containing
|
||||
|
||||
```elisp
|
||||
((tide-mode
|
||||
. ((tide-tsserver-executable
|
||||
. "/FULL/PATH/TO/YOUR/PROJECT/node_modules/typescript/bin/tsserver"))))
|
||||
```
|
||||
|
||||
I don't know of any way of automatically resolving a relative path
|
||||
specification with respect to the directory containing
|
||||
`.dir-locals.el` without using `eval`, but if you're happy to do so,
|
||||
you can use the following:
|
||||
|
||||
```elisp
|
||||
((typescript-mode
|
||||
. ((eval . (setq tide-tsserver-executable
|
||||
(concat
|
||||
(let ((d (dir-locals-find-file ".")))
|
||||
(if (stringp d) d (car d)))
|
||||
"node_modules/typescript/lib/tsserver.js"))))))
|
||||
```
|
||||
|
||||
If you use the `.dir-locals.el` methods, you may need to run
|
||||
`tide-restart-server` once after opening the first TypeScript file in
|
||||
your project (and then close and re-open that TypeScript file).
|
||||
|
||||
### Visual Studio Code
|
||||
|
||||
After `yarn install`, you will have a `node_modules/typescript`
|
||||
directory.
|
||||
After `yarn install`, if you have a `node_modules/typescript`
|
||||
directory, then the following will work. (Otherwise, there may not be
|
||||
an option to select "Use Workspace Version", and you may need to
|
||||
symlink a `typescript` directory into `node_modules` as described for
|
||||
Emacs Tide above.)
|
||||
|
||||
Open VS Code, and select the version of TypeScript contained therein
|
||||
by following instructions
|
||||
|
@ -60,3 +103,25 @@ file containing:
|
|||
{
|
||||
"typescript.tsdk": "node_modules/typescript/lib"
|
||||
}
|
||||
|
||||
## Debugging
|
||||
|
||||
You can get verbose logs from Tide's tsserver by setting the Emacs
|
||||
variable `tide-tsserver-process-environment`:
|
||||
|
||||
```elisp
|
||||
(setq tide-tsserver-process-environment '("TSS_LOG=-file /tmp/tss.log"))
|
||||
```
|
||||
|
||||
You can also enable "verbose" output, if that's useful:
|
||||
|
||||
```elisp
|
||||
(setq tide-tsserver-process-environment '("TSS_LOG=-level verbose -file /tmp/tss.log"))
|
||||
```
|
||||
|
||||
Finally, you can set these options in a `.dir-locals.el` file, too:
|
||||
|
||||
```elisp
|
||||
((typescript-mode
|
||||
. ((tide-tsserver-process-environment . ("TSS_LOG=-level verbose -file /tmp/tss.log")))))
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue