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
Added foundation for sway-fmt
v2
#1425
Conversation
sway-fmt
v2sway-fmt
v2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting close!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only things left are:
- Change version to
0.0.0
. - Add
publish = false
flag in favour of eventually publishing assway-fmt
when it's ready.
After these I'm happy to approve!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥳
The design of
rustfmt
is to leave code functionality in tact, but also do more than just move white space. For instance, long generic parameters can be cleaned up with awhere
clause addition and formatting of those parameters after it. I think that's a really great characteristic that keeps code uniform and even teaches users the standard practices.It uses an
AST
for most of the formatting, but for macros it uses tokens or otherwise leaves them untouched. Most macros aren't formatted, unless necessary like theformat!
macro since it takes in variables that result in aString
.rustfmt
can recognize when something won't benefit from being formatted and opts that portion of the code out of the formatting process. If code doesn't fit the conditions of what would need formatting, e.g. a user created diagram, then it will just leave it alone.swayfmt
's goal is to be somewhat transparent. It should format Sway code to our standards, and if the user so decides it, they can add aswayfmt.toml
to their root dir and it will assume only the changes present, and leave the rest to default.Tracking further development: #1516