OCamlPro / ocp-indent

Indentation tool for OCaml, to be used from editors like Emacs and Vim.
http://www.typerex.org/ocp-indent.html
Other
200 stars 63 forks source link

Wrong indent of match in match #255

Closed mauny closed 7 years ago

mauny commented 7 years ago

The following code is not indented correctly:

match expr with
| p1 -> match v1 with
| p2 -> v2

instead of

match expr with
| p1 -> match v1 with
   | p2 -> v2

However, when the internal match is at the beginning on a line, indentation is correct. Tested with version 1.6.1.

AltGr commented 7 years ago

This doesn't happen with the default configuration. I believe it can be caused by the combination of with=0 (the default), which says to not indent the switch cases, and strict_with=always, which says to strictly respect with (the default is never).

From the manpage:

   strict_with=<always|never|auto> (default=never)
       If `never', match bars are indented, superseding `with', whenever
       `match with' doesn't start its line. If `auto', there are
       exceptions for constructs like `begin match with'. If `always',
       `with' is always strictly respected.

       Example with `strict_with=never,with=0':
           begin match foo with
           ..| _ -> bar
           end

I would advise to set strict_with to auto if you would like to keep with=0

mauny commented 7 years ago

Indeed, an extra config file was loaded while I thought I used the default configuration. I should have better rtfm ;-).

mauny commented 7 years ago

Thanks!