nixfmt icon indicating copy to clipboard operation
nixfmt copied to clipboard

nixfmt keeps moving comments immediately after `in`

Open menixator opened this issue 2 years ago • 1 comments

Given the expression

let  
    a = 0;
in 
# checking if a == 0
if a == 0 then 
"a is zero"
else
"a is not zero"

nixfmt outputs:

let
  a = 0;
  # checking if a == 0
in if a == 0 then "a is zero" else "a is not zero"

nixfmt moves the comment before the in which sort of makes sense for smaller comments but big blocks of comments look weird. Is this intended behavior?

menixator avatar Aug 29 '22 20:08 menixator

Moving the comment before the in is intentional and currently the only case where comments are moved. The fact that it gets indented is not intentional and is something that will eventually be fixed once I get around to https://github.com/serokell/nixfmt/issues/32.

Lucus16 avatar Sep 05 '22 09:09 Lucus16

The layout in #118 does occasionally move comments around, but not in this case.

piegamesde avatar Mar 14 '24 20:03 piegamesde