From: Niels Thykier <niels@thykier.net>
To: "João Távora" <joaotavora@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>, 72088@debbugs.gnu.org
Subject: bug#72088: eglot: Segregates language servers in a way that hampers polyglot language servers
Date: Sun, 14 Jul 2024 14:01:32 +0200 [thread overview]
Message-ID: <8febc150-6ed6-430a-afd8-a738d960616e@thykier.net> (raw)
In-Reply-To: <CALDnm51jEzLYmyDMdT2o=O2JXhFZ52NfDNsVKypaKhMsnNoVuA@mail.gmail.com>
João Távora:
> On Sun, Jul 14, 2024, 10:36 Niels Thykier <niels@thykier.net> wrote:
>
>> I read through
>>
>> https://www.gnu.org/software/emacs/manual/html_node/eglot/Setting-Up-LSP-Servers.html
>> and I do not see anything here that decides how to control whether one
>> or two instances per project will be spawned.
>>
>
> In that section, did you happen to read this sentence?
>
> "In addition, major-mode can be a list of several major modes specified in
> one of the above forms – this means a running instance of the associated
> server is responsible for files of multiple major modes or languages in the
> project. "
>
> If so, how do you comprehend or interpret it? Maybe it could be clarified.
> Regardless, the default value of the eglot-server-programs variable that
> ships with Emacs has several examples that make use of this feature, so it
> may be worth studying those.
>
> João
>
I missed it entirely.
My recommendations would one or more of the following:
1 Use a more verbose variant of the `major-mode` placeholder, like
`(major-mode-or-modes . server)`. This would have prompted me
to not assume `major-mode` was just a single major-mode.
2 Provide an example featuring multiple modes in addition the existing
examples. This example could also show off the `:language-id`
feature.
3 Provide a howto guide for adding a new LSP server configuration
that explicitly featured the distinction between single mode vs.
multi-mode LSP servers.
(Note "howto guide" is specifically the "howto guide" from
https://docs.divio.com/documentation-system/)
For me, either 1+2 would definitely have worked. The third option is a
question of which kind of audience you want to optimize for. Personally,
I find it difficult myself to figure out what deserves a howto guide, so
I can totally understand if you pass on doing one of those.
A bit more on what happened on my end:
I think a key aspect of this problem is that I was trying to quickly
solve a problem. Namely getting my prototype to work and all I could
find was reference documentation, which is tailored for solving a
different type of documentation problem than what I ideally needed
(Compare problem-oriented vs information-oriented on
https://docs.divio.com/documentation-system/).
Since I know the documentation has the "wrong focus" for the thing I
want to do, I scan much more aggressively for examples and highlighted
words that looks like definitions and then retrace from there if
relevant. This is a common issue for many projects including some of my
own that they only provide one or two types of documentation (with
reference documentation being the most common type of documentation),
which has made me adopt this reading style.
The use of `major-mode` in the documentation had me assume that it was
one major mode at the time which works out of the box with no warnings.
The moment I saw: "The value of the variable is an alist, whose elements
are of the form (major-mode . server)", I was like "Got it, one major
mode + a server definition. Where do I find the definition of `server`?
Next line talks about the major-mode and I got what is. I need the
server part, oh I see the highlighted `(programs args)` below, so skip
to that. Oh, there are examples in the bottom. Ok, so 5x the first
example that with a bit of replacements" and I had some code that worked
and I was back to working on my language server. From there it took me
several months until the server reached maturity enough to provide
features where this mistake got in the way.
As mentioned, an example that might have worked would have been:
```
;; Polyglot LSP server example. The instance is reused
;; in a given project for all the listed modes.
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
'((
c-mode
(cpp-mode :language-id "c++"))
. ("custom-c-lsp" "--stdio"))))
```
In fact, it would have been nice to have this example, because I spent
30 minutes fighting with the elisp syntax figuring out the syntax. After
that, I spent 15 minutes trying to figure out why my `eglot-ensure`
configuration stopped working (as you can probably tell, lisp/elisp is
not really not my jam).
Hope that helped.
Best regards,
Niels
next prev parent reply other threads:[~2024-07-14 12:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-12 11:33 bug#72088: eglot: Segregates language servers in a way that hampers polyglot language servers Niels Thykier
2024-07-13 6:15 ` Eli Zaretskii
2024-07-13 16:29 ` João Távora
2024-07-14 4:37 ` Eli Zaretskii
2024-07-14 7:31 ` Niels Thykier
2024-07-14 8:01 ` João Távora
2024-07-14 9:36 ` Niels Thykier
2024-07-14 9:46 ` Niels Thykier
2024-07-14 10:30 ` Niels Thykier
2024-07-14 9:48 ` João Távora
2024-07-14 12:01 ` Niels Thykier [this message]
2024-07-14 13:21 ` João Távora
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8febc150-6ed6-430a-afd8-a738d960616e@thykier.net \
--to=niels@thykier.net \
--cc=72088@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=joaotavora@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.