Skip to content
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

group_imports option to remove grouping #4962

Closed
Heliozoa opened this issue Aug 22, 2021 · 2 comments
Closed

group_imports option to remove grouping #4962

Heliozoa opened this issue Aug 22, 2021 · 2 comments

Comments

@Heliozoa
Copy link
Contributor

Hi,
thanks a lot for your work on rustfmt. I would like to have an option to always put all imports into a single group. I tried looking for an existing issue but I might have missed one

use self::some_mod::SomeStruct;

use crate::my_module;

use diesel::prelude::*;

use rocket::serde::json::Json;

use std::env;

use uuid::Uuid;

would format to

use self::some_mod::SomeStruct;
use crate::my_module;
use diesel::prelude::*;
use rocket::serde::json::Json;
use std::env;
use uuid::Uuid;

The rationale is that I like the idea of rustfmt enforcing the grouping, but find it nicer to have them all together, ordered inside the group the way rustfmt currently does it.

If this is something that could be added to rustfmt, I could take a look at making a PR. At a glance it looks like I could just follow the implementation of the StdExternalCrate option and it wouldn't be too difficult.

As for the name, maybe something like "Together"?

group_imports = "Together"
@Heliozoa Heliozoa changed the title group_imports option to remove grouping group_imports option to remove grouping Aug 22, 2021
@Heliozoa
Copy link
Contributor Author

I was going to close the issue since the PR was merged but I noticed the 2x port pending tag. What would be involved in implementing that? Does it just refer to compatibility with version = Two?

@calebcartwright
Copy link
Member

I was going to close the issue since the PR was merged but I noticed the 2x port pending tag. What would be involved in implementing that? Does it just refer to compatibility with version = Two?

Thanks for the question. The port labels are primarily for the rustfmt team to help us deal with some branch-related management activities. I'm going to go ahead and close this given that your PR has been merged, thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants