VSCode settings import refactor (#40513)

A small follow-up to the settings refactor of a few weeks ago to move
all the VSCode settings imports
to one place.

This should make it easier to spot missing imports, and easier to test
the importer.

Release Notes:

- N/A
This commit is contained in:
Conrad Irwin
2025-10-17 17:47:05 +00:00
committed by GitHub
parent 62858f6a5c
commit 1fbe1e3512
19 changed files with 774 additions and 924 deletions
-6
View File
@@ -985,12 +985,6 @@ impl settings::Settings for DisableAiSettings {
disable_ai: content.disable_ai.unwrap().0,
}
}
fn import_from_vscode(
_vscode: &settings::VsCodeSettings,
_current: &mut settings::SettingsContent,
) {
}
}
impl Project {
-59
View File
@@ -522,65 +522,6 @@ impl Settings for ProjectSettings {
},
}
}
fn import_from_vscode(
vscode: &settings::VsCodeSettings,
current: &mut settings::SettingsContent,
) {
// this just sets the binary name instead of a full path so it relies on path lookup
// resolving to the one you want
let npm_path = vscode.read_enum("npm.packageManager", |s| match s {
v @ ("npm" | "yarn" | "bun" | "pnpm") => Some(v.to_owned()),
_ => None,
});
if npm_path.is_some() {
current.node.get_or_insert_default().npm_path = npm_path;
}
if let Some(b) = vscode.read_bool("git.blame.editorDecoration.enabled") {
current
.git
.get_or_insert_default()
.inline_blame
.get_or_insert_default()
.enabled = Some(b);
}
#[derive(Deserialize)]
struct VsCodeContextServerCommand {
command: PathBuf,
args: Option<Vec<String>>,
env: Option<HashMap<String, String>>,
// note: we don't support envFile and type
}
if let Some(mcp) = vscode.read_value("mcp").and_then(|v| v.as_object()) {
current
.project
.context_servers
.extend(mcp.iter().filter_map(|(k, v)| {
Some((
k.clone().into(),
settings::ContextServerSettingsContent::Custom {
enabled: true,
command: serde_json::from_value::<VsCodeContextServerCommand>(
v.clone(),
)
.ok()
.map(|cmd| {
settings::ContextServerCommand {
path: cmd.command,
args: cmd.args.unwrap_or_default(),
env: cmd.env,
timeout: None,
}
})?,
},
))
}));
}
// TODO: translate lsp settings for rust-analyzer and other popular ones to old.lsp
}
}
pub enum SettingsObserverMode {