-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple formatters when using --stdin #274
Comments
@brianmcgee I see the new release with golang rewrite is around the corner. Will this be fixed in the new version? Since the code is totally new, I assume this bug won't persist. But just making sure :) |
@terlar, if you have an example config you can share, I'd be happy to add it to the tests to ensure we cover this specifically. |
I just tested this on the main branch and it seems the $ cat temp-test/treefmt.toml
# One CLI to format the code tree - https://git.numtide.com/numtide/treefmt
[formatter.dos2unix]
command = "dos2unix"
includes = ["*.yaml"]
options = ["--keepdate"]
[formatter.yamlfmt]
command = "yamlfmt"
includes = ["*.yaml"]
$ cat --show-ends temp-test/dos2unix+yaml.yaml
hello: world^M$
^M$
list:^M$
- one^M$
- two^M$
- three^M$
$ cat temp-test/dos2unix+yaml.yaml | nix shell nixpkgs#dos2unix nixpkgs#yamlfmt --command nix run
. -- -C temp-test --stdin sample.yaml
treefmt: error: failed to generate change set: failed to walk path: lstat /home/terje/src/github.com/numtide/treefmt/temp-test/sample.yaml: no such file or directory |
@terlar #313 was merged, give main another go whenever you have a chance.
Formatters are applied first in |
Thank you! Looks promising, I will have a look soon. |
Yes, I can confirm this now works. So I will close this issue. Thanks for the quick fix. |
Is your feature request related to a problem? Please describe.
I configured the formatter
dos2unix
which I essentially applied to all files in the project, then everything seemed to work fine, however in my editor I utilizetreefmt --stdin FILENAME < BUFFER
in order to have consistent formatting across the project without duplicate configuration. Recently I noticed the formatting stopped working and when I debugged this I got this:So it didn't format the file because
dos2unix
was the first one.Describe the solution you'd like
Either a way to select which formatter has priority in this case, or I guess the best case would be to run all the formatters, just like it does when you apply via
treefmt test.nix
.Describe alternatives you've considered
The text was updated successfully, but these errors were encountered: