Skip to content
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

Support workspace/configuration #737

Merged
merged 7 commits into from Sep 30, 2019
Merged

Conversation

tomv564
Copy link
Contributor

@tomv564 tomv564 commented Sep 29, 2019

This is enough to get the eslint server to pull configuration from the client config's settings object.

The kotlin language server also used the request briefly (with section parameter set to "kotlin") but reverted to workspace/didChangeConfiguration.

Goal is to cover needs discussed in issue #699

Need to figure out how to handle:

  • section (eslint doesn't use it, but I guess we could treat them as keys under the client config settings object?) Lack of consistent use, we wait for more server to adopt.
  • scopeUri (at least send None for URIs outside the workspace?) wait for multiple workspace support
  • do we need to check server support? (we could send workspace/didChangeConfiguration notifications with no content, unclear if needed) There is no server capability.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 36.001% when pulling 7919b5e on workspace_configuration_request into 2072a12 on master.

for requested_item in requested_items:
items.append(session.config.settings)

client.send_response(Response(request_id, items))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be a lot more work to do it "properly" from the start and expose a hook that LSP plugins (LanguageHandler implementations) could react to?

I don't know if it would be really worth it, as with static configuration it will probably be good enough for 99% of the cases, but just in case... :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it would be nice if language handlers can replace this built-in implementation. Would it not be valuable for LSP to provide a functional example for other plugins to improve on (with better defaults for example) ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you are right. Providing default with a way to override would be the best.

For Eslint server, response can include properties like workspaceFolder and workingDirectory. To provide those, we'd need to be able to override response in LanguageHandler but to be fair, I've been running without those two and things are generally working without them. So I'm not sure how important are those.

items = [] # type: List[Any]
requested_items = params.get("items") or []
for requested_item in requested_items:
items.append(session.config.settings)
Copy link
Member

@rchl rchl Sep 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we will go with this hardcoded solution, maybe we should consider not using root settings but have a more specific property in settings for this case. It should be better in case there is a need later to provide some other settings also.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found no explanation that this configuration request expects a different data structure than the one sent by didChangeConfiguration. With your example, users would suddenly have to move their config into a new property just because the server “upgraded” to the workspace/configuration request.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I thought it's some arbitrary settings. Didn't know it's something more specific that is already sent with specific message. Then it makes sense to do it like that.

@tomv564 tomv564 force-pushed the workspace_configuration_request branch from 7919b5e to 9b66ab8 Compare September 30, 2019 09:23
@tomv564
Copy link
Contributor Author

tomv564 commented Sep 30, 2019

The use of "section" in VS code's eslint: Server sends a blank section, and assumes the Code extension only returns eslint config (see: https://github.com/microsoft/vscode-eslint/blob/master/client/src/extension.ts#L490)

Hopefully this means section is a path after the language server's config.
The Kotlin server sent "kotlin" as section, meaning they expected they were querying a "global" set of settings (which exists in VS Code, but in LSP the settings start at the language client config).

Ignoring section for now is likely incorrect, but works for both implementations that I found.

@tomv564
Copy link
Contributor Author

tomv564 commented Sep 30, 2019

ScopeUri is probably best implemented once we have multiple workspaces.

@tomv564 tomv564 changed the title WIP: Support workspace/configuration Support workspace/configuration Sep 30, 2019
@tomv564 tomv564 merged commit 02938c5 into master Sep 30, 2019
@tomv564 tomv564 deleted the workspace_configuration_request branch September 30, 2019 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants