Closed teto closed 2 months ago
This can be handled by treefmt direclty, without passing the options down to the tools.
Treefmt can already deal with buffers. Eg to get a sneak peek of a generated output:
$ treefmt --stdin src/eval_cache.rs < src/eval_cache.rs
Potentially we could add a new --try
option that takes a single file as a shortcut.
(Sorry for posting on this older issue, but I think this might be related)
I use treefmt-nix
with flake-parts, and running (something like) the above command does not work for me:
$ treefmt --stdin flake.nix < flake.nix
[ERR]: treefmt.toml could not be found in /Users/daniel/.config/nixpkgs and up. Use the --init option to create one.
treefmt
is the wrapper script that is generated by treefmt-nix
, so --config-file
is specified in the wrapper script.
No combination of --config-file
and --tree-root
appears to work.
I think this is supported with --stdin
as @zimbatm described above.
I don't think the issues @nifoc mentioned either are an issue any more.
Is your feature request related to a problem? Please describe.
Sometimes we dont want to format the code in place but have a look at what changes it proposes first. We've had bad experience with stylish-haskell which depending on the locales configuration would just delete half the code.
Describe the solution you'd like Not sure what I would like, maybe a different set of flags on a per formatter basis for inplace formatting and just checking. This would require a new command on treefmt too to be able to run "see-changes" and "inplace-format".
Describe alternatives you've considered
I've thought of overriding the default flags of the different formatters not to format in place like:
but seems like it triggers other issues error:
The option
settings.formatter.nixpkgs-fmt.command' is used but not defined.`That's probably the simplest for everyone. Guess I am just curious about the scope of treefmt.