Closed Ben-Lichtman closed 1 year ago
The other option is to disable rustfmt project-wide with disable_all_formatting in the .rustfmt.toml, though I'd suggest that it's better to pick a suboptimal style rather than ad-hoc style chosen by contributors
I would PR this, but it would be difficult to review due to the large number of changes, so I'll leave it up to the maintainer to push a version with cargo fmt
run on it
Thanks for your consideration! I've been working on implementing a rustfmt policy that I can stomach.
I'm not a fan of autoformatters in general as they tend to make everything look consistently ugly.
But with some okay settings, a nightly rustfmt, refactoring some code and liberal application of rustfmt::skip
I think I can make it work.
I'll try to get a PR up in a few more hours.
Good lord I just noticed rustfmt rewrote everything to lf which conflicts with my windows checkout and usage of autocrlf setting... I'll try to keep going and get the repo to cleanly pass rustfmt but rustfmt is just not ready for actual usage...
You can adjust this with the newline_style setting.
Looks like the default is "auto" though which tries to use whatever that file already uses, so your file probably already had a LF present.
I can confirm that this is not the case, all files changed by cargo +nightly fmt
(idk if nightly matters here) are changed from crlf to lf. Look like it is an open bug in rustfmt: https://github.com/rust-lang/rustfmt/issues/4097
Some git magic later it's all fixed but these are the kind of rough edges that confirm my biases against rustfmt 😛
It took some time but it's there
I'd like to contribute to this project, however it seems like the style is mostly ad-hoc and rustfmt is not being used for the most part?
I propose adding a .rustfmt.toml to the root of the project to ensure that contribution style is consistent, then running
cargo fmt
on the repo to format the code.I've tried to come up with a
.rustfmt.toml
which is minimally imactful while still providing some benefits:Unfortunately this still leads to a large number of changes due to many small adjustments.
More settings can be found here
One other potential issue is the lack of a setting for preserving aligned spaces such as
This patten is found in a few places, especially
src/image.rs
In this case if you want to preserve the nice alignment there are a few options:#[rustfmt::ignore]
annotations to each line that you want to preserve formatting#[rustfmt::ignore]
#![rustfmt::ignore]
to the top of the file to avoid formatting the whole thing