Correctly set 'cargo fmt' It formats correctly but hx --health
complains it cannot find the bin
#14014
-
SummaryHi, thanks for helix. Just trying it out and I already love it. I can see myself using it as my main editor. Now, I just wanted to point out that the correct formatter settings for Rust ( ❯ head -12 ~/.config/helix/languages.toml
#### Rust START
[[language]]
name = "rust"
language-servers = ["rust-analyzer", "tailwindcss-ls", "harper-ls"]
formatter = { command = "cargo fmt", args = [""] }
[language-server.rust-analyzer.config.check]
command = "clippy"
[language-server.rust-analyzer.config.cargo]
features = "all"
##### Rust END
❯ hx --health rust
Configured language servers:
✓ rust-analyzer: /Users/andreacfromtheapp/.cargo/bin/rust-analyzer
✓ tailwindcss-ls: /Users/andreacfromtheapp/.local/state/fnm_multishells/2242_1752918305548/bin/tailwindcss-language-server
✓ harper-ls: /opt/homebrew/bin/harper-ls
Configured debug adapter:
✓ /opt/homebrew/opt/llvm/bin/lldb-dap
Configured formatter:
✘ 'cargo fmt' not found in $PATH
Tree-sitter parser: ✓
Highlight queries: ✓
Textobject queries: ✓
Indent queries: ✓ Reproduction Steps
#### Rust START
[[language]]
name = "rust"
language-servers = ["rust-analyzer", "tailwindcss-ls", "harper-ls"]
formatter = { command = "cargo fmt", args = [""] }
[language-server.rust-analyzer.config.check]
command = "clippy"
[language-server.rust-analyzer.config.cargo]
features = "all"
##### Rust END
I expected this to happen:
Instead, this happened: ❯ hx --health rust
Configured language servers:
✓ rust-analyzer: /Users/andreacfromtheapp/.cargo/bin/rust-analyzer
✓ tailwindcss-ls: /Users/andreacfromtheapp/.local/state/fnm_multishells/2242_1752918305548/bin/tailwindcss-language-server
✓ harper-ls: /opt/homebrew/bin/harper-ls
Configured debug adapter:
✓ /opt/homebrew/opt/llvm/bin/lldb-dap
Configured formatter:
✘ 'cargo fmt' not found in $PATH
Tree-sitter parser: ✓
Highlight queries: ✓
Textobject queries: ✓
Indent queries: ✓ Helix logno pertinent log found PlatformmacOS Terminal EmulatorGhostty 1.1.3 Installation Methodbrew Helix Versionhelix 25.07.1 (a05c151) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
The program is formatter = { command = "cargo", args = ["fmt"] } cargo-fmt does not support reading files from stdin and printing the formatted versions to stdout which is what |
Beta Was this translation helpful? Give feedback.
The program is
cargo
and the first arg isfmt
so you would specify the formatter as this instead:cargo-fmt does not support reading files from stdin and printing the formatted versions to stdout which is what
formatter
programs are expected to do. You should be able to delete that line since rust-analyzer should take care of formatting on write. If formatting is currently working even though the formatter program is marked as "not found in PATH" then rust-analyzer is already being used for formatting.