Skip to content

Commit

Permalink
Auto merge of rust-lang#17346 - ChosenName:master, r=Veykril
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Jun 6, 2024
2 parents b8e94dd + ca07bf2 commit 56a298b
Show file tree
Hide file tree
Showing 3 changed files with 2,237 additions and 1,415 deletions.
21 changes: 15 additions & 6 deletions src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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();
Expand Down
Loading

0 comments on commit 56a298b

Please sign in to comment.