Subject: [PATCH] eglot-server-programs: Account for new modes

From: Brian Leung <[email-masked]>
Date: Tue, 25 Oct 2022 04:01:09 +0000

Tags: patch

In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
version 1.16.0, Xaw3d scroll bars)
Repository revision: 8f16578c45fc1d23aacecdb48111f816088c7b83
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12014000
System Description: NixOS 22.11 (Raccoon)

Configured using:
 'configure
 --prefix=/nix/store/044ilan524hm57j9lhz7fqg2nxfga5n7-emacs-git-20221024.0
 --disable-build-details --with-modules --with-x-toolkit=lucid
 --with-xft --with-cairo --with-native-compilation'

>From 2365a02ac3fecafcffea2e35b3852835bf0177c9 Mon Sep 17 00:00:00 2001
From: Brian Leung <[email-masked]>
Date: Mon, 24 Oct 2022 20:43:50 -0700
Subject: [PATCH 1/2] eglot-server-programs: Account for new js-json-mode

* lisp/progmodes/eglot.el (eglot-server-programs): Move the
json-language-server info before the entry for js-mode, and add on
js-json-mode.

js-json-mode derives from js-mode, so the reordering is necessary to
prevent js-mode's eglot server from starting if a user has something
like

(add-to-hook 'js-json-mode #'eglot-ensure)
(add-to-hook 'js-mode #'eglot-ensure)

in their config.
---
 lisp/progmodes/eglot.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 71001ba680..9dca05d5f0 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -186,6 +186,7 @@ eglot-server-programs
                                 (python-mode
                                  . ,(eglot-alternatives
                                      '("pylsp" "pyls" ("pyright-langserver" "--stdio") "jedi-language-server")))
+                                ((js-json-mode json-mode) . ,(eglot-alternatives '(("vscode-json-language-server" "--stdio") ("json-languageserver" "--stdio"))))
                                 ((js-mode typescript-mode)
                                  . ("typescript-language-server" "--stdio"))
                                 (sh-mode . ("bash-language-server" "start"))
@@ -227,7 +228,6 @@ eglot-server-programs
                                 (zig-mode . ("zls"))
                                 (css-mode . ,(eglot-alternatives '(("vscode-css-language-server" "--stdio") ("css-languageserver" "--stdio"))))
                                 (html-mode . ,(eglot-alternatives '(("vscode-html-language-server" "--stdio") ("html-languageserver" "--stdio"))))
-                                (json-mode . ,(eglot-alternatives '(("vscode-json-language-server" "--stdio") ("json-languageserver" "--stdio"))))
                                 (dockerfile-mode . ("docker-langserver" "--stdio"))
                                 ((clojure-mode clojurescript-mode clojurec-mode) 
                                  . ("clojure-lsp"))
-- 
2.38.0

>From b022569c136dc6a23e1b4cfe5e23e94cb05e233e Mon Sep 17 00:00:00 2001
From: Brian Leung <[email-masked]>
Date: Mon, 24 Oct 2022 20:46:41 -0700
Subject: [PATCH 2/2] eglot-server-programs: Account for new ts-mode

* lisp/progmodes/eglot.el (eglot-server-programs): Add new major mode
to be used with the typescript-language-server.

At the time of writing, this exists only in the unmerged tree-sitter
branch.  It is not harmful to include, however.
---
 lisp/progmodes/eglot.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 9dca05d5f0..54756dd21a 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -187,7 +187,7 @@ eglot-server-programs
                                  . ,(eglot-alternatives
                                      '("pylsp" "pyls" ("pyright-langserver" "--stdio") "jedi-language-server")))
                                 ((js-json-mode json-mode) . ,(eglot-alternatives '(("vscode-json-language-server" "--stdio") ("json-languageserver" "--stdio"))))
-                                ((js-mode typescript-mode)
+                                ((js-mode ts-mode typescript-mode)
                                  . ("typescript-language-server" "--stdio"))
                                 (sh-mode . ("bash-language-server" "start"))
                                 ((php-mode phps-mode)
-- 
2.38.0