diff --git a/.dir-locals.el b/.dir-locals.el index 798fc99..ee8e4a0 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -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"))))) )))) diff --git a/package.json b/package.json index f42715c..13a7b21 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/packages/ts-plugin/README.md b/packages/ts-plugin/README.md index 7f19c84..e5fa0f1 100644 --- a/packages/ts-plugin/README.md +++ b/packages/ts-plugin/README.md @@ -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`