Closed Root-Time closed 1 month ago
I got it to work by changing the .vscode/settings.json
override command to this:
{
"rust-analyzer.rustfmt.overrideCommand": ["leptosfmt", "--config-file", "${workspaceFolder}/leptosfmt.toml", "--stdin", "--rustfmt"]
}
Is this only a problem with workspaces, or with standalone cargo projects as well?
Even without a workspace, hx src/app.rs
has the CWD of src/
(tested with recent helix, replacing the override command with pwd
). This makes it hard to use any configuration value that isn't mirrored in flags, e.g. attr_value_brace_style
will become more important to configure shortly.
It might be worth using the approach of rustfmt, which is to recursively look in parent directories up to the root, viz. https://github.com/rust-lang/rustfmt/blob/88944668fec947339291d04e6f0b9c4392cea937/src/config/mod.rs#L263
I think the issue comes from here: https://github.com/rust-lang/rust-analyzer/blob/935883fd826c46e7e7e6de19cf24377c21f1b2ba/crates/rust-analyzer/src/handlers/request.rs#L2188
R-A changes the working directory to the path of the file being formatted, to try to pick up any local rustfmt.toml
files.
Could we add an option that is possible that the override at
rust-analyzer.rustfmt.overrideCommand
uses the project config file?