GNU bug report logs - #76423
Major-mode provided LSP server for Eglot

Previous Next

Package: emacs;

Reported by: Stefan Monnier <monnier <at> iro.umontreal.ca>

Date: Wed, 19 Feb 2025 20:34:02 UTC

Severity: wishlist

Tags: patch

Full log


View this message in rfc822 format

From: Felician Nemeth <felician.nemeth <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Kevin Brubeck Unhammer <unhammer <at> fsfe.org>, 76423 <at> debbugs.gnu.org, João Távora <joaotavora <at> gmail.com>
Subject: bug#76423: Major-mode provided LSP server for Eglot
Date: Wed, 19 Feb 2025 22:52:25 +0100
Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs <at> gnu.org> writes:

> Eglot should make it easier for major modes to suggest which LSP
> server to use.

> The patch below would let this major modes do it with a simple:
>
>       (setq-local eglot-server-programs
>                   `(bicep-ts-mode . ("dotnet" ,(bicep-langserver-path))))

Wouldn't the patch make harder for the users to customize Eglot to use
their preferred LSP server instead of the server suggested by the major
mode?

Thanks,
Felicián

>
> - Stefan
>
>
> diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
> index bd28174e7da..3aff922be1d 100644
> --- a/lisp/progmodes/eglot.el
> +++ b/lisp/progmodes/eglot.el
> @@ -235,6 +235,10 @@ eglot-alternatives
>                        when probe return (cons probe args)
>                        finally (funcall err)))))))
>  
> +(defvar-local eglot-server-program nil
> +  "Description of the server to use.
> +Follows the same syntax as any element of `eglot-server-programs', ")
> +
>  (defvar eglot-server-programs
>    ;; FIXME: Maybe this info should be distributed into the major modes
>    ;; themselves where they could set a buffer-local `eglot-server-program'
> @@ -354,7 +358,7 @@ eglot-server-programs
>  
>  * In the most common case, a symbol such as `c-mode';
>  
> -* A list (MAJOR-MODE-SYMBOL :LANGUAGE-ID ID) where
> +* A list (MAJOR-MODE-SYMBOL :language-id ID) where
>    MAJOR-MODE-SYMBOL is the aforementioned symbol and ID is a
>    string identifying the language to the server;
>  
> @@ -1331,7 +1335,9 @@ eglot--lookup-mode
>                                          (replace-regexp-in-string
>                                           "\\(?:-ts\\)?-mode$" ""
>                                           (symbol-name sym))))))
> -   for (modes . contact) in eglot-server-programs
> +   for (modes . contact) in (if (null eglot-server-program)
> +                                eglot-server-programs
> +                              (cons eglot-server-program eglot-server-programs))
>     for llists = (mapcar #'eglot--ensure-list
>                          (if (or (symbolp modes) (keywordp (cadr modes)))
>                              (list modes) modes))




This bug report was last modified 113 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.