Merge #3845
3845: Simplify config r=matklad a=Veetaha Co-authored-by: veetaha <veetaha2@gmail.com>
This commit is contained in:
commit
2071d0b827
@ -120,12 +120,10 @@ pub fn update(&mut self, value: &serde_json::Value) {
|
|||||||
set(value, "/withSysroot", &mut self.with_sysroot);
|
set(value, "/withSysroot", &mut self.with_sysroot);
|
||||||
set(value, "/featureFlags/lsp.diagnostics", &mut self.publish_diagnostics);
|
set(value, "/featureFlags/lsp.diagnostics", &mut self.publish_diagnostics);
|
||||||
set(value, "/lruCapacity", &mut self.lru_capacity);
|
set(value, "/lruCapacity", &mut self.lru_capacity);
|
||||||
if let Some(watcher) = get::<String>(value, "/files/watcher") {
|
self.files.watcher = match get(value, "/files/watcher") {
|
||||||
self.files.watcher = match watcher.as_str() {
|
Some("client") => FilesWatcher::Client,
|
||||||
"client" => FilesWatcher::Client,
|
Some("notify") | _ => FilesWatcher::Notify
|
||||||
"notify"| _ => FilesWatcher::Notify,
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
set(value, "/notifications/workspaceLoaded", &mut self.notifications.workspace_loaded);
|
set(value, "/notifications/workspaceLoaded", &mut self.notifications.workspace_loaded);
|
||||||
set(value, "/notifications/cargoTomlNotFound", &mut self.notifications.cargo_toml_not_found);
|
set(value, "/notifications/cargoTomlNotFound", &mut self.notifications.cargo_toml_not_found);
|
||||||
|
|
||||||
@ -144,8 +142,9 @@ pub fn update(&mut self, value: &serde_json::Value) {
|
|||||||
} else if let RustfmtConfig::Rustfmt { extra_args } = &mut self.rustfmt {
|
} else if let RustfmtConfig::Rustfmt { extra_args } = &mut self.rustfmt {
|
||||||
set(value, "/rustfmt/extraArgs", extra_args);
|
set(value, "/rustfmt/extraArgs", extra_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(false) = get(value, "/checkOnSave/enable") {
|
if let Some(false) = get(value, "/checkOnSave/enable") {
|
||||||
self.check = None
|
self.check = None;
|
||||||
} else {
|
} else {
|
||||||
if let Some(mut args) = get::<Vec<String>>(value, "/checkOnSave/overrideCommand") {
|
if let Some(mut args) = get::<Vec<String>>(value, "/checkOnSave/overrideCommand") {
|
||||||
if !args.is_empty() {
|
if !args.is_empty() {
|
||||||
@ -153,7 +152,7 @@ pub fn update(&mut self, value: &serde_json::Value) {
|
|||||||
self.check = Some(FlycheckConfig::CustomCommand {
|
self.check = Some(FlycheckConfig::CustomCommand {
|
||||||
command,
|
command,
|
||||||
args,
|
args,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets }) = &mut self.check
|
} else if let Some(FlycheckConfig::CargoCommand { command, extra_args, all_targets }) = &mut self.check
|
||||||
@ -179,7 +178,7 @@ fn get<'a, T: Deserialize<'a>>(value: &'a serde_json::Value, pointer: &str) -> O
|
|||||||
value.pointer(pointer).and_then(|it| T::deserialize(it).ok())
|
value.pointer(pointer).and_then(|it| T::deserialize(it).ok())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set<'a, T: Deserialize<'a> + std::fmt::Debug>(value: &'a serde_json::Value, pointer: &str, slot: &mut T) {
|
fn set<'a, T: Deserialize<'a>>(value: &'a serde_json::Value, pointer: &str, slot: &mut T) {
|
||||||
if let Some(new_value) = get(value, pointer) {
|
if let Some(new_value) = get(value, pointer) {
|
||||||
*slot = new_value
|
*slot = new_value
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user