0

My emacs is set up with lsp-mode that works well for TypeScript & JSX using ts-ls. However, now that I'm exploring deno, lsp-mode incorrectly sets up my deno projects with ts-ls, and I can't figure out how to tell lsp-mode to initialize the workspace with the deno LSP instead.

My current emacs config utilizes web-mode + lsp-mode:

(use-package web-mode
  :ensure t
  :mode (("\\.ts\\'" . web-mode)
         ("\\.js\\'" . web-mode)
         ("\\.tsx\\'" . web-mode)
         ("\\.jsx\\'" . web-mode))
  :config
  (setq web-mode-content-types-alist
    '(("jsx" . "\\.js[x]?\\'"))))

(use-package lsp-mode
  :ensure t
  :hook (web-mode . lsp)
  :commands lsp)

I've used a .dir-locals.el solution before for something that is somewhat similar, by setting the Yarn 2+ TypeScript server to a different path: https://yarnpkg.com/getting-started/editor-sdks#emacs. However, this case is slightly different. I don't need a different server for ts-ls, I need to initialize the workspace with deno LSP.

What's the best way to set lsp-mode's language server based on a directory? I'd like ts-ls to be the default, and deno LSP only in specific cases, probably by project directory (since the file extension is the same).

1 Answer 1

1

This was still solvable with .dir-locals.el. Here's what I needed to get it to work:

((nil . ((lsp-enabled-clients . '(deno-ls)))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.