play-haskell icon indicating copy to clipboard operation
play-haskell copied to clipboard

Button for running a code formatter

Open tomsmeding opened this issue 2 years ago • 1 comments

To make the playground double as a place for trying out different Haskell code formatters without having to download and build them all, it would be nice to have a UI element to run your code through one of a couple of high-profile code formatters (ormolu, brittany, stylish-haskell, maybe even configurable fourmolu?, others?). How exactly this UI element should look, I'm not sure. It definitely shouldn't take up a lot of space if you're not using it.

Some things to think about:

  • If the formatter runs on the server (probably), doing a formatting operation should also count (a little bit) against your spam score. How much should depend on how long a formatter takes to process some file; hopefully this is not very long usually?
  • We should verify for each formatter in question that they not have any risk of actually running part of the code being formatted (I'm thinking about too-clever handling of CPP or TH), because then that would be unsafe.
  • It should hook into the undo/redo functionality of the Ace editor so that the user can undo the formatting easily.

tomsmeding avatar Feb 01 '23 21:02 tomsmeding

How much should depend on how long a formatter takes to process some file; hopefully this is not very long usually?

It's usually fairly quick yes

Kleidukos avatar Feb 02 '23 09:02 Kleidukos