mirror of
https://github.com/RGBCube/alejandra
synced 2025-08-01 04:57:44 +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));
|
steps.push_back(crate::builder::Step::Format(child.element));
|
||||||
match layout {
|
match layout {
|
||||||
crate::config::Layout::Tall => {
|
crate::config::Layout::Tall => {
|
||||||
|
let next = children.peek_next().unwrap();
|
||||||
|
let next_kind = next.element.kind();
|
||||||
|
|
||||||
if let rnix::SyntaxKind::NODE_APPLY
|
if let rnix::SyntaxKind::NODE_APPLY
|
||||||
| rnix::SyntaxKind::NODE_ATTR_SET
|
| rnix::SyntaxKind::NODE_ATTR_SET
|
||||||
| rnix::SyntaxKind::NODE_LAMBDA
|
|
||||||
| rnix::SyntaxKind::NODE_LIST
|
| rnix::SyntaxKind::NODE_LIST
|
||||||
| rnix::SyntaxKind::NODE_PAREN
|
| rnix::SyntaxKind::NODE_PAREN
|
||||||
| rnix::SyntaxKind::NODE_STRING =
|
| rnix::SyntaxKind::NODE_STRING = next_kind
|
||||||
children.peek_next().unwrap().element.kind()
|
|
||||||
{
|
{
|
||||||
steps.push_back(crate::builder::Step::Whitespace);
|
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 {
|
} else {
|
||||||
dedent = true;
|
dedent = true;
|
||||||
steps.push_back(crate::builder::Step::Indent);
|
steps.push_back(crate::builder::Step::Indent);
|
||||||
|
|
|
@ -11,4 +11,8 @@
|
||||||
k = a: { b = 1; c = 2;};
|
k = a: { b = 1; c = 2;};
|
||||||
l = a: /*b*/ { b = 1 ;};
|
l = a: /*b*/ { b = 1 ;};
|
||||||
m = a: /*b*/ { b = 1; c = 2;};
|
m = a: /*b*/ { b = 1; c = 2;};
|
||||||
|
n = pkgs: { };
|
||||||
|
o = { pkgs
|
||||||
|
, ...
|
||||||
|
}: { };
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,4 +90,10 @@
|
||||||
b = 1;
|
b = 1;
|
||||||
c = 2;
|
c = 2;
|
||||||
};
|
};
|
||||||
|
n = pkgs: { };
|
||||||
|
o =
|
||||||
|
{ pkgs
|
||||||
|
, ...
|
||||||
|
}:
|
||||||
|
{ };
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue