mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +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()
|
||||
.map(|(field, ty, doc, default)| {
|
||||
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 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()
|
||||
}
|
||||
|
||||
|
@ -3037,8 +3044,8 @@ mod tests {
|
|||
let s = Config::json_schema();
|
||||
let schema = format!("{s:#}");
|
||||
let mut schema = schema
|
||||
.trim_start_matches('{')
|
||||
.trim_end_matches('}')
|
||||
.trim_start_matches('[')
|
||||
.trim_end_matches(']')
|
||||
.replace(" ", " ")
|
||||
.replace('\n', "\n ")
|
||||
.trim_start_matches('\n')
|
||||
|
@ -3072,8 +3079,10 @@ mod tests {
|
|||
let package_json_path = project_root().join("editors/code/package.json");
|
||||
let mut package_json = fs::read_to_string(&package_json_path).unwrap();
|
||||
|
||||
let start_marker = " \"$generated-start\": {},\n";
|
||||
let end_marker = " \"$generated-end\": {}\n";
|
||||
let start_marker =
|
||||
" {\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 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}""#),
|
||||
)
|
||||
.replace(r#""releaseTag": null"#, &format!(r#""releaseTag": "{release_tag}""#))
|
||||
.replace(r#""$generated-start": {},"#, "")
|
||||
.replace(",\n \"$generated-end\": {}", "")
|
||||
.replace(
|
||||
" {\n \"title\": \"$generated-start\"\n },\n",
|
||||
"",
|
||||
)
|
||||
.replace(" { \"title\": \"$generated-end\" }\n", "")
|
||||
.replace(r#""enabledApiProposals": [],"#, r#""#);
|
||||
patch.commit(sh)?;
|
||||
|
||||
|
|
Loading…
Reference in a new issue