Open TheBlueMatt opened 4 years ago
Hi @TheBlueMatt
If you haven't already done so, you may want to checkout the available Configuration options (for example fn_args_layout
) to see if there's anything that allows you to tune the emitted formatting to your liking.
rustfmt's default behavior is to format code according to the Rust Style Guide as defined over in https://github.com/rust-dev-tools/fmt-rfcs, though in many instances there are config options that can be used to override those defaults.
Right, essentially what I’d love to see is the Compressed option (or something like it) from fn_args_layout available for chains/fn calls. Correct me if I’m wrong, but there appears to be nothing available which doesn’t jump to “vertical” for most things if a line runs long, which can lead to incredibly tall code in some projects.
On Apr 29, 2020, at 20:25, Caleb Cartwright notifications@github.com wrote:
Hi @TheBlueMatt
If you haven't already done so, you may want to checkout the available Configuration options (for example fn_args_layout) to see if there's anything that allows you to tune the emitted formatting to your liking.
rustfmt's default behavior is to format code according to the Rust Style Guide as defined over in https://github.com/rust-dev-tools/fmt-rfcs, though in many instances there are config options that can be used to override those defaults.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
AFAIK there's no such equivalent config option that's used for the layout of call args.
There was fn_call_style
a few years ago, but that never had a Compressed
variant (#2010). It was dropped since the behavior associated with a Tall
variant is the default for calls and the Vertical
equivalent can be achieved via the width_heuristics
/fn_call_width
config options.
I believe the same challenges with a Compressed
-based formatting calls still exists (particularly sub expressions) so IMO we're unlikely to be able to support, though I'll defer to @topecongiro
The relevant thread in the Style Guide can be found in https://github.com/rust-dev-tools/fmt-rfcs/issues/65, also a previous request for Compressed call args in #2851
Yea, I'd come across #2010, but its quite old at this point, and the discussion there seemed both stale (ie was at a different time in rustfmt's history) and to not actually describe why it was closed. I get that it would be hard to do Compressed in a general way, but given that it comes up from time to time, may be best to at least track it as a relatively-common feature request. Its probably a blocker for us using rustfmt given how easily rustfmt makes code really tall breaks readability as-is.
This sounds like a nice feature! I like rustfmt but sometimes I have big function definitions with a lot of inputs, and on one hand I don't want them on one line, but on the other, I don't want that each call will take ~11 lines
This may be hard to get right, but, in general, I tend to prefer putting two or three things in a fn call instead of putting each on its own line. This prevents things from getting needlessly absurdly vertical, eg this in today's rustfmt:
could be