neovimhaskell/haskell-vim

multi-line comment formatting is not working as good

osa1 opened this issue · 2 comments

osa1 commented

Suppose I have this comment block:

--    If they're in form `C1 t1_1 .. t1_n` and `C2 t2_1 .. t2_m` (C1 and C2 are
--    type constructors), it expands C1 and C2 if they're different type synonyms.
--    Then it recursively does the same thing on expanded types. If C1 and C2 are
--    same, then it should apply same procedure to arguments of C1 and arguments
--    of C2 to make them as similar as possible.

Some of these lines are longer than I like so I choose the whole thing and do gq and it's formatted perfectly:

--    If they're in form `C1 t1_1 .. t1_n` and `C2 t2_1 .. t2_m` (C1 and C2 are
--    type constructors), it expands C1 and C2 if they're different type
--    synonyms. Then it recursively does the same thing on expanded types. If C1
--    and C2 are same, then it should apply same procedure to arguments of C1
--    and arguments of C2 to make them as similar as possible.

Splitting worked great and new line is indented correctly.

However, if I do the same thing on this comment block:

{-
      If they're in form `C1 t1_1 .. t1_n` and `C2 t2_1 .. t2_m` (C1 and C2 are
      type constructors), it expands C1 and C2 if they're different type synonyms.
      Then it recursively does the same thing on expanded types. If C1 and C2 are
      same, then it should apply same procedure to arguments of C1 and arguments
      of C2 to make them as similar as possible.
-}

It becomes this:

{-
      If they're in form `C1 t1_1 .. t1_n` and `C2 t2_1 .. t2_m` (C1 and C2 are
 type constructors), it expands C1 and C2 if they're different type synonyms.
 Then it recursively does the same thing on expanded types. If C1 and C2 are
 same, then it should apply same procedure to arguments of C1 and arguments of
 C2 to make them as similar as possible.
-}

Indentation is completely messed up. There's another problem which may be related. Suppose I don't have any indentation, like so:

{-
If they're in form `C1 t1_1 .. t1_n` and `C2 t2_1 .. t2_m` (C1 and C2 are type
constructors), it expands C1 and C2 if they're different type synonyms. Then it
recursively does the same thing on expanded types. If C1 and C2 are same, then
it should apply same procedure to arguments of C1 and arguments of C2 to make
them as similar as possible.
-}

gq again messes things up by generating this:

{-
If they're in form `C1 t1_1 .. t1_n` and `C2 t2_1 .. t2_m` (C1 and C2 are type
 constructors), it expands C1 and C2 if they're different type synonyms. Then it
 recursively does the same thing on expanded types. If C1 and C2 are same, then
 it should apply same procedure to arguments of C1 and arguments of C2 to make
 them as similar as possible.
-}

For some reason every line except the first one is indented by one space.

It'd be really awesome if multi-line comments would work exactly the way single-line comments works.

I've pushed some changes dealing with that. Check out of that does what you want.

osa1 commented

Amazing! Thanks a lot!