Skip to content

Commit 1f11b70

Browse files
committed
Final fixups
1 parent 9fe1b24 commit 1f11b70

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

crates/rust-analyzer/src/config.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ use crate::{
3737

3838
// Conventions for configuration keys to preserve maximal extendability without breakage:
3939
// - Toggles (be it binary true/false or with more options in-between) should almost always suffix as `_enable`
40+
// This has the benefit of namespaces being extensible, and if the suffix doesn't fit later it can be changed without breakage.
4041
// - In general be wary of using the namespace of something verbatim, it prevents us from adding subkeys in the future
4142
// - Don't use abbreviations unless really necessary
4243
// - foo_command = overrides the subcommand, foo_overrideCommand allows full overwriting, extra args only applies for foo_command
@@ -58,7 +59,7 @@ config_data! {
5859
/// `Cargo.toml` changes.
5960
cargo_autoreload: bool = "true",
6061
/// Run build scripts (`build.rs`) for more precise code analysis.
61-
cargo_buildScripts_enable: bool = "true",
62+
cargo_buildScripts_enable: bool = "true",
6263
/// Advanced option, fully override the command rust-analyzer uses to
6364
/// run build scripts and build procedural macros. The command should
6465
/// include `--message-format=json` or a similar option.
@@ -87,7 +88,7 @@ config_data! {
8788
checkOnSave_extraArgs: Vec<String> = "[]",
8889
/// List of features to activate. Defaults to
8990
/// `#rust-analyzer.cargo.features#`. Set to `"all"` to pass `--all-features` to cargo.
90-
checkOnSave_features: Option<CargoFeatures> = "null",
91+
checkOnSave_features: Option<CargoFeatures> = "null",
9192
/// Do not activate the `default` feature.
9293
checkOnSave_noDefaultFeatures: Option<bool> = "null",
9394
/// Advanced option, fully override the command rust-analyzer uses for
@@ -215,13 +216,13 @@ config_data! {
215216
hover_links_enable: bool = "true",
216217

217218
/// 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.
218-
imports_enforceGranularity: bool = "false",
219+
imports_granularity_enforce: bool = "false",
219220
/// How imports should be grouped into use statements.
220-
imports_granularity: ImportGranularityDef = "\"crate\"",
221+
imports_granularity_group: ImportGranularityDef = "\"crate\"",
221222
/// Group inserted imports by the https://rust-analyzer.github.io/manual.html#auto-import[following order]. Groups are separated by newlines.
222-
imports_group: bool = "true",
223+
imports_group_enable: bool = "true",
223224
/// Whether to allow import insertion to merge new imports into single path glob imports like `use std::fmt::*;`.
224-
imports_mergeIntoGlob: bool = "true",
225+
imports_merge_glob: bool = "true",
225226
/// The path structure for newly inserted paths to use.
226227
imports_prefix: ImportPrefixDef = "\"plain\"",
227228

@@ -976,20 +977,20 @@ impl Config {
976977

977978
fn insert_use_config(&self) -> InsertUseConfig {
978979
InsertUseConfig {
979-
granularity: match self.data.imports_granularity {
980+
granularity: match self.data.imports_granularity_group {
980981
ImportGranularityDef::Preserve => ImportGranularity::Preserve,
981982
ImportGranularityDef::Item => ImportGranularity::Item,
982983
ImportGranularityDef::Crate => ImportGranularity::Crate,
983984
ImportGranularityDef::Module => ImportGranularity::Module,
984985
},
985-
enforce_granularity: self.data.imports_enforceGranularity,
986+
enforce_granularity: self.data.imports_granularity_enforce,
986987
prefix_kind: match self.data.imports_prefix {
987988
ImportPrefixDef::Plain => PrefixKind::Plain,
988989
ImportPrefixDef::ByCrate => PrefixKind::ByCrate,
989990
ImportPrefixDef::BySelf => PrefixKind::BySelf,
990991
},
991-
group: self.data.imports_group,
992-
skip_glob_imports: !self.data.imports_mergeIntoGlob,
992+
group: self.data.imports_group_enable,
993+
skip_glob_imports: !self.data.imports_merge_glob,
993994
}
994995
}
995996

docs/user/generated_config.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,22 +288,22 @@ Whether to show documentation on hover.
288288
--
289289
Use markdown syntax for links in hover.
290290
--
291-
[[rust-analyzer.imports.enforceGranularity]]rust-analyzer.imports.enforceGranularity (default: `false`)::
291+
[[rust-analyzer.imports.granularity.enforce]]rust-analyzer.imports.granularity.enforce (default: `false`)::
292292
+
293293
--
294294
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.
295295
--
296-
[[rust-analyzer.imports.granularity]]rust-analyzer.imports.granularity (default: `"crate"`)::
296+
[[rust-analyzer.imports.granularity.group]]rust-analyzer.imports.granularity.group (default: `"crate"`)::
297297
+
298298
--
299299
How imports should be grouped into use statements.
300300
--
301-
[[rust-analyzer.imports.group]]rust-analyzer.imports.group (default: `true`)::
301+
[[rust-analyzer.imports.group.enable]]rust-analyzer.imports.group.enable (default: `true`)::
302302
+
303303
--
304304
Group inserted imports by the https://rust-analyzer.github.io/manual.html#auto-import[following order]. Groups are separated by newlines.
305305
--
306-
[[rust-analyzer.imports.mergeIntoGlob]]rust-analyzer.imports.mergeIntoGlob (default: `true`)::
306+
[[rust-analyzer.imports.merge.glob]]rust-analyzer.imports.merge.glob (default: `true`)::
307307
+
308308
--
309309
Whether to allow import insertion to merge new imports into single path glob imports like `use std::fmt::*;`.

editors/code/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -714,12 +714,12 @@
714714
"default": true,
715715
"type": "boolean"
716716
},
717-
"rust-analyzer.imports.enforceGranularity": {
717+
"rust-analyzer.imports.granularity.enforce": {
718718
"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.",
719719
"default": false,
720720
"type": "boolean"
721721
},
722-
"rust-analyzer.imports.granularity": {
722+
"rust-analyzer.imports.granularity.group": {
723723
"markdownDescription": "How imports should be grouped into use statements.",
724724
"default": "crate",
725725
"type": "string",
@@ -736,12 +736,12 @@
736736
"Flatten imports so that each has its own use statement."
737737
]
738738
},
739-
"rust-analyzer.imports.group": {
739+
"rust-analyzer.imports.group.enable": {
740740
"markdownDescription": "Group inserted imports by the [following order](https://rust-analyzer.github.io/manual.html#auto-import). Groups are separated by newlines.",
741741
"default": true,
742742
"type": "boolean"
743743
},
744-
"rust-analyzer.imports.mergeIntoGlob": {
744+
"rust-analyzer.imports.merge.glob": {
745745
"markdownDescription": "Whether to allow import insertion to merge new imports into single path glob imports like `use std::fmt::*;`.",
746746
"default": true,
747747
"type": "boolean"

0 commit comments

Comments
 (0)