about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLukas Wirth <lukastw97@gmail.com>2022-04-29 10:56:32 +0200
committerLukas Wirth <lukastw97@gmail.com>2022-05-01 19:57:09 +0200
commit1f11b70c3bcbdd1481d00344ccf4da9cdca2a572 (patch)
tree4578e40052356b05d0cdf18c367a5f229220c4ee
parent9fe1b24736c8390364d8fdfdb35c6611e29eaf13 (diff)
downloadrust-1f11b70c3bcbdd1481d00344ccf4da9cdca2a572.tar.gz
rust-1f11b70c3bcbdd1481d00344ccf4da9cdca2a572.zip
Final fixups
-rw-r--r--crates/rust-analyzer/src/config.rs21
-rw-r--r--docs/user/generated_config.adoc8
-rw-r--r--editors/code/package.json8
3 files changed, 19 insertions, 18 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index 1af59cfebee..64eb16fbcaa 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -37,6 +37,7 @@ use crate::{
 
 // Conventions for configuration keys to preserve maximal extendability without breakage:
 //  - Toggles (be it binary true/false or with more options in-between) should almost always suffix as `_enable`
+//    This has the benefit of namespaces being extensible, and if the suffix doesn't fit later it can be changed without breakage.
 //  - In general be wary of using the namespace of something verbatim, it prevents us from adding subkeys in the future
 //  - Don't use abbreviations unless really necessary
 //  - foo_command = overrides the subcommand, foo_overrideCommand allows full overwriting, extra args only applies for foo_command
@@ -58,7 +59,7 @@ config_data! {
         /// `Cargo.toml` changes.
         cargo_autoreload: bool           = "true",
         /// Run build scripts (`build.rs`) for more precise code analysis.
-        cargo_buildScripts_enable: bool = "true",
+        cargo_buildScripts_enable: bool  = "true",
         /// Advanced option, fully override the command rust-analyzer uses to
         /// run build scripts and build procedural macros. The command should
         /// include `--message-format=json` or a similar option.
@@ -87,7 +88,7 @@ config_data! {
         checkOnSave_extraArgs: Vec<String>               = "[]",
         /// List of features to activate. Defaults to
         /// `#rust-analyzer.cargo.features#`. Set to `"all"` to pass `--all-features` to cargo.
-        checkOnSave_features: Option<CargoFeatures>        = "null",
+        checkOnSave_features: Option<CargoFeatures>      = "null",
         /// Do not activate the `default` feature.
         checkOnSave_noDefaultFeatures: Option<bool>      = "null",
         /// Advanced option, fully override the command rust-analyzer uses for
@@ -215,13 +216,13 @@ config_data! {
         hover_links_enable: bool = "true",
 
         /// Whether to enforce the import granularity setting for all files. If set to false rust-analyzer will try to keep import styles consistent per file.
-        imports_enforceGranularity: bool              = "false",
+        imports_granularity_enforce: bool              = "false",
         /// How imports should be grouped into use statements.
-        imports_granularity: ImportGranularityDef  = "\"crate\"",
+        imports_granularity_group: ImportGranularityDef  = "\"crate\"",
         /// Group inserted imports by the https://rust-analyzer.github.io/manual.html#auto-import[following order]. Groups are separated by newlines.
-        imports_group: bool                           = "true",
+        imports_group_enable: bool                           = "true",
         /// Whether to allow import insertion to merge new imports into single path glob imports like `use std::fmt::*;`.
-        imports_mergeIntoGlob: bool           = "true",
+        imports_merge_glob: bool           = "true",
         /// The path structure for newly inserted paths to use.
         imports_prefix: ImportPrefixDef               = "\"plain\"",
 
@@ -976,20 +977,20 @@ impl Config {
 
     fn insert_use_config(&self) -> InsertUseConfig {
         InsertUseConfig {
-            granularity: match self.data.imports_granularity {
+            granularity: match self.data.imports_granularity_group {
                 ImportGranularityDef::Preserve => ImportGranularity::Preserve,
                 ImportGranularityDef::Item => ImportGranularity::Item,
                 ImportGranularityDef::Crate => ImportGranularity::Crate,
                 ImportGranularityDef::Module => ImportGranularity::Module,
             },
-            enforce_granularity: self.data.imports_enforceGranularity,
+            enforce_granularity: self.data.imports_granularity_enforce,
             prefix_kind: match self.data.imports_prefix {
                 ImportPrefixDef::Plain => PrefixKind::Plain,
                 ImportPrefixDef::ByCrate => PrefixKind::ByCrate,
                 ImportPrefixDef::BySelf => PrefixKind::BySelf,
             },
-            group: self.data.imports_group,
-            skip_glob_imports: !self.data.imports_mergeIntoGlob,
+            group: self.data.imports_group_enable,
+            skip_glob_imports: !self.data.imports_merge_glob,
         }
     }
 
diff --git a/docs/user/generated_config.adoc b/docs/user/generated_config.adoc
index ab9f7db8847..81bab6fd2d3 100644
--- a/docs/user/generated_config.adoc
+++ b/docs/user/generated_config.adoc
@@ -288,22 +288,22 @@ Whether to show documentation on hover.
 --
 Use markdown syntax for links in hover.
 --
-[[rust-analyzer.imports.enforceGranularity]]rust-analyzer.imports.enforceGranularity (default: `false`)::
+[[rust-analyzer.imports.granularity.enforce]]rust-analyzer.imports.granularity.enforce (default: `false`)::
 +
 --
 Whether to enforce the import granularity setting for all files. If set to false rust-analyzer will try to keep import styles consistent per file.
 --
-[[rust-analyzer.imports.granularity]]rust-analyzer.imports.granularity (default: `"crate"`)::
+[[rust-analyzer.imports.granularity.group]]rust-analyzer.imports.granularity.group (default: `"crate"`)::
 +
 --
 How imports should be grouped into use statements.
 --
-[[rust-analyzer.imports.group]]rust-analyzer.imports.group (default: `true`)::
+[[rust-analyzer.imports.group.enable]]rust-analyzer.imports.group.enable (default: `true`)::
 +
 --
 Group inserted imports by the https://rust-analyzer.github.io/manual.html#auto-import[following order]. Groups are separated by newlines.
 --
-[[rust-analyzer.imports.mergeIntoGlob]]rust-analyzer.imports.mergeIntoGlob (default: `true`)::
+[[rust-analyzer.imports.merge.glob]]rust-analyzer.imports.merge.glob (default: `true`)::
 +
 --
 Whether to allow import insertion to merge new imports into single path glob imports like `use std::fmt::*;`.
diff --git a/editors/code/package.json b/editors/code/package.json
index df5d9b36090..79df7bdf3e4 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -714,12 +714,12 @@
                     "default": true,
                     "type": "boolean"
                 },
-                "rust-analyzer.imports.enforceGranularity": {
+                "rust-analyzer.imports.granularity.enforce": {
                     "markdownDescription": "Whether to enforce the import granularity setting for all files. If set to false rust-analyzer will try to keep import styles consistent per file.",
                     "default": false,
                     "type": "boolean"
                 },
-                "rust-analyzer.imports.granularity": {
+                "rust-analyzer.imports.granularity.group": {
                     "markdownDescription": "How imports should be grouped into use statements.",
                     "default": "crate",
                     "type": "string",
@@ -736,12 +736,12 @@
                         "Flatten imports so that each has its own use statement."
                     ]
                 },
-                "rust-analyzer.imports.group": {
+                "rust-analyzer.imports.group.enable": {
                     "markdownDescription": "Group inserted imports by the [following order](https://rust-analyzer.github.io/manual.html#auto-import). Groups are separated by newlines.",
                     "default": true,
                     "type": "boolean"
                 },
-                "rust-analyzer.imports.mergeIntoGlob": {
+                "rust-analyzer.imports.merge.glob": {
                     "markdownDescription": "Whether to allow import insertion to merge new imports into single path glob imports like `use std::fmt::*;`.",
                     "default": true,
                     "type": "boolean"