-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Idea: wrap multiple servers #38
Comments
To be honest. This feature would be a life savier, as it would make eglot step into the modern world of 'multiple lsps in the same buffer'. I personally use from 2 to 4 lsps servers per buffer in most of my job projects. A feature like this could put Eglot in the game again 😄. Edit: if anyone is willing to implement it, I am happy to test it! |
When you use so many servers, how are you deciding and configuring which requests go to which servers? |
Well, I might not be the best to answer this, as I am mostly an USER of LSPs. I primarily use LSPs in Emacs, mostly with In my experience, LSP servers often complement each other rather than conflict, as each serves a distinct purpose. For example:
When hovering over code, the editor collects responses from all active LSPs and displays them merged, separated by a bar (when inline) or an horizontal bar when in a floating box. If multiple servers report the same diagnostic message (e.g., a linter and the language server flagging the same error), the messages are deduplicated. For code actions, the options are presented with an indication of which server provided them, such as:
This allows users to see which LSP is suggesting an action and choose accordingly. I think that would be the general idea. |
I don't think I fully understand this part. Could you please elaborate on this? I'm using lsp-mode, when multiple servers are used, each server is wrapped with its own emacs-lsp-booster, and AFAIK lsp-mode queries all servers fully in parallel asynchronously. I didn't observe any performance issues in this case.
So if I understand you correctly, what you mean is that emacs-lsp-booster can act as a "router" that forwards requests to different servers based on configurations and/or server capabilities, right? However, I think for most of the requests, what we want is actually "merging results", instead of "select one" (e.g. code actions, or diagnostics). But that's a "application-level" thing, while emacs-lsp-booster more-like work in "transport-level" to me (like nginx proxy). |
I suppose I meant if you didn't wrap both of them separately, the JSON translation and I/O latency would be doubled-up. If you have the option to wrap both, that might work well, though I suspect it would always be better to offload server communication outside of emacs. Eglot does not offer any such option. So you can see the power in using an intermediary like
Exactly. The details to figure out would be "which server(s) should I route this request to". After I wrote this I found this related discussion with eglot's author; he calls the idea a "server multiplexer". I'm proposing that
It's an important point, and one which I'm not as clear on. I know many people composite servers together because they provide different capabilities, in which case merging responses isn't necessary. But yes, if two servers are combined both of which provide, say completion results, you might want to merge them (and de-duplicate candidates?). Or you can just send both sets of results and let the application side sort that out. I can imagine a completion at point function that merges asynchronously and "just in time", for example. |
Update: this python server multiplexer does merge completions. |
Some servers are intended to be "add-ons", providing only certain features and expecting other servers to provide the rest. A classic combination is e.g.
pyright + ruff-lsp
. Juggling multiple servers is possible in many editors, and in Emacs with LSP (but not eglot). But all of the process contention and JSON performance issues that motivated this package are compounded when communicating with multiple LSP servers at the same time.eglot-lsp-booster
is well poised to help with this I think.Imagine a call like:
With a call like this,
emacs-lsp-booster
would start and communicate with two different servers at the same time, caching and translating the requests to and responses from both.Here
server1.cfg
andserver2.cfg
would be configuration files that instructemacs-lsp-booster
how set the priority for request types (these could also be passed as arguments). There would seem to be a number of ways to do this, but one simple idea:server1.cfg
mentions a given request name, send those requests to it.server2.cfg
mentions it, send those requests to server2.One thing to be worked out is capability registration during
initialize
, i.e. when the servers respond with their capabilities, like:It might be nice if
emacs-lsp-booster
could "spy" on this traffic, merging the capabilities to send back to the client, and saving an internal table of capabilities per-server to help direct requests to the correct server.The text was updated successfully, but these errors were encountered: