mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-29 06:23:25 +00:00
Auto merge of #17346 - ChosenName:master, r=Veykril
Changed package.json so vscode extension settings have submenus There are a lot of options that are a part of rust-analyzer, sometimes it can be hard to find an option that you are looking for. To fix this I have put all configurations into categories based on their names. I have also changed the schema in `crates/rust-analyzer/src/config.rs` to reflect this. Currently for each generated entry the title is redeclared, this does function but I am prepared to change this if it is a problem.
This commit is contained in:
commit
577b0becd0
3 changed files with 2246 additions and 1424 deletions
|
@ -2634,11 +2634,18 @@ fn schema(fields: &[SchemaField]) -> serde_json::Value {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(field, ty, doc, default)| {
|
.map(|(field, ty, doc, default)| {
|
||||||
let name = field.replace('_', ".");
|
let name = field.replace('_', ".");
|
||||||
|
let category =
|
||||||
|
name.find('.').map(|end| String::from(&name[..end])).unwrap_or("general".into());
|
||||||
let name = format!("rust-analyzer.{name}");
|
let name = format!("rust-analyzer.{name}");
|
||||||
let props = field_props(field, ty, doc, default);
|
let props = field_props(field, ty, doc, default);
|
||||||
(name, props)
|
serde_json::json!({
|
||||||
|
"title": category,
|
||||||
|
"properties": {
|
||||||
|
name: props
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.collect::<serde_json::Map<_, _>>();
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
map.into()
|
map.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3037,8 +3044,8 @@ mod tests {
|
||||||
let s = Config::json_schema();
|
let s = Config::json_schema();
|
||||||
let schema = format!("{s:#}");
|
let schema = format!("{s:#}");
|
||||||
let mut schema = schema
|
let mut schema = schema
|
||||||
.trim_start_matches('{')
|
.trim_start_matches('[')
|
||||||
.trim_end_matches('}')
|
.trim_end_matches(']')
|
||||||
.replace(" ", " ")
|
.replace(" ", " ")
|
||||||
.replace('\n', "\n ")
|
.replace('\n', "\n ")
|
||||||
.trim_start_matches('\n')
|
.trim_start_matches('\n')
|
||||||
|
@ -3072,8 +3079,10 @@ mod tests {
|
||||||
let package_json_path = project_root().join("editors/code/package.json");
|
let package_json_path = project_root().join("editors/code/package.json");
|
||||||
let mut package_json = fs::read_to_string(&package_json_path).unwrap();
|
let mut package_json = fs::read_to_string(&package_json_path).unwrap();
|
||||||
|
|
||||||
let start_marker = " \"$generated-start\": {},\n";
|
let start_marker =
|
||||||
let end_marker = " \"$generated-end\": {}\n";
|
" {\n \"title\": \"$generated-start\"\n },\n";
|
||||||
|
let end_marker =
|
||||||
|
" {\n \"title\": \"$generated-end\"\n }\n";
|
||||||
|
|
||||||
let start = package_json.find(start_marker).unwrap() + start_marker.len();
|
let start = package_json.find(start_marker).unwrap() + start_marker.len();
|
||||||
let end = package_json.find(end_marker).unwrap();
|
let end = package_json.find(end_marker).unwrap();
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -70,8 +70,11 @@ fn dist_client(
|
||||||
&format!(r#""version": "{version}""#),
|
&format!(r#""version": "{version}""#),
|
||||||
)
|
)
|
||||||
.replace(r#""releaseTag": null"#, &format!(r#""releaseTag": "{release_tag}""#))
|
.replace(r#""releaseTag": null"#, &format!(r#""releaseTag": "{release_tag}""#))
|
||||||
.replace(r#""$generated-start": {},"#, "")
|
.replace(
|
||||||
.replace(",\n \"$generated-end\": {}", "")
|
" {\n \"title\": \"$generated-start\"\n },\n",
|
||||||
|
"",
|
||||||
|
)
|
||||||
|
.replace(" { \"title\": \"$generated-end\" }\n", "")
|
||||||
.replace(r#""enabledApiProposals": [],"#, r#""#);
|
.replace(r#""enabledApiProposals": [],"#, r#""#);
|
||||||
patch.commit(sh)?;
|
patch.commit(sh)?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue