mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-03 13:23:25 +00:00
update import granularity config and docs
This commit is contained in:
parent
57d4b5bb0f
commit
4f176b3f7f
3 changed files with 11 additions and 4 deletions
|
|
@ -49,6 +49,8 @@ use crate::{AssistContext, AssistId, AssistKind, Assists, GroupLabel};
|
||||||
// - `item`: Don't merge imports at all, creating one import per item.
|
// - `item`: Don't merge imports at all, creating one import per item.
|
||||||
// - `preserve`: Do not change the granularity of any imports. For auto-import this has the same
|
// - `preserve`: Do not change the granularity of any imports. For auto-import this has the same
|
||||||
// effect as `item`.
|
// effect as `item`.
|
||||||
|
// - `one`: Merge all imports into a single use statement as long as they have the same visibility
|
||||||
|
// and attributes.
|
||||||
//
|
//
|
||||||
// In `VS Code` the configuration for this is `rust-analyzer.imports.granularity.group`.
|
// In `VS Code` the configuration for this is `rust-analyzer.imports.granularity.group`.
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -1493,6 +1493,7 @@ impl Config {
|
||||||
ImportGranularityDef::Item => ImportGranularity::Item,
|
ImportGranularityDef::Item => ImportGranularity::Item,
|
||||||
ImportGranularityDef::Crate => ImportGranularity::Crate,
|
ImportGranularityDef::Crate => ImportGranularity::Crate,
|
||||||
ImportGranularityDef::Module => ImportGranularity::Module,
|
ImportGranularityDef::Module => ImportGranularity::Module,
|
||||||
|
ImportGranularityDef::One => ImportGranularity::One,
|
||||||
},
|
},
|
||||||
enforce_granularity: self.data.imports_granularity_enforce,
|
enforce_granularity: self.data.imports_granularity_enforce,
|
||||||
prefix_kind: match self.data.imports_prefix {
|
prefix_kind: match self.data.imports_prefix {
|
||||||
|
|
@ -1933,6 +1934,7 @@ enum ImportGranularityDef {
|
||||||
Item,
|
Item,
|
||||||
Crate,
|
Crate,
|
||||||
Module,
|
Module,
|
||||||
|
One,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, Copy, Clone)]
|
#[derive(Deserialize, Debug, Copy, Clone)]
|
||||||
|
|
@ -2274,12 +2276,13 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json
|
||||||
},
|
},
|
||||||
"ImportGranularityDef" => set! {
|
"ImportGranularityDef" => set! {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["preserve", "crate", "module", "item"],
|
"enum": ["preserve", "crate", "module", "item", "one"],
|
||||||
"enumDescriptions": [
|
"enumDescriptions": [
|
||||||
"Do not change the granularity of any imports and preserve the original structure written by the developer.",
|
"Do not change the granularity of any imports and preserve the original structure written by the developer.",
|
||||||
"Merge imports from the same crate into a single use statement. Conversely, imports from different crates are split into separate statements.",
|
"Merge imports from the same crate into a single use statement. Conversely, imports from different crates are split into separate statements.",
|
||||||
"Merge imports from the same module into a single use statement. Conversely, imports from different modules are split into separate statements.",
|
"Merge imports from the same module into a single use statement. Conversely, imports from different modules are split into separate statements.",
|
||||||
"Flatten imports so that each has its own use statement."
|
"Flatten imports so that each has its own use statement.",
|
||||||
|
"Merge all imports into a single use statement as long as they have the same visibility and attributes."
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"ImportPrefixDef" => set! {
|
"ImportPrefixDef" => set! {
|
||||||
|
|
|
||||||
|
|
@ -1120,13 +1120,15 @@
|
||||||
"preserve",
|
"preserve",
|
||||||
"crate",
|
"crate",
|
||||||
"module",
|
"module",
|
||||||
"item"
|
"item",
|
||||||
|
"one"
|
||||||
],
|
],
|
||||||
"enumDescriptions": [
|
"enumDescriptions": [
|
||||||
"Do not change the granularity of any imports and preserve the original structure written by the developer.",
|
"Do not change the granularity of any imports and preserve the original structure written by the developer.",
|
||||||
"Merge imports from the same crate into a single use statement. Conversely, imports from different crates are split into separate statements.",
|
"Merge imports from the same crate into a single use statement. Conversely, imports from different crates are split into separate statements.",
|
||||||
"Merge imports from the same module into a single use statement. Conversely, imports from different modules are split into separate statements.",
|
"Merge imports from the same module into a single use statement. Conversely, imports from different modules are split into separate statements.",
|
||||||
"Flatten imports so that each has its own use statement."
|
"Flatten imports so that each has its own use statement.",
|
||||||
|
"Merge all imports into a single use statement as long as they have the same visibility and attributes."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"rust-analyzer.imports.group.enable": {
|
"rust-analyzer.imports.group.enable": {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue