-
-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Allow new line(s) after }:
#241
Comments
We can have the best of both worlds: enforcing the newlines, which means there is still one single style being allowed The end result would be something like: {
libXdamage,
nss,
}:
{
libXdamage,
nss,
}:
version: hashes:
{
libXdamage,
nss,
}: Most times I've seen nested lambdas in practice is because they are logically separated concepts |
Should this be a universal rule, or just if followed by a function? |
When the implementation is not another function it would look like a waste of space, but on the other hand, if we do it only for functions it would look inconsistent to the detail-oriented eye. If we allow choosing, then we sacrifice consistency as well, but overall would be an improvement since the user knows the perfect meaning Other facts:
I'm happy with all alternatives proposed so far, even leaving it as-is |
imho, the example form #241 (comment) should be formatted as: {
libXdamage,
nss,
}:
{
libXdamage,
nss,
}:
version:
hashes:
{
libXdamage,
nss,
}: this gives equal treatment to function arguments, regardless if they are attrset destructuring style, or simple identifiers currently it's formatted as follows: {
libXdamage,
nss,
}: {
libXdamage,
nss,
}: version: hashes: {
libXdamage,
nss,
}: since simple identifier arguments are always collapsed into a single line (even if it means making the line very long): |
here are some examples of how I'd prefer the formatter to behave in regards to function arguments: in the following examples, developer "chooses" the formatting style, and the formatted enforces consistency: if all arguments are on a single line, the formatter leaves them as they are (unless they violate max line length), but inserting at least one newline, forces all into separate lines (same as it works currently for lists and operator chains): unchanged: a: b: c: a + b + c in 1: a:
b: c: a + b + c out 1: a:
b:
c:
a + b + c in 2: {
a,
x
}:
b: c: (a + b + c) * x out 2: {
a,
x,
}:
b:
c:
(a + b + c) * x Then you could allow newlines, which would make the formatter "reset" the arguent formatting style (consitency only enforce per newline separated block), so the following would remain unchanged: {
a,
x,
}:
b: c: (a + b + c) * x a:
x:
b: c: (a + b + c) * x a: x:
b:
c:
(a + b + c) * x |
Here a (modified) example from nixpkgs containing a long argument list followed by a function:
It is clearly visible that a function with two parameters follows the argument list.
alejandra does this:
The fact that there follows a function after the args list becomes hidden a bit.
Possible fix:
Always allow new lines (or even empty lines) after argument lists.
Downsides:
There will be multiple different styles allowed, vs right now there is only one single allows style, which has it's benefits as well.
Conclusion:
I'm not sure.
The text was updated successfully, but these errors were encountered: