Describe the bug
So the default behavior of treefmt, is to to not pass the file path to the downstream formatter if formatting via stdin. But that subtly breaks fourmolu, it fails to pull in the active Haskell extensions. So fourmolu -i -c fat-hs/src/MyLib.hs < fat-hs/src/MyLib.hs works, but fourmolu -i -c < fat-hs/src/MyLib.hs doesn't. I don't quite see from the code, where does the path get omitted,
|
func (f *Formatter) Apply(ctx context.Context, files []*walk.File) error { |
I was looking there, and I think it comes from files, which is empty in the case of stdin formatting I guess.
To Reproduce
- clone my thesis repo https://git.redalder.org/magic_rb/bsc-thesis
- try to format
fat-hs/src/MyLib.hs using treefmt, so: treefmt --stdin fat-hs/src/MyLib.hs < fat-hs/src/MyLib.hs
Expected behavior
Formatting is consistent between stdin mode and direct mode
System information
NixOS 25.05, exact versions of everything are pinned in https://git.redalder.org/magic_rb/bsc-thesis
Additional context
Describe the bug
So the default behavior of treefmt, is to to not pass the file path to the downstream formatter if formatting via stdin. But that subtly breaks fourmolu, it fails to pull in the active Haskell extensions. So
fourmolu -i -c fat-hs/src/MyLib.hs < fat-hs/src/MyLib.hsworks, butfourmolu -i -c < fat-hs/src/MyLib.hsdoesn't. I don't quite see from the code, where does the path get omitted,treefmt/format/formatter.go
Line 80 in 9399cd6
To Reproduce
fat-hs/src/MyLib.hsusingtreefmt, so:treefmt --stdin fat-hs/src/MyLib.hs < fat-hs/src/MyLib.hsExpected behavior
Formatting is consistent between
stdinmode and direct modeSystem information
NixOS 25.05, exact versions of everything are pinned in https://git.redalder.org/magic_rb/bsc-thesis
Additional context