From 262fcfbc580d0fe1dd127b8e0a9a12d65cd8107a Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 19 May 2025 08:40:59 +0200 Subject: [PATCH] Change import prefix default to be by crate The current default plain, tends to create non-uniform import blocks over time, some being relative, some being absolute. I believe we should encourage a different default here. --- crates/rust-analyzer/src/config.rs | 2 +- docs/book/src/configuration_generated.md | 2 +- editors/code/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 03e5b1f6f4..f7158235ca 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -544,7 +544,7 @@ config_data! { /// Whether to prefer import paths containing a `prelude` module. imports_preferPrelude: bool = false, /// The path structure for newly inserted paths to use. - imports_prefix: ImportPrefixDef = ImportPrefixDef::Plain, + imports_prefix: ImportPrefixDef = ImportPrefixDef::ByCrate, /// Whether to prefix external (including std, core) crate imports with `::`. e.g. "use ::std::io::Read;". imports_prefixExternPrelude: bool = false, } diff --git a/docs/book/src/configuration_generated.md b/docs/book/src/configuration_generated.md index 2ae73df61d..de1d0ea4a3 100644 --- a/docs/book/src/configuration_generated.md +++ b/docs/book/src/configuration_generated.md @@ -835,7 +835,7 @@ Whether to prefer import paths containing a `prelude` module. ## rust-analyzer.imports.prefix {#imports.prefix} -Default: `"plain"` +Default: `"crate"` The path structure for newly inserted paths to use. diff --git a/editors/code/package.json b/editors/code/package.json index a282eea999..88a90aad8c 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -1927,7 +1927,7 @@ "properties": { "rust-analyzer.imports.prefix": { "markdownDescription": "The path structure for newly inserted paths to use.", - "default": "plain", + "default": "crate", "type": "string", "enum": [ "plain",