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:
parent
5a9660e707
commit
2ccf66037b
3 changed files with 32 additions and 3 deletions
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
, ...
|
||||
}: { };
|
||||
}
|
||||
|
|
|
@ -90,4 +90,10 @@
|
|||
b = 1;
|
||||
c = 2;
|
||||
};
|
||||
n = pkgs: { };
|
||||
o =
|
||||
{ pkgs
|
||||
, ...
|
||||
}:
|
||||
{ };
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue