Fix (?) LSP config

This commit is contained in:
Tony Garnock-Jones 2021-12-24 15:28:05 -05:00
parent 9369bb56cd
commit 665d5ab219
3 changed files with 36 additions and 6 deletions

View File

@ -9,9 +9,14 @@
"node_modules/typescript/lib/tsserver.js"))
;; For LSP:
(require 'lsp-javascript)
(lsp-dependency 'typescript
`(:system ,(concat
(let ((d (dir-locals-find-file ".")))
(if (stringp d) d (car d)))
"node_modules/typescript/lib/tsserver.js"))))
(let ((node-modules (concat
(let ((d (dir-locals-find-file ".")))
(if (stringp d) d (car d)))
"node_modules/")))
(lsp-dependency 'typescript-language-server
`(:system ,(concat node-modules
"typescript-language-server/lib/cli.js")))
(lsp-dependency 'typescript
`(:system ,(concat node-modules
"typescript/lib/tsserver.js")))))
))))

View File

@ -18,6 +18,7 @@
"ts-jest": "^27.0",
"ts-node": "^10.4",
"ts-node-dev": "^1.1",
"typescript": "^4.5"
"typescript": "^4.5",
"typescript-language-server": "^0.8"
}
}

View File

@ -128,6 +128,30 @@ you like:
))))
```
Finally, I've had some trouble with LSP when I've not had
`typescript-language-server`, which is different to `tsserver` (?),
installed. Then, I've had to install the `typescript-language-server`
npm package, as well as `typescript`, and to take an approach similar
to this to point LSP at it:
```elisp
((typescript-mode
. ((eval
. (progn
(require 'lsp-javascript)
(let ((node-modules (concat
(let ((d (dir-locals-find-file ".")))
(if (stringp d) d (car d)))
"node_modules/")))
(lsp-dependency 'typescript-language-server
`(:system ,(concat node-modules
"typescript-language-server/lib/cli.js")))
(lsp-dependency 'typescript
`(:system ,(concat node-modules
"typescript/lib/tsserver.js")))))
))))
```
### Visual Studio Code
After `yarn install`, if you have a `node_modules/typescript`