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

[Tracking] swayfmt-v2 MVP #1516

Closed
eureka-cpu opened this issue May 10, 2022 · 3 comments · Fixed by #2669
Closed

[Tracking] swayfmt-v2 MVP #1516

eureka-cpu opened this issue May 10, 2022 · 3 comments · Fixed by #2669
Assignees
Labels
big this task is hard and will take a while formatter
Milestone

Comments

@eureka-cpu
Copy link
Contributor

eureka-cpu commented May 10, 2022

Tracking for the new formatter:

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.

Please feel free to hop in and take on some of this if it interests you:

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.

Once completed add to CI documentor: #1806

@adlerjohn adlerjohn added the big this task is hard and will take a while label May 10, 2022
@adlerjohn adlerjohn moved this to Todo in Fuel Network May 10, 2022
@mitchmindtree
Copy link
Contributor

Excited for this work @eureka-cpu !

I'll just add that we should really avoid emphasizing that swayfmt.toml exists at all until it gets pulled out of us.

I think it will be useful for development of the formatter (e.g. trying different combinations of configuration while we bikeshed over "the way" to do things), but we should avoid having users use or depend on swayfmt.toml at all until we're really sure we want to support the can of worms that is custom code formatting, especally when we likely want to encourage uniformity in styling across all sway projects.

This was discussed briefly in #605.

@eureka-cpu
Copy link
Contributor Author

Excited for this work @eureka-cpu !

I'll just add that we should really avoid emphasizing that swayfmt.toml exists at all until it gets pulled out of us.

I think it will be useful for development of the formatter (e.g. trying different combinations of configuration while we bikeshed over "the way" to do things), but we should avoid having users use or depend on swayfmt.toml at all until we're really sure we want to support the can of worms that is custom code formatting, especally when we likely want to encourage uniformity in styling across all sway projects.

This was discussed briefly in #605.

Absolutely agree, currently what is on the branch is exactly in this vein ! The toml doesn't get created automatically, but you can optionally include one and it will replace values if they exist.

@kayagokalp
Copy link
Member

kayagokalp commented Jun 6, 2022

I started to work on handling enums (#1873).

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 formatter
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants