Closed nwj closed 5 months ago
Did some research and it seems like there's no good way to get cargo fmt
to operate on stdin. It does not seem to be built for the purpose of integrating with an editor. I don't love it, but I think the better approach is to parse the edition (hackily, because we don't have a toml parser) from the Cargo.toml file.
Neovim version (nvim -v)
0.9.5
Operating system/version
MacOS Sonoma 14.2.1
Add the debug logs
log_level = vim.log.levels.DEBUG
and pasted the log contents below.Log file
Describe the bug
Attempts to run Rustfmt via Conform on Rust files that use async functions error out and no formatting occurs.
What is the severity of this bug?
breaking (some functionality is broken)
Steps To Reproduce
tmp/Cargo.toml
andtmp/src/main.rs
as specified.nvim -u repro.lua
:e src/main.rs
:ConformInfo
to witness error.Expected Behavior
In file paths that include a Cargo.toml, Conform is able to invoke
rustfmt
on Rust files containing async syntax in a way that successfully formats the file without errors.Minimal example file
tmp/src/main.rs
tmp/Cargo.toml
Minimal init.lua
Additional context
I believe this is happening because Conform is not setting the appropriate edition parameter when it calls
rustfmt
. https://github.com/stevearc/conform.nvim/pull/328 attempted to fix this, but fails when Conform is invoked in a filesystem path that includes a Cargo.toml file.I believe the reason for this failure is that when Conform finds a
Cargo.toml
file, it attempts to pass the path to that file torustfmt
using the--manifest-path
parameter. This fails becauserustfmt
does not support such a parameter (cargo fmt
does, but I don't think Conform ever invokescargo fmt
?).Potential fixes seem to me like:
edition
value out ofCargo.toml
(when that file is present) and passing it torustfmt
via the--edition
parameter.cargo fmt
instead ofrustfmt
in contexts where cargo is present.