-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Feature Request: Custom auto-import order #13960
Comments
The order is currently strictly defined via rust-analyzer/crates/ide-db/src/imports/insert_use.rs Lines 219 to 227 in f1b257f
The main question is how to expose ordering in a config in a decent way |
The config may look like this typescript definition type ImportGroup = "std" | "extern-crate" | "this-crate" | "this-module" | "super-module" | "workspace-crate";
type ImportOrder = ImportGroup[]; // unique elements
const A: ImportOrder = [
"std",
"extern-crate",
"workspace-crate",
"this-crate",
"this-module",
"super-module"
];
const B: ImportOrder = [
"this-module",
"super-module",
"this-crate",
"workspace-crate",
"std",
"extern-crate"
]; |
I also want a fmt tool which can enforce custom import orders. While rustfmt has an unstable option, it still has a number of issues. I would be appreciated if anyone can help with this problem. |
I think what's missing from this is the ability to merge some of them together into a single block. E.g., I would like to combine |
My favour is the following order, sorted by priority.
std
/alloc
/core
itemsHowever, the current auto-import feature enforces a built-in order which I cannot adjust.
https://rust-analyzer.github.io/manual.html#auto-import
It would be better if I don't have to reorder imports manually.
The text was updated successfully, but these errors were encountered: