`cargo fmt` cannot be used for Rust projects in Helix
Summary
To my understanding, currently Helix pipes the actively viewed file into the configured formatter command's stdin, as it is intended for the rustfmt command.
I've tried to switch the command to cargo with args of fmt & --, however Helix still pipes through stdin, meaning the command fails because cargo fmt already passes file names into rustfmt, and the additional stdin stream confuses rustfmt.
For additional context, I am in a workspace project.
The reason I am using cargo fmt instead of rustfmt is because using rustfmt is ignoring my workspace's .rustfmt.toml.
Reproduction Steps
I tried this:
- Have a configured
.rustfmt.tomlin my workspace's root; - Configure
.helix/languages.tomlto usecargo fmt --/cargo fmt; - Run Helix;
- Trust the workspace; and
- Edit a Rust file and save; or
- Run
:fmtwhilst in a Rust file.
I expected this to happen:
Helix would format my code according to my .rustfmt.toml with no issues.
Instead, this happened:
Formatter can't run because cargo fmt expects no stdin.
Helix log
~/.cache/helix/helix.log2026-09-16T23:33:09.577 helix_view::document [ERROR] Formatter error: Failed to find targets
This utility formats all bin and lib files of the current crate using rustfmt.
Usage: cargo fmt [OPTIONS] [-- <rustfmt_options>...]
Arguments:
[rustfmt_options]... Options passed to rustfmt
Options:
-q, --quiet
No output printed to stdout
-v, --verbose
Use verbose output
--version
Print rustfmt version and exit
-p, --package <package>...
Specify package to format
--manifest-path <manifest-path>
Specify path to Cargo.toml
--message-format <message-format>
Specify message-format: short|json|human
--all
Format all packages, and also their local path-based dependencies
--check
Run rustfmt in check mode
-h, --help
Print help
Platform
Linux
Terminal Emulator
alacritty 0.18.0-dev (852e971)
Installation Method
source
Helix Version
helix 25.07.1 (079a789e)
Source: helix-editor/helix