radian-software / apheleia

🌷 Run code formatter on buffer contents without moving point, using RCS patches and dynamic programming.
MIT License
568 stars 80 forks source link

ormolu backend for haskell-mode is broken #312

Closed Eason0210 closed 1 month ago

Eason0210 commented 2 months ago

Hi,

Because the default brittany for haskell-mode is unmaintained, and the repos recommand to use ormolu instead.

But the ormolu (version: ormolu 0.7.7.0) don't works with cabal project, will get below error message in *aphelia-ormolu-log* buffer:

$ ormolu

The --stdin-input-file option is necessary when using input
from stdin and accounting for .cabal files

Command failed with exit code 9.

my configs:

(setf (alist-get 'haskell-mode apheleia-mode-alist) 'ormolu)

with below config, will fix the issue.

(push '(ormolu . ("ormolu"
                    `("--stdin-input-file" ,buffer-file-name)))
        apheleia-formatters)

Expected this can be fixed in apheleia.

Maybe it is time to change the default backend for haskell-mode to ormolu instead of brittany?

raxod502 commented 1 month ago

Fair enough. If the maintainer of the original formatter recommends switching, then it seems logical for us to switch as well, to encourage best practices as determined by each language's community.

Let me see if I can add a test case that will prevent a regression like this, too... I've done some work on more robust formatter tests that can leverage an entire project directory.

raxod502 commented 1 month ago

Nevermind, no new tests needed, we just need to run the existing ones again from time to time. That might be a good idea, run the full formatter test suite on a monthly schedule or something and have a bot file an issue for ones that are failing.

image