Emacs lsp brittany: how to set indentation to 2?

I am very happy with emacs and lsp-mode, because of the fact that haskell-language-server now takes care of a lot of stuff for me.

I recently discovered brittany, i.e. automatic code styling.

However, brittany sets indentation to 4 spaces. Once I use a couple of closures, a lot of code gets wrapped in a ridiculous way on the remaining right half of my editor.

Anyone knows how to configure brittany (brought to me by emacs/lsp-haskell) to use 2 spaces?

And while I’m at it: Anyone else using brittany here? If you prefer another styling tool, why? And is there general agreement on 2 spaces vs 4 spaces?

Unfortunately Brittany’s configuration format is under specified at the moment. But you should be able to configure Brittany with a brittany.yaml like this:

conf_layout:
  lconfig_indentAmount: 2

I myself use Brittany. I think the other popular formatter right now is Ormolu (or Fourmolu).

1 Like

googling “Brittany vs fourmolu”, I learn that Brittany isn’t developped anymore. Maybe time to switch.

I know :slight_smile: I am the de facto maintainer of Brittany these days. I’m working to make it easier for me to maintain and also to use GHC 9.0 (and now 9.2).

I think Ormolu or Fourmolu is a fine choice. I personally dislike how it formats things, but I think that consistent formatting applied by a tool is more important than liking the exact style that it chooses.

3 Likes

Now having tried fourmolu, I miss brittany. Maybe I have to configure fourmolu some more or something but so far it doesn’t do it for me.

So thanks for keeping brittany running! It was and still is my formatter of choice.