-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
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. |
Confused now about how to configure language servers since the "config" parameter was removed. Are there docs for this? |
Is this in the current version? because i have just copied over the typescript version from the docs and that gives me an error: Error parsing user language config: unknown field `language-servers`, expected one of `name`, `scope`, `file-types`, `shebangs`, `roots`, `comment-token`, `text-width`, `soft-wrap`, `config`, `auto-format`, `formatter`, `diagnostic-severity`, `grammar`, `injection-regex`, `language-server`, `indent`, `debugger`, `auto-pairs`, `rulers`, `workspace-lsp-roots`
in `language` |
You're using an older version of |
@MarkStruik If I'm not mistaken this feature is only in |
Thanks for responding. So if I want that I need to build from master? ( ahh I now get the version number scheme 😁 ) or is this merge planned in a release that’s coming soon? |
If you're on mac you can run |
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. |
**Summary** Breaking changes: - Support multiple language servers per language [getsolus#2507](helix-editor/helix#2507) - This is a breaking change to language configuration Full release notes: - [23.10](https://github.com/helix-editor/helix/blob/master/CHANGELOG.md#2310-2023-10-24)
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 |
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-server
is configured by default):or equivalent:
Each requested LSP feature is priorized in the order of the
language-servers
array.For example the first
goto-definition
supported language server (in this casetypescript-language-server
) will be taken for the relevant LSP request (commandgoto_definition
).If no
except-features
oronly-features
is 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:
format
goto-definition
goto-declaration
goto-type-definition
goto-reference
goto-implementation
signature-help
hover
document-highlight
completion
code-action
workspace-command
document-symbols
workspace-symbols
diagnostics
rename-symbol
inlay-hints
Another 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.