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: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Felician Nemeth <felician.nemeth <at> gmail.com>
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 17:22:29 -0500
>> 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?

Could be, tho it depends.
AFAIK they can't use Customize to do that because packages (like
`bicep-ts-mode.el`) modify the variable outside of Customize's control,
so currently they have to do something like:

    (add-to-list 'eglot-server-programs '(bicep-ts-mode . MYSERVER))

which may need to be adjusted to

    (with-eval-after-load 'eglot
      (add-to-list 'eglot-server-programs '(bicep-ts-mode . MYSERVER)))

or

    (with-eval-after-load 'bicep-ts-mode
      (add-to-list 'eglot-server-programs '(bicep-ts-mode . MYSERVER)))

With the variable I suggest I guess they'd have to do

    (add-hook 'bicep-ts-mode-hook
      (lambda () (setq-local eglot-server-program '(bicep-ts-mode . MYSERVER))))

I know some people find `add-hook` and `lambda` more scary than
`eval-after-load` and `add-to-list`, so I guess it would count as
"harder", yes.

Maybe we should offer an actual `defcustom` variable for user overrides,
if we care enough.  Personally, I prefer to work on making the
`add-hook+lambda` approach more accessible, because it's just very
flexible and powerful, so it's much more generally useful.
One such effort is to use `use-package` or `setup`.


        Stefan





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.