alejandra
alejandra copied to clipboard
reconsider placement of semicolons
Current formatting
{
f = a: b: c:
a
|| b
&& c;
}
Proposed:
{
f = a: b: c:
a
|| b
&& c
;
}
Rationale
- The semicolon closes a block opened by
=
so it should be on the same indentation level. It makes it easy to visually parse the span of the block. - Proposed change would make things consistent with how lists and attrsets are formatted:
{
list = [
a
b
];
attrs = {
a = 1;
b = 2;
};
}
- Modifying the last line of the scope leads to 2 line diff given current formatting vs 1 line given the proposed one:
current:
|| b
- && c;
+ && c
+ || a + b;
proposed:
|| b
&& c
+ || a + b
;
}
This is the same argument as used for the choice of comma placement described in alejandra's style guide.
Bonus
Make semicolon placement consistent between multiline assignment and inherit
:
Currently we've got:
{
pkgs =
import
<nixpkgs>
{};
inherit
(pgks)
bash
lib
;
}
I'd like to propose:
{
pkgs =
import
<nixpkgs>
{}
;
inherit
(pgks)
bash
lib
;
}