-
Notifications
You must be signed in to change notification settings - Fork 809
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
Spec should discourage abuse of initializationOptions and didChangeConfiguration #567
Comments
Interesting. I use At what point would you consider the use of this "abuse" though? |
As an adopter of LS I don't develop, I consider any usage is abuse, as long as it requires to create a specific UI or workflow to interact with it in the client ;) But I hope this discussion can lead to a more flexible definition. |
As I see it, a server initialized without |
@LaurentTreguier: so your proposal is that the settings should be limited to only client-specific configuration? I think it'd be fair. |
This is how I understood it. The spec describes it as |
IMO the spec should encourage all server providers to spec the following to things:
Having a push model for configurations was a mistake and got basically replaced by the pull model where the server sends The client should still send |
- the initialization options it supports. I agree with @LaurentTreguier
<https://github.com/LaurentTreguier> that a server should work with an
empty literal as well and simply assume a set of defaults.
Just to give examples and food for thought, VSCode CSS language server
requires explicit enablement for sass, scss and so on; and VSCode JSon
language server doesn't pre-load a typical list of JSon schema. Both assume
client discover this settings by reverse engineering VSCode and repeat the
same settings. The question is what drove the developers of those LS to
rely on those options instead of making them default? It'd be interesting
to get their POV on this question.
Having a push model for configurations was a mistake and got basically
replaced by the pull model where the server sends workspace/configuration
requests.
Still, the expected type is `any[]` which means that it's some LS specific
settings that require specific integration.
I don't think the flow of the operation was the issue here (while it's
still good to know it was improved), it's really than any `any` leads to
the unspecified world and specific effort of integration between client and
LS, which is the opposite of LSP goal.
I believe instead of specifying some operations with `any`, it's better to
leave these as extensions. For clients, it's a similar effort to support
one or the other, and it's not reusable between LS, so the protocol should
remain strictly made of specified, portable, reusable operations, and
whenever there is `any`, consider deprecating the operation basically
because it's not specified enough to be useful by most tools.
|
I disagree here. The reason is that the fact that I still think that it is a fair thing to require a server to depend on some I do fully agree that the spec need to spec this assumptions. @aeschli any comments on why the CSS language server can't work with a reasonable default set ? |
One pattern I saw emerge is that many language servers interpret
It doesn't use the term "configuration", but it does say "user provided" (not client provided). The reason why language servers use it for configuration is because there is otherwise no way to read configuration in |
I will clarify the spec in a way that the I am actually against whitelisting |
Please ping if you think dynamic registration is not the right path to go. |
I will clarify the spec in a way that the initializationOptions is
typically something that could be passed on the command line when starting
the server. It shouldn't be user configurations.
I disagree with that. The initializationOptions can be a good way to
guarantee that user settings are passed immediately to the LS before to
starts up. I think that basically, the initializationOptions have to be a
super-set of the didChangeConfiguration as there are case where we want the
configuration immediately.
From a client perspective, the didChangeConfiguration is over-used, hard to
maintain and is semantically often used with wrong semantic since several
LS use it even to retrieve a default configuration. Eclipse Corrosion had
an important discussion with RLS on that matter, and the resolution that
initializationOptions can contain a mirror of didChangeConfiguration
improved things a lot: rust-lang/rls#1026
|
@dbaeumer I agree for determining whether a provider should be registered or not, but a server might need configuration during initialisation for a lot of reasons. For example, a loglevel or logfile, whether file watchers should be set up with polling or OS events, the HTTP endpoint of a service that needs to be contacted, whether dependencies should be installed, if yes an access token for that, the path of an external tool that needs to be shelled into, something like JAVA_HOME or GOPATH, ... |
@felixfbecker the list you provided don't seem to be user configuration which is something that should come through |
Could you explain why a user-defined access token should come through a command line option and not user settings? Lots of VS Code extensions configure access tokens through settings, or JAVA_HOME/GOPATH, ... It seems like an arbitrary distinction if the extension had to filter out specific settings to pass them through |
Multiplying the entry-points for configuration/options is making harder and harder to adopt the protocol. |
@dbaeumer dynamic registration is not always available, as clients aren't forced to implement it. Atom, with its official |
This is exactly what I want to avoid by making it more clear. The @felixfbecker if the user token is a user setting then it should come through |
@LaurentTreguier I am not against having |
I think me and others gave a lot of examples of this kind of config in this thread - it really is a very common use case.
The server could just make the request and if it returns an error fall back to a different mechanism. But the whole whitelist could also be announced in |
static vs dynamic is not absolute and depends a lot on the client and the server. Some clients tend to allow/encourage a lot of user configuration, some others using similar LS would prefer providing a pre-defined config and not let user tweak it. As such, I don't think using the static vs dynamic distinction is reliable here. |
@felixfbecker and @mickaelistria can you both please write what you would like to see written in the spec. I have to say I get puzzled here since it is not clear to me what kind of settings you want to allow and what kind of settings you want to forbid. The original idea of the I will revert the changes and wait for you to make concrete wording proposals. |
I would like to see specified something like
and/or the other way round
|
and also something like
|
I thought this is exactly what we don't want. We shouldn't push server developers in updating a configuration using In my opinion to make this easier for clients to handle we should say:
|
I agree that they shouldn’t be in initialisationOptions, and the docs should clarify that. The term used for user-defined settings is “configuration”, not “options”. This seems like the simplest solution to me to solve the use case and without any drawbacks. |
See microsoft/language-server-protocol#567 for motivations to not require `InitializationOptions` TODO: Check if there is any other custom clientside code we use which should be disabled if not implemented
It is possible to send I will close the issue since I am really not a fan of having another property during initialization. Please ping if you think otherwise. |
The current spec says
Which seems to contradict what you said, @dbaeumer ? |
No this contradicts nothing.
A server can therefore do a |
Gotcha, thanks! |
@dbaeumer The latest solution doesn't seem sufficient and I think Good servers should pull relevant workspace settings by namespace, for each workspace folder if interested, and incorporate that before they start processing normal document notifications/requests. Currently you can only do that in the Is that the basic recommended approach? Or are servers supposed to initialize once with default settings, initialize again with pulled config slightly later while possibly receiving doc info in between? I don't see any other interpretation. Well, extension authors have avoided this and are still heavily relying on Is there a good reason to not allow-list |
This is what we're doing in HLS. In fact we do all of what you said:
I agree that this is not very good, and it certainly seems that if you do the recommended thing you can start getting sent requests before you have your config set up. |
good |
In general I try to keep the message that can be sent to the client in initialized as small as possible to make the initialization phase on the client simple.
I usually do that when actually processing a request and then cache the result of the |
This is not a good candidate for lazy init because:
I think that would mean just storing the initialize params and returning server info and capabilities, since technically everything else can be done lazily. But server authors won't use it that way. A more meaningful differentiation is that Please reconsider allow-listing |
I'm working on having Eclipse IDE adopting some language servers.
I see a possible bad trend for Language Servers to heavily rely on initializationOptions and didChangeConfigurations to enable/disable features. The issue with those is that they are unspecified placeholders and that whatever usage is made of it requires all clients to write code specific to this language server to support those options.
The main example I have in mind right now is RLS that, by abusing those settings is progressively, and most likely without really willing it, breaking rich compatibility with other IDEs: rust-lang/rls#1047
Abuse of those properties should be deprecated in the spec, with some disclaimer explaining how relying on those make the LS integration less likely to be trivially portable from an editor to another.
The text was updated successfully, but these errors were encountered: