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

chore: use rustfmt cli via dprint for faster format #13735

Merged
merged 1 commit into from
Feb 21, 2022

Conversation

dsherret
Copy link
Member

@dsherret dsherret commented Feb 21, 2022

This PR uses dprint to orchestrate formatting via rustfmt.

Before: 6384ms
After: 932ms (3677ms on the first format or with incremental disabled)

I think part of the previous ~2.5 slowdown was from collecting the file paths. Dprint's CLI has a super fast custom glob walking solution.

@@ -9,8 +9,12 @@
"json": {
"deno": true
},
"exec": {
"associations": "**/*.rs",
"rustfmt": "rustfmt"
Copy link
Member Author

@dsherret dsherret Feb 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exec plugin has no knowledge of rustfmt until being provided it here. This makes it call the rustfmt cli and format over stdin.

https://github.com/dprint/dprint-plugin-exec#configuration

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@lucacasonato lucacasonato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool!

@dsherret
Copy link
Member Author

A nice side effect is that now rust files get automatically formatted on save if using dprint's vscode extension.

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

Successfully merging this pull request may close these issues.

3 participants