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

Added foundation for sway-fmt v2 #1425

Merged
merged 55 commits into from May 19, 2022
Merged

Added foundation for sway-fmt v2 #1425

merged 55 commits into from May 19, 2022

Conversation

eureka-cpu
Copy link
Contributor

@eureka-cpu eureka-cpu commented Apr 28, 2022

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 a where 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 the format! macro since it takes in variables that result in a String.

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 a swayfmt.toml to their root dir and it will assume only the changes present, and leave the rest to default.

Tracking further development: #1516

@eureka-cpu eureka-cpu self-assigned this Apr 28, 2022
@eureka-cpu eureka-cpu changed the title Added skeleton for sway-fmt v2 Added foundation for sway-fmt v2 Apr 28, 2022
Copy link
Contributor

@mitchmindtree mitchmindtree left a comment

Choose a reason for hiding this comment

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

Getting close!

sway-fmt-v2/src/config/manifest.rs Outdated Show resolved Hide resolved
sway-fmt-v2/src/config/expr.rs Show resolved Hide resolved
sway-fmt-v2/src/config/manifest.rs Outdated Show resolved Hide resolved
@eureka-cpu eureka-cpu marked this pull request as ready for review May 17, 2022 01:09
sway-fmt-v2/Cargo.toml Outdated Show resolved Hide resolved
sway-fmt-v2/Cargo.toml Show resolved Hide resolved
Copy link
Contributor

@mitchmindtree mitchmindtree left a 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 as sway-fmt when it's ready.

After these I'm happy to approve!

.gitignore Outdated Show resolved Hide resolved
mitchmindtree
mitchmindtree previously approved these changes May 18, 2022
Copy link
Contributor

@mitchmindtree mitchmindtree left a comment

Choose a reason for hiding this comment

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

🥳

@eureka-cpu eureka-cpu merged commit 266f580 into master May 19, 2022
@eureka-cpu eureka-cpu deleted the eureka-cpu/sway-fmt branch May 19, 2022 02:37
@eureka-cpu eureka-cpu added this to the `swayfmt-v2` milestone Jun 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
big this task is hard and will take a while forc formatter
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Review approach to parsing in sway-fmt Formatter configuration file
5 participants