Subject: bug#72343: [PATCH] Fix eglot-server-programs for TeX modes

From: João Távora <[email-masked]>
Date: Tue, 6 Aug 2024 17:27:28 +0100

On Tue, Aug 6, 2024 at 4:45 PM Augusto Stoffel <[email-masked]> wrote:
>
> On Tue, Aug 6, 2024, 17:34 João Távora <[email-masked]> wrote:
>>
>> * lisp/progmodes/eglot.el (eglot-server-programs): Explicitly list modes
>> derived from tex-mode, so that the correct language id is guessed.
>>
>> Won't it break when another mode is derived from it?
> Not really, since such a hypothetical mode has no support from the servers.

No but it might represent a language that does! servers don't care modes,
they know about languages.  Furthermore, the same server, even
the same server connection might serve multiple documents in multiple
different languages.

> That doesn't work, because apparently Eglot picks the language id

Eglot pairs language ids with modes (plural).  This is what the internal
function eglot--lookup does.  In the same session, multiple language-id
maybe be picked depending on the LSP document being "opened".
So there's no "single pick" in general.

> of the first mode in the listing that applies, which previously was the generic tex-mode. That doesn't allow distinguishing latex and plain TeX. Again, the issue is not guessing the language id string from the mode name, but rather choosing the right mode symbol to guess from.

Previously, you suggested :language-id would work, but you didn't
want to "dabble" with it.  Now you seem to be saying it can't work
at all.

This may be an "XY Problem".  Can you state what exactly is the
end result you're trying to achieve (short of "writing thesis" or "fulfill
life goals") as someone who has never seen Eglot source code
before or has looked at LSP event logs to check what is being sent.
Tell me which server is installed and what file(s) in which major
modes you are visiting just before typing `M-x eglot`.  Then tell me
what happens to said server invocation (if any).  Focusing on the
goal  rather than the means may help me understand what you
want to achieve.

Thanks