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

Send structured InitializationOptions to the server #121

Merged
merged 5 commits into from
Jan 7, 2025

Conversation

DavisVaughan
Copy link
Collaborator

@DavisVaughan DavisVaughan commented Dec 20, 2024

Closes #100

This PR sends a minimal amount of initialization options through initializationOptions - logLevel and dependencyLogLevels. These are currently our only 2 client side options, but the important part is that they really are initialization time options.

For 99% of client side options, this isn't really the right thing to do. We are instead supposed to "pull" options dynamically on the server side. We would do that at startup and after any meaningful change notification (workspace changes, configuration changes, etc). See microsoft/language-server-protocol#567 for a big discussion about this. Note that I don't think ruff really does this correctly.

If we ever wanted logLevel to be dynamic, it would come through initializationOptions AND also be "pull"ed dynamically (as a way to refresh it).

Here are the places we might dynamically "pull" options in the future (once we have user/workspace level options)
- Initialized notification handler, where we'd request them for the first time (possibly also adding a lock to prevent any other requests from running until we've requested them and set them)
- DidChangeWorkspaceFolders, requesting them for opened workspaces, purging them for closed workspaces
- DidChangeConfiguration, where we use DidChangeConfiguration as a simple notification that "something" has changed in configuration, so we have to repull every scope we are interested in (this is now how you are supposed to use DidChangeConfiguration apparently)

In particular, this lets us respect `air.logLevel` and `air.dependencyLogLevels` on server startup

User and workspace level settings are not used yet but are included for completeness
@DavisVaughan

This comment was marked as outdated.

@DavisVaughan DavisVaughan requested a review from lionel- January 6, 2025 18:18
Copy link
Collaborator

@lionel- lionel- left a comment

Choose a reason for hiding this comment

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

Did you know about handle_initialized() in handlers.rs? We already have some infra in place for dynamic watching of settings. Probably worth making these dynamic now?

crates/lsp/src/handlers_state.rs Outdated Show resolved Hide resolved
"properties": {
"air.logLevel": {
"default": null,
"markdownDescription": "Controls the log level of the language server.\n\n**This setting requires a restart to take effect.**",
Copy link
Collaborator

Choose a reason for hiding this comment

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

These static settings are a bit annoying. Probably worth it to make it dynamic right away?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Going to do in a follow up after we rework testing a bit to allow for dynamicness in the logging code

editors/code/src/settings.ts Outdated Show resolved Hide resolved
editors/code/src/settings.ts Outdated Show resolved Hide resolved
@DavisVaughan DavisVaughan merged commit 92887d3 into main Jan 7, 2025
5 checks passed
@DavisVaughan DavisVaughan deleted the feature/initialization-options branch January 7, 2025 15:31
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.

Hook up user specified options of air.logLevel and air.dependencyLogLevels in VS Code extension
2 participants