-
Notifications
You must be signed in to change notification settings - Fork 105
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
cargo fmt
cannot be used for formatting a single rust buffer
#95
Comments
Thanks for reporting the bug. I don't use Rust myself, so I'll follow your recommendations on what to do. Skimming that rustfmt thread, I got the impression that the problem is there's no simple way to run |
Does this imply that Rust formatting currently cannot be made work properly for projects using non-standard formatter settings? In other words, we need to wait for the rustfmt and/or cargo fmt maintainers to add a command line flag for editor plugins. |
That's correct, at least for now.
Not quite. It's worth noting that the next major release of My recommendation would be to revert #88 and advise users to create a |
And you can set the edition in |
"cargo fmt" currently doesn't work sensibly for stdin->stdout formatting -- if the project has multiple Rust source files, it formats all of them instead of formatting only the one we want. There is currently no way to fix this in "cargo fmt", so revert to "rustfmt". Thanks to Sondre Nilsen for solving this problem. See also issue #88 (Use cargo fmt instead of rustfmt).
OK, pushed a fix to master. Please test and close this issue if it solves the problem. Thanks for an excellent bug report! |
It works, thank you! |
In #87 / #88, the
rustfmt
formatter was switched from callingrustfmt
directly to usingcargo fmt
so that it would respectCargo.toml
. Unfortunately,cargo fmt
cannot format a single file. It will actually format all the files in the crate. When combined with--emit=stdout
(as in current master), this will spit out all the crate's src into the current buffer on save.See discussion in rust-lang/rustfmt#4074
There doesn't appear to be a way to respect
Cargo.toml
while formatting a single buffer.The text was updated successfully, but these errors were encountered: