mirror of
https://github.com/RGBCube/alejandra
synced 2025-07-30 12:07:46 +00:00
feat: allow choosing loose parens
- There are a few cases where it's valid to have it loose, but we cannot guess algorithmically in all cases, so let's leave a small door open in the cases that we cannot guess, but force when we are sure
This commit is contained in:
parent
61ff81165b
commit
86dcb185f2
5 changed files with 35 additions and 11 deletions
|
@ -16,7 +16,19 @@ pub(crate) fn rule(
|
|||
|| expression.has_comments
|
||||
|| closer.has_inline_comment
|
||||
|| closer.has_comments
|
||||
|| matches!(expression.element.kind(), rnix::SyntaxKind::NODE_IF_ELSE);
|
||||
|| matches!(expression.element.kind(), rnix::SyntaxKind::NODE_IF_ELSE)
|
||||
|| ((opener.has_trivialities
|
||||
|| expression.has_trivialities
|
||||
|| closer.has_trivialities)
|
||||
&& !matches!(
|
||||
expression.element.kind(),
|
||||
rnix::SyntaxKind::NODE_ATTR_SET
|
||||
| rnix::SyntaxKind::NODE_IDENT
|
||||
| rnix::SyntaxKind::NODE_LITERAL
|
||||
| rnix::SyntaxKind::NODE_LIST
|
||||
| rnix::SyntaxKind::NODE_STRING
|
||||
| rnix::SyntaxKind::NODE_UNARY_OP
|
||||
));
|
||||
|
||||
let should_indent = loose
|
||||
|| matches!(
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
[
|
||||
(a
|
||||
b)
|
||||
((a b)
|
||||
(
|
||||
(a b)
|
||||
(a b)
|
||||
(a
|
||||
/*
|
||||
|
@ -20,9 +21,11 @@
|
|||
/*
|
||||
e
|
||||
*/
|
||||
))
|
||||
)
|
||||
)
|
||||
''
|
||||
otherModules=${pkgs.writeText "other-modules.json"
|
||||
otherModules=${
|
||||
pkgs.writeText "other-modules.json"
|
||||
(l.toJSON
|
||||
(l.mapAttrs
|
||||
(pname: subOutputs: let
|
||||
|
@ -31,7 +34,8 @@
|
|||
installMethod = "copy";
|
||||
});
|
||||
in "${pkg}/lib/node_modules/${pname}/node_modules")
|
||||
outputs.subPackages))}
|
||||
outputs.subPackages))
|
||||
}
|
||||
''
|
||||
{
|
||||
name1 =
|
||||
|
|
|
@ -35,8 +35,12 @@
|
|||
c
|
||||
*/
|
||||
d)
|
||||
(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
|
||||
(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
|
||||
(
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
)
|
||||
(
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
)
|
||||
({
|
||||
pkgs ? import ./.. {},
|
||||
locationsXml,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
(( # test
|
||||
(
|
||||
( # test
|
||||
a # test
|
||||
)
|
||||
c
|
||||
|
@ -160,4 +161,5 @@
|
|||
/*
|
||||
e
|
||||
*/
|
||||
))
|
||||
)
|
||||
)
|
||||
|
|
|
@ -1059,7 +1059,8 @@
|
|||
}:
|
||||
_)
|
||||
|
||||
({
|
||||
(
|
||||
{
|
||||
/*
|
||||
a
|
||||
*/
|
||||
|
@ -1117,5 +1118,6 @@
|
|||
j
|
||||
*/
|
||||
#
|
||||
_)
|
||||
_
|
||||
)
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue