-
Notifications
You must be signed in to change notification settings - Fork 17
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
Project's current formatting makes it hard to contribute non-trivial changes #24
Comments
You are correct! I need to merge the |
As long as there's a corresponding |
You can use a nightly rustfmt config values in a rust-stable codebase by sticking
|
@mkatychev Thanks for the suggestion. I'll get to it once I get a chance to merge the BYODS work. |
@s-arash it looks like the BYODS work got merged in the meanwhile. Any update on this? |
This is a bit ancillary but you can also define your own formatting rules using topiary as well, there's rust support under the hood but this specifically allows one to apply custom formatting for ascent grammar through s-expressions: I've been working on a formatter for OpenSCAD using topiary with great success and have been meaning to finish https://github.com/mkatychev/tree-sitter-ascent sometime this month: |
Thanks for the reminder @regexident! I'll get to it soon. |
Very cool @mkatychev, good luck! |
Thanks for taking care of this @s-arash! 🙏 I can't reproduce the formatting on my side though, which was the main goal of is issue, so I'd be hesitant to call it resolved just yet. 😕 When I run
If I run
This is the Rust setup I'm running the above in:
|
Thanks @regexident. I've fixed those. Can you check again? |
Given that Better yet: make {
"editor.formatOnSave": true,
"rust-analyzer.linkedProjects": [
"./ascent/Cargo.toml",
"./ascent_macro_tests/Cargo.toml", // excluded in workspace
"./ascent_tests/Cargo.toml", // excluded in workspace
"./wasm-tests/Cargo.toml" // excluded in workspace
],
"rust-analyzer.rustfmt.extraArgs": ["+nightly"]
}
(not sure what's the equivalent for RustRover) |
FYI, I've just updated my open PRs with the new formatting. Would appreciate if you could take a look some time. |
The project's current code formatting suffers from a couple of issues, affect:
tl;dr: For the sake of making contributions hassle-free it would arguably be preferable to revert to Rust's default format (as applied by
rustfmt
without a customrustfmt.toml
file) and used by >90% of Rust projects.It uses a non-standard format
The Rust project recommends using the default formatting configuration to ease collaboration.
It provides a custom
rustfmt.toml
file but doesn't actually use itWhile the project provides a
rustfmt.toml
file./rustfmt.toml
Running
cargo fmt
results in 30+ reformatted files, which should not happen if the code had previously been formatted with it.As such it is currently impossible to have
rustfmt
/cargo fmt
apply the same formatting as used by the project. And anybody opening a PR on the project gets a nasty surprise when they notice that their IDE auto-formatted the code (as is usually desirable) and now the semantic changes are lost in thousands of formatting changes (as it just happened to me, again).The
rustfmt.toml
file requiresnightly
and is also invalidFurther more running
cargo fmt
results in a bunch of warnings:The project mixes CRLF and LF
The text was updated successfully, but these errors were encountered: