-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Feat: "One" import granularity #11361
Comments
This should be called |
Relevant code is mainly here https://github.com/rust-analyzer/rust-analyzer/blob/93036aa0e201474d43c38be3862f4a899defe267/crates/ide_db/src/helpers/insert_use.rs#L155-L193 We also should adjust our guessing infra to be able to understand that form here https://github.com/rust-analyzer/rust-analyzer/blob/93036aa0e201474d43c38be3862f4a899defe267/crates/ide_db/src/helpers/insert_use.rs#L246-L318 And config changes are needed here https://github.com/rust-analyzer/rust-analyzer/blob/93036aa0e201474d43c38be3862f4a899defe267/crates/rust-analyzer/src/config.rs |
can you please assign this issue to me? |
What's the most resilient way to identify the correct ImportGranularityGuess? Looking at the rustfmt implementation, it looks like having merged use trees one for each visibility level is obviously One, but what about mixed cases? What should it guess? |
To identify we probably just want to check if there is only one tree that starts as If mixed it should fall back to Unknown I'd say. |
i was thinking about writing a test that checks for one tree for each of the possible publicity types use { ... };
pub use { ... };
pub(crate) use { ... }; thoughts? |
Sounds good |
Some personal stuff made me quite unproductive in February. Looks like @jeremyBanks is actively working on it, so it's only fair I am un-assigned from this issue |
Koto's been using the `one` import granularity style [1], but this doesn't play well with Rust Analyzer [2] which has made wish for a change, and the `crate` style seems like a decent alternative. [1] https://rust-lang.github.io/rustfmt/?search=#imports_granularity [2] rust-lang/rust-analyzer#11361
Koto's been using the `one` import granularity style [1], but this doesn't play well with Rust Analyzer [2] which has made wish for a change, and the `crate` style seems like a decent alternative. [1] https://rust-lang.github.io/rustfmt/?search=#imports_granularity [2] rust-lang/rust-analyzer#11361
@rustbot claim |
The current options for
rust-analyzer.assist.importGranularity
are "preserve", "crate", "module", and "item". Personally, I group all of my imports into a singleuse
block (and don't really understand why nobody else seems to do so); rust-analyzer should support (enforcing) this grouping along the existinguse
groupings.The text was updated successfully, but these errors were encountered: