-
Notifications
You must be signed in to change notification settings - Fork 184
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
Read values for workspace/configuration request from settings #908
Conversation
See: https://microsoft.github.io/language-server-protocol/specification#workspace_configuration The Julia server sends multiple configuration keys as 'section'. This commit extracts the corresponding values for those keys from the "settings" entry of the server configuration, and returns None for missing values, as described in the protocol specification. A special case is needed for the ESLint server, which sends a blank section instead, but expects a dict of configuration settings.
936bb35
to
31681f1
Compare
Can we split the requested configuration key on the dot, and then go into the settings dictionary for each token?
So something like this: def get_value_from_section(current: Any, section: str) -> Any:
keys = section.split('.')
for key in keys:
if isinstance(current, dict):
current = current.get(key)
else:
return None
return current
for requested_item in requested_items:
section = requested_item['section']
items.append(get_value_from_section(self.config.settings, section)) I hope this'll work with these kinds of settings, more in line with kotlin and eslint: "settings": {
"julia": {
"format": {
"calls": false,
"comments": false
},
"lint": {
"call": false,
"modname": false
}
}
} |
I have something like that in my plugin too! It's really handy. |
To be honest I think the Julia server's choice of requesting individual values using this parameter (it's called section for a reason) is a bit special and I personally wouldn't go out of my way to accommodate it. Users can just put eg "julia.format.calls" in their LSP settings, it's ugly but doesn't cost us any extra logic. |
…figuration request
I've checked how VS Code handles its settings for the Julia server: they also just put single dotted strings e.g. "julia.format.calls" in their settings and don't split on dots, and personally I would prefer a flat settings structure as well. However, if we use nested setting structures elsewhere, I'm also fine with adding a function to split requested values into separate tokens, if requested for consistency. In my opinion, neither the Julia server nor ESLint use
So for the Julia server implementation it would make more sense to ask for two objects 'julia.format' and 'julia.lint', so our setting structure would be "settings": {
"julia.format": {
"calls": false,
"comments": false,
"curly": false
},
"julia.lint": {
"call": false,
"constif": false,
"datadecl": false
}
} If the way like how ESLint just expects a single nested settings structure was the intended way, why would it have been wrapped into an array with different |
You can update |
So what happens if one day julia-ls decides to request a single If we decide to allow
If a server requests And the other way around also seems broken. The difference in settings-structure furthermore makes it difficult for new users to understand what the general rule about these settings are. |
I see that is a goood point and would add flexibility for such kind of request changes from servers.
Edit: OK I think that objection didn't make sense 🙈 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I'm happy all settings structures/schemas for all servers are the same.
The workspace/configuration request seems to be implemented differently in various servers:
section
section
.This PR makes LSP to read each
section
from the server's settings in LSP.sublime-settings, so for the Julia server they could for example beIf a 'section' name is missing in the settings, LSP should use
None
as its value, as described in https://microsoft.github.io/language-server-protocol/specification#workspace_configuration.A separate fix is needed for the ESLint server, because its 'section' value is blank.
The Kotlin server would require
This might require a change for users who use this server, but I think it is better than adding another special case just for that server. I have not tested with the Kotlin server though, perhaps someone could test if it works before merging?
The
scopeURI
described in the specs is still ignored here by LSP (it is not used in the Julia server).Fixes #907
Related: #699