1
Fork 0
mirror of https://github.com/RGBCube/alejandra synced 2025-07-31 12:37:45 +00:00

feat: func attrs format

This commit is contained in:
Kevin Amado 2022-02-06 16:49:11 -05:00
parent 5a9660e707
commit 2ccf66037b
No known key found for this signature in database
GPG key ID: FFF341057F503148
3 changed files with 32 additions and 3 deletions

View file

@ -45,15 +45,34 @@ pub fn rule(
steps.push_back(crate::builder::Step::Format(child.element));
match layout {
crate::config::Layout::Tall => {
let next = children.peek_next().unwrap();
let next_kind = next.element.kind();
if let rnix::SyntaxKind::NODE_APPLY
| rnix::SyntaxKind::NODE_ATTR_SET
| rnix::SyntaxKind::NODE_LAMBDA
| rnix::SyntaxKind::NODE_LIST
| rnix::SyntaxKind::NODE_PAREN
| rnix::SyntaxKind::NODE_STRING =
children.peek_next().unwrap().element.kind()
| rnix::SyntaxKind::NODE_STRING = next_kind
{
steps.push_back(crate::builder::Step::Whitespace);
} else if let rnix::SyntaxKind::NODE_LAMBDA = next_kind {
if let rnix::SyntaxKind::NODE_PATTERN = next
.element
.clone()
.into_node()
.unwrap()
.children()
.next()
.unwrap()
.kind()
{
dedent = true;
steps.push_back(crate::builder::Step::Indent);
steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad);
} else {
steps.push_back(crate::builder::Step::Whitespace);
}
} else {
dedent = true;
steps.push_back(crate::builder::Step::Indent);

View file

@ -11,4 +11,8 @@
k = a: { b = 1; c = 2;};
l = a: /*b*/ { b = 1 ;};
m = a: /*b*/ { b = 1; c = 2;};
n = pkgs: { };
o = { pkgs
, ...
}: { };
}

View file

@ -90,4 +90,10 @@
b = 1;
c = 2;
};
n = pkgs: { };
o =
{ pkgs
, ...
}:
{ };
}