-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Add support for multiple language servers per language #2507
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
Add support for multiple language servers per language #2507
Conversation
|
It might be good to survey how other LSP clients handle multiple LSPs. I suspect that the features should be configurable so you can choose which language server configuration is used to format or request signature-help or autocompletion. Requesting auto-complete from multiple language servers and merging the values could be disirable as well as code actions and diagnostics. |
|
My opinion
|
Yes, I also think there needs to be something like that, currently one completion request future fills the completion menu. I'm pretty sure in the near future there will be multiple completion sources (like file-path completion, which is useful most of the time I think). Same applies of course for code-actions and diagnostics. Maybe this should be done before this PR? Btw. I've tested this PR so far with |
5bb5e8c to
e887912
Compare
e887912 to
d8bbfe7
Compare
|
An update: Merging of completion results, code-action and symbols in the symbol picker(s) are working now. I have slightly refactored the UI components Menu, Completion and (File)Picker to be able to extend options/items after the respective component has been created. I've also added support to call Merging works like this currently: spawn all lsp-request futures, and then collect them in a loop, the first finished future, creates the menu/picker/etc. and the next futures extend it. This could potentially mean, that if the menu/picker etc. was closed in the meantime that a new menu/picker is spawned, if one of the LSP takes too long for a request. This could be tackled with Mutexes (see in code_action, here: 5040679#diff-abe37ebb421b375471daa248c8de6541335e61dd3dfc93ee999eb108876e5837R213) I'm not sure if it makes sense to refactor the way the ui collects its data further (e.g. via streams or something), it may get too complex this way I guess... |
|
Another thing I've noticed, a few other editors have separated LSPs from the languages (like neovim). This may make sense, if an LSP should be used for multiple languages at once (e.g. E.g. extend [[language-server]]
name="efm-frontend" # could be used as unique id
command="efm-langserver"
config = {..}
# ...
[[language]]
name = "typescript"
language-servers = [
{
command = "typescript-language-server",
args = ["--stdio"],
language-id = "javascript"
},
"efm-frontend"
]
|
d866093 to
65961c9
Compare
|
I think I got a little bit ahead of myself... I have now implemented pretty much everything I think is necessary to support multiple language servers. This includes the change suggested in the previous comment, with the exception, that every language server is now configured in a separate table I think the rest is hopefully documented well enough in I will update the PR message if all is good |
b8cbe3b to
de72a59
Compare
de72a59 to
7d3f736
Compare
7d3f736 to
b685db7
Compare
b685db7 to
df7ff54
Compare
|
Is there anything I can do, that makes reviewing this PR easier? Like splitting not directly related parts into its own PR? (Since keeping this up-to-date with master is quite some work...) |
|
Splitting the PR into multiple smaller ones (even dependent ones, where one PR depends on another to be merged first) would definitely make reviewing easier. Some PRs cannot do this and that's fine, but where possible breaking them down is always better. |
|
When will this be on release so that it appears on scoop as well? |
We don't maintain the scoop package, so you'll have to ask whoever does. |
Fair enough but I would imagine they do not update it until there is a new official release. Now if I look at past releases it might suggest end of August? |
|
Yep, we're working on a release that will include this and the other changes in master. We try to release every few months (see the faq) but we don't commit to firm timelines / ETAs. |
|
I know this is closed, but maybe someone has an answer. Is it possible to append a language server, rather than replace the current ones? If wanted one for every language (copilot) for example, that would be a bit tedious. Being able to just add a language server rather than overwrite would be great. |
|
Your proposal makes sense, and I think I've thought about something like that (pretty much the use-case you've presented). You could open an issue with a design of the configuration you think makes sense (when there isn't yet an issue with that, haven't searched for that...). |
|
#9318 will actually allow that |
This comment was marked as abuse.
This comment was marked as abuse.
Multiple language servers per language has already been merged and is available (for several releases now). Is something not working in your config? If so, I'd recommend making a new issue for it.
It's OSS, people should work on whatever they like. |
This comment was marked as abuse.
This comment was marked as abuse.
I still recommend you make a separate issue(or even better a discussion) describing what you're expecting. Your request is off-topic for this PR, since it's a completely separate part of the language server protocol compared to your "common LSP for all languages". Even re-reading it, I'm not sure what you're getting it, but it has no place in this PR. |
This comment was marked as abuse.
This comment was marked as abuse.
Do you mean a global default LSP? Like, instead of manually setting the name for every language, we specify it once and the editor will invoke it regardless of the file-type that is opened? That could be useful for LSPs such as this one, as mentioned here |
This comment was marked as abuse.
This comment was marked as abuse.
|
As mentioned before, you should open an separate issue or discussion for this feature wish. Discussion on a PR should be about implementation details, scope and features or bugs before merge. Post-merge it comments should be kept to the necessary minimum of referencing for other PRs or issues, to keep the noise low for people who got subscribed to a PR over time. |
This comment was marked as abuse.
This comment was marked as abuse.
|
This is a long-merged PR, you're notifying a lot of people with something that should definitely be a separate issue, as it is an additional feature, that is somewhat orthogonal to this PR, and well this PR is merged, so it just doesn't make sense to discuss this here, as we can't merge it again in a different state... And if you care so much about it, just implement it, don't expect other people to do this in their free-time. |
This comment was marked as abuse.
This comment was marked as abuse.
|
Necrobumping is poor form but at this point I'm pretty sure you're just trolling / rage baiting. Knock it off. |
Adds support for multiple language servers per language.
Language Servers are now configured in a separate table in
languages.toml:The language server for a language is configured like this (
typescript-language-serveris configured by default):or equivalent:
Each requested LSP feature is priorized in the order of the
language-serversarray.For example the first
goto-definitionsupported language server (in this casetypescript-language-server) will be taken for the relevant LSP request (commandgoto_definition).If no
except-featuresoronly-featuresis given all features for the language server are enabled, as long as the language server supports these. If it doesn't the next language server which supports the feature is tried.The list of supported features are:
formatgoto-definitiongoto-declarationgoto-type-definitiongoto-referencegoto-implementationsignature-helphoverdocument-highlightcompletioncode-actionworkspace-commanddocument-symbolsworkspace-symbolsdiagnosticsrename-symbolinlay-hintsAnother side-effect/difference that comes with this PR, is that only one language server instance is started if different languages use the same language server.