guerrinha · 2022-12-20 18:27
Hi everyone, I'm trying to set up my Emacs to work with Deno and Node. I use projectile and eglot. My node setup work fine and after try the deno setup I mess with the node =\\
There is a way to only eval this code:
\`(add-to-list 'eglot-server-programs '((js-mode typescript-mode) . (eglot-deno "deno" "lsp")))\`
If the project has a \`deno.json\` file?
danielstaleiny · 2022-12-20 20:58
use .dir-locals.el to set your deno project. the rest can default to node.
lastnamebird · 2022-12-20 21:01
The demo documentation has a [solution](https://deno.land/manual@v1.29.1/getting_started/setup_your_environment#eglot)
guerrinha · 2022-12-20 22:52
I followed the documentation but with this config, every file that use js-mode or typescript will use deno lsp instead of typescript lsp
guerrinha · 2022-12-20 22:53
Thanks, I'll try
lastnamebird · 2022-12-21 16:30
oh sorry, I should have said it can help you find a solution. This is what I currently use:
(defclass eglot-deno (eglot-lsp-server) ()
:documentation "A custom class for deno lsp.")
(cl-defmethod eglot-initialization-options ((server eglot-deno))
"Passes through required deno initialization options"
(list :enable t
:lint t))
(defun deno-project-p ()
"Predicate for determining if the open project is a Deno one."
(when-let* ((project (project-current))
(p-root (project-root project)))
(file-exists-p (concat p-root "deno.json"))))
(defun ts-server-program (&rest _)
"Decide which server to use based on project characteristics."
(cond ((deno-project-p) '(eglot-deno "deno" "lsp"))
(t '("typescript-language-server" "--stdio"))))
(map-put! eglot-server-programs
;; Emacs 29 currently includ the tree-sitter modes
'(js-mode js-ts-mode tsx-ts-mode typescript-ts-mode typescript-mode)
`ts-server-program)
guerrinha · 2022-12-23 01:37
>js-mode js-ts-mode tsx-ts-mode typescript-ts-mode typescript-mode
Thanks a lot u/lastnamebird, I got some errors with \`defclass\` but your code has the answered I'm looking for. With your code and this [discussion](https://github.com/joaotavora/eglot/discussions/999), I ended up with this [solution](https://github.com/guilhermecomum/emacs.d/blob/main/readme.org#eglot)