-
Notifications
You must be signed in to change notification settings - Fork 200
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
Multiple entries in eglot-server-programs for the same mode #90
Comments
Actually, @mkcms we could enhance this to also allow multiple servers to manage the same buffer. |
@joaotavora I was actually planning to extend the way eglot chooses servers for managing buffers like that:
All of those things are rather easy to implement, and I already implemented no. 1. I just wanted to have them all before making a PR. Do you think those they are useful? |
I am weary of adding syntax to
|
I will open a PR for that.
Alternatively, could we still use the current infrastructure, but just ask which server to use?
I don't get that though. Would multiple servers manage that buffer, or would they just be started to see if they work or something? Would e.g. a definitions request ask all servers in current buffer and then merge the results into one list? |
Well yes. At least this is what I think makes sense. But it's better to hold off this development for a while, since the changes would be truly drastic. Everywhere we use
|
So should I look into implementing 'asking the user which server to start'?
That's pretty interesting. To take this a bit further, it could just be a python script, so that all LSP clients can use it, IIUC. |
How are you planning to coordinate that with the existing interactive behavior of
Yes, indeed you could very well write this in whatever language you prefer. |
And python is probably a good choice given its popularity... |
Good question. I guess there's no option but assume that functional contacts are always present? E.g. include the contact as a choice, and call it only after it was chosen by the user. |
Above I was talking about functional contacts. In general, is there anything special to consider?
|
It has to generally make sense :-)
OK.
OK. Unless the user explicitly use
OK In general, I think the best way to do this is to rewrite the current You are also looking at a significant overhaul of the |
Then again, this isn't strictly true. If you want to rewrite more deeply and you can make it readable (and not enormous), that's also OK. Anyway, I would start with the docstrings and move on from there. |
OK, I will do that. However probably not soon, because I'm pretty busy now. I probably won't be very active for a while. |
I suggest to keep user interaction out of To be honest I'm not very familiar with eglot or Org Mode, so this might not be the case. But something similar happens when I enabled lsp-mode and tried to export some Org files; and I guessed that this is the cause (because the debug trace has something about lsp-mode and I know lsp-mode sometimes requires you to chose the project root interactively). |
You won't get that, unless you do something you shouldn't. If you just use the recommended way of enabling eglot in some mode automatically, e.g. |
Multiple servers is a cool idea, but how about the original proposal (a list of servers)? That could be useful for configuring default servers. We can just have a list of servers in the default configuration. And the one that the user installed will be used. This way, users wouldn't even need to customize |
Jump in this thread, to provide a usecase scenario for multiple language servers bought up by We recently build a project specific language server to navigate across FFIs. The idea is that while pyls and c++ works perfectly fine for find definitions within languages, they cannot trace cross language ffis. While that is a hard problem in general, we can build a specific tool for our project which detects certain patterns and tracks calls from python to c++. This would however, requires the ls client to be able to make use of this project-specific language server along with the generic ones, and combines the result from both to get the final result. |
@tqchen, I think even in your case, one can potentially write a proxy LSP server that combines the result form the generic and the special servers. Then clients can work without modification. This way, only one proxy has to be written, whereas your proposal requires to modify every client. |
Yep, non-eglot-dependent proxy-server seems like the way to go here, at least on first glance. I'm happy to start that discussion with some knowledgeable people tho. |
I'm sorry, I see this is more or less a good discussion venue for this already. And my silly wording seems to imply that I think you all aren't knowledgeable. Sorry about that, it doesn't make any sense 🤦♂️. |
Then to make the discussion thrive, I'd like to mention that there's an LSP proxy I use all the time, which might be generalized to combine multiple server "backends": https://github.com/sourcegraph/lsp-adapter/ |
What do you mean generalized? You mean changing it? It... looks dauntingly complex. And needs Go. I was thinking of something Python of maybe Perl based. But I guess if you can make that work, then, why not? Is it free software? |
Proxy server approach sounds good to me, as long as there is a minimum guideline for users to configure it. IMO It really depends on the level of complexity of the client, in the particular use-case that we need, it would be a matter of change the server to a list, and have a way to combine results(e.g. concat all the lists). So it might not be a bad feature to have on the client side given the minimum complexity. This particular use-case was already supported by the lsp-mode. Although I am not expert on this project so I might be wrong here. |
It is a good feature to have on the client side, but not necessary on the final LSP client editor.
It's more than that. You have to send every request to two servers, combine responses in different ways (first available, wait for all possible). And you have to keep per-server capabilities, too. So it's best to offload that hard work to a multiplexer that the Eglot client (or any other client) sees as just one server. |
Just another note: you can do all that in Emacs lisp, but you would be limiting yourself to contributors/users in Emacsland (needlessly in my opinion). |
I also like the proxy idea and it would be interesting to see a different take on how to approach multi-server scenarios than lsp-mode. If my understanding is right, this proxy is not eglot or particular server specific, so it can be written once and for all and it would remove the complexity of implementing multi-server handling (be it client or serer side). It would benefit other people working in the same space. (it reminds me of the fact that the purpose of the LSP is to be a proxy for different languages to different editors, interesting we are talking about another layer of proxying :) ) |
My thoughts exactly 👍 |
[lsp-adapter]
It's under MIT license. I think go is as good as any other language. But this is not my "personal itch", so I don't intend to contribute to a multiplexer proxy. (But that doesn't stop me from speaking gibberish.) |
Just to be clear though (for folks coming here without context), |
I think it would be convenient if we allowed users to add multiple entries for the same major mode to
eglot-server-programs
, and then tried each one in order until we find one for which an executable exists For example:(setq eglot-server-programs '((c-mode . "cquery") (c-mode . "clangd")))
Or alternatively:
(setq eglot-server-programs '((c-mode . (or "cquery" "clangd"))))
The text was updated successfully, but these errors were encountered: