Skip to content

Simplify LSP settings #865

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

Open
wants to merge 2 commits into
base: feature/top-level-assign-symbols
Choose a base branch
from

Conversation

lionel-
Copy link
Contributor

@lionel- lionel- commented Jul 5, 2025

I think you'll like this one @DavisVaughan.

Branched from #859. I was concerned at how hard it was to add a new setting and section. I think the refactor in this PR will make things much simpler and easier:

  • Add a generic Setting type that allows us to flatten a representation of all our settings in a flat array SETTINGS that is easy to loop over. This drastically simplify the updating logic where we send all keys of interest to the client in a flat array, as we no longer need any bookkeeping.

  • The setting objects in this array contain the conversion-from-json logic as simple methods assigned to a closure field. The default handling is still delegated to Default methods in our setting types.

  • Remove the split between VS Code and LSP settings. If we want to add vscode agnostic settings in the future, we could add editor aliases in the SETTINGS array..

Copy link
Contributor

@DavisVaughan DavisVaughan left a comment

Choose a reason for hiding this comment

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

Blocking because this strips out per document config in favor of global config, which I think is incorrect

Comment on lines +106 to +108
use crate::lsp::config::SETTINGS;

for setting in SETTINGS {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
use crate::lsp::config::SETTINGS;
for setting in SETTINGS {
for setting in crate::lsp::config::SETTINGS {

That feels very AI 😆

@@ -284,121 +275,35 @@ pub(crate) fn did_change_formatting_options(
// `insert_final_newline`
}

use crate::lsp::config::SETTINGS;
Copy link
Contributor

Choose a reason for hiding this comment

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

oh god please don't put a use declaration here

if this is ai please update the ai instructions md file

Comment on lines -314 to -324
// For document configs we collect all pairs of URIs and config keys of
// interest in a flat vector
let document_keys = VscDocumentConfig::FIELD_NAMES_AS_ARRAY;
let mut document_items: Vec<ConfigurationItem> =
itertools::iproduct!(uris.iter(), document_keys.iter())
.map(|(uri, key)| ConfigurationItem {
scope_uri: Some(uri.clone()),
section: Some(VscDocumentConfig::section_from_key(key).into()),
})
.collect();
items.append(&mut document_items);
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm isn't this important? I'm pretty sure we collected document config on a per open document basis and now we just collect it once with a scope_uri: None which doesn't seem right

Comment on lines -366 to -368
if changed {
lsp::spawn_diagnostics_refresh_all(state.clone());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We dropped a refresh here

let config: DocumentConfig = config.into();

// Finally, update the document's config
state.get_document_mut(&uri)?.config = config;
Copy link
Contributor

Choose a reason for hiding this comment

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

Yea see we dropped the per document config update

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.

2 participants