fourmolu icon indicating copy to clipboard operation
fourmolu copied to clipboard

Allow specifying Ormolu CLI flags in config file

Open neongreen opened this issue 3 years ago • 8 comments

It would be lovely to be able to specify extensions (-XBlockArguments, etc) in the config. This would be a strong selling point vs Ormolu.

neongreen avatar Jan 20 '21 16:01 neongreen

it'd be super cool if we could parse the package.ymal or cabal file on startup to pick out default-extensions too

parsonsmatt avatar Jan 20 '21 17:01 parsonsmatt

It would be lovely to be able to specify extensions (-XBlockArguments, etc) in the config.

I've never cared too much about this, since I almost exclusively use Fourmolu via HLS. But I appreciate it would be useful, and it's particularly been on my radar since it was requested yesterday. There's a bit of a backlog of Fourmolu work that I expect to get back to in the next few weeks. In the meantime, a PR would be great if you're so inclined.

it'd be super cool if we could parse the package.ymal or cabal file on startup to pick out default-extensions too

I wonder if we could get this via something like hie-bios...

georgefst avatar Jan 20 '21 17:01 georgefst

Hey I added this feature (automatically reading default extensions from the .cabal file) to hindent, and you could totally just copy the code.

AshleyYakeley avatar Apr 26 '21 00:04 AshleyYakeley

Well, it's been added upstream, even though I'm sure I remember them originally rejecting the idea: https://github.com/tweag/ormolu/pull/759.

~~So we just need to merge (see https://github.com/fourmolu/fourmolu/pull/106, though there have been more changes in Ormolu since then).~~ Done: #106

georgefst avatar Sep 26 '21 22:09 georgefst

Any update on this? I cannot find a way to specify --cabal-default-extensions when using HLS

s0kil avatar Apr 11 '22 04:04 s0kil

No update yet, but I made the title more reflective of the fact that we now support --cabal-default-extensions like Ormolu. Ideally, we should be able to support any Ormolu flag in the config file; hopefully it can also be done in a way to minimize merge conflicts with Ormolu in app/Main.hs

Probably intersects a great deal with #150

brandonchinn178 avatar Apr 17 '22 03:04 brandonchinn178

Any update on this? I cannot find a way to specify --cabal-default-extensions when using HLS

You could write a wrapper around Fourmolu and call it using https://github.com/haskell/haskell-language-server/pull/2763. Which will be in the next HLS release.

georgefst avatar Apr 17 '22 09:04 georgefst

You could write a wrapper around Fourmolu and call it using haskell/haskell-language-server#2763. Which will be in the next HLS release.

Although actually, it shouldn't be necessary if you've got HLS working correctly, unless you've got a pretty esoteric setup? The Fourmolu HLS plugin has always been passed GHC options from the environment, which includes those specified in a Cabal file.

georgefst avatar Jun 07 '22 16:06 georgefst