Skip to content

Improve settings tree title and descriptions #20154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

joshka
Copy link
Contributor

@joshka joshka commented Jul 3, 2025

  • All settings are now phrased in the imperative form stating what the
    setting does rather than talking about what it controls. (E.g.:
    "Show Debug action." instead of "Whether to show Debug action"
  • Categories are now displayed in title case
  • Categories are now sorted lexicographically
  • General category is removed (and all the settings are moved to the top
    level)
  • Language for a few descriptions is made a bit less ambiguous

Before:
image
After:
image

- All settings are now phrased in the imperative form stating what the
  setting does rather than talking about what it controls. (E.g.:
  "Show `Debug` action." instead of "Whether to show `Debug` action"
- Categories are now displayed in title case
- Categories are now sorted lexicographically
- General category is removed (and all the settings are moved to the top
  level)
- Language for a few descriptions is made a bit less ambiguous
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 3, 2025
Copy link
Contributor Author

@joshka joshka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-review comments to help navigate this change.

For any comments about the description changes, please make these in config.rs rather than the generated files to make it easier to address (except for the non-generated parts of package.json).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No manual changes made to this doc - purely generated by running cargo test

Comment on lines 355 to +366
"configuration": [
{
"title": "general",
"title": "Rust Analyzer"
},
{
"title": "Assist"
},
{
"title": "Cache Priming"
},
{
"title": "Cargo"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part forces the categories to be ordered lexicographically. Otherwise they are ordered based the order which they appear in the file. It's possible that this was intentional, in which case I'd remove these lines.

"title": "Workspace"
},
{
"title": "rust-analyzer",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this category title from "general" to "rust-analyzer" makes this appear at the top level of the settings instead of having an unnecessary category.

Comment on lines -360 to +447
"markdownDescription": "Whether to restart the server automatically when certain settings that require a restart are changed.",
"description": "Restart the server automatically when settings that require a restart are changed.",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

markdownDescription is only needed when there's markdown.
I left it there for the generated descriptions to avoid having to detect whether there's markdown or not

Comment on lines -656 to +743
"title": "assist",
"title": "Assist",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below this point, all the changes are generated from config.rs. There are no manual changes to this file below here. The changes are generally:

  • category name is title case
  • description is imperative

Comment on lines -64 to +65
// Defines the server-side configuration of the rust-analyzer. We generate
// *parts* of VS Code's `package.json` config from this. Run `cargo test` to
// re-generate that file.
// Defines the server-side configuration of the rust-analyzer. We generate *parts* of VS Code's
// `package.json` config from this. Run `cargo test` to re-generate that file.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, Ive wrapped these at 100 chars as the changes were otherwise difficult to read at times with various wrap points across each item. I've also put a single blank line between each item instead of 0-3, this makes it easier to read as the comment is more obviously grouped with the following item rather than the previous.

I also removed the vertically aligned defaults ( = true etc.), as this formatting doesn't appear elsewhere in the source code and doesn't make the values easier to read.

// To deprecate an option by replacing it with another name use `new_name` | `old_name` so that we keep
// parsing the old name.
// To deprecate an option by replacing it with another name use `new_name` | `old_name` so that we
// keep parsing the old name.
config_data! {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in this are to:

  • comments - wording etc.
  • spacing - consistent wrapping etc.

The generated code doesn't care too much about single newlines, only double newlines like standard markdown.

let category = name
.split_once(".")
.map(|(category, _name)| to_title_case(category))
.unwrap_or("rust-analyzer".into());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defaut changed to put all non-grouped settings at the top level instead of under a "General" category. (Casing is important here, it has to match the case of the extension display name.)

name.find('.').map(|end| String::from(&name[..end])).unwrap_or("general".into());
let category = name
.split_once(".")
.map(|(category, _name)| to_title_case(category))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generated category names are now title case

Comment on lines +3366 to +3368
/// This likely should be in stdx (or just use heck instead), but it doesn't handle any edge cases
/// and is intentionally simple.
fn to_title_case(s: &str) -> String {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm inclined to leave this method here rather than extracting it to something more general. If someone wants to make it more useful, performant etc., then that's fine, but for now it's usefullness is this one use case.

I also don't really care too much about the impl here as it's dev time code. It's likely there's edge cases a more general function would have to catch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants