Description
This is probably asking too much but it'd be nice if cargo-fmt
could support reading a file from stdin and putting formatted output on stdout like rustfmt
does. With this there'd be no real need to specify rustfmt --edition <edition>
.
The use case is a linting tool like ale which runs rustfmt as
/bin/sh -c rustfmt < ${path_to_file_in_tmpdir}
. It then takes this output and copies into the vim buffer. As far as I know ale doesn't support linters that modify files in place.
This currently doesn't work for files that use syntax from editions greater than 2015
(the default for rustfmt). It'd be nice not to have to hardcode a rust edition in my vim configuration and instead be able to point the config to cargo-fmt running in a "stdin mode", i.e:
/bin/sh -c cargo-fmt --stdin < ${path_to_file_in_tmpdir}
. That way I can always adhere the project's edition specified in Cargo.toml as well as other configuration options specified in rustfmt.toml
(assuming cargo-fmt
adheres to the project's rustfmt.toml
, I could be wrong about that).
I'd love to try to implement something like this if you all think it'd be valuable, but I understand if not. I can always see what I can do on the ale
side of things to get this working.