tweag / ormolu

A formatter for Haskell source code
https://ormolu-live.tweag.io
Other
956 stars 83 forks source link

Provide a feature to set column width #982

Closed asarkar closed 1 year ago

asarkar commented 1 year ago

Is your feature request related to a problem? Please describe. Provide a feature to set column width.

Describe the solution you'd like Lines wider than the set width would automatically indent. The online formatter will need a text box for specifying this.

Describe alternatives you've considered Indent manually.

In general design, a configuration file (perhaps named .ormolu) at the project root can be used to set the width, as well as the mode. Command line option would override config file.

ocharles commented 1 year ago

The README writes:

Let some whitespace be programmable. The layout of the input influences the layout choices in the output. This means that the choices between single-line/multi-line layouts in certain situations are made by the user, not by an algorithm. This makes the implementation simpler and leaves some control to the user while still guaranteeing that the formatted code is stylistically consistent.

(emphasis mine).

I imagine this will be a wontfix, because I believe it's an explicit goal of ormolu to not do this.

mrkkrp commented 1 year ago

@ocharles is right. Wrapping is controlled by the layout of input, not by a configuration parameter. This is a design chocie.