Skip to content

[Tracking] swayfmt-v2 MVP #1516

@eureka-cpu

Description

@eureka-cpu

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

Metadata

Metadata

Labels

bigthis task is hard and will take a whileformatter

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions