mirror of
https://github.com/RGBCube/alejandra
synced 2025-07-30 12:07:46 +00:00
feat: indent with
This commit is contained in:
parent
81ce4c563f
commit
d60c6e6526
7 changed files with 34 additions and 19 deletions
|
@ -72,6 +72,12 @@ Types of changes
|
|||
+ value,
|
||||
+ }:
|
||||
```
|
||||
- `with` expressions now indent the new scope and follow the equal sign:
|
||||
```diff
|
||||
- binPath =
|
||||
- with pkgs;
|
||||
+ binPath = with pkgs;
|
||||
```
|
||||
|
||||
## [0.2.0] - 2022-02-17
|
||||
|
||||
|
|
|
@ -68,11 +68,18 @@ pub fn rule(
|
|||
let child = children.get_next().unwrap();
|
||||
match layout {
|
||||
crate::config::Layout::Tall => {
|
||||
if comment
|
||||
|| matches!(
|
||||
if {
|
||||
matches!(
|
||||
child.element.kind(),
|
||||
rnix::SyntaxKind::NODE_ASSERT | rnix::SyntaxKind::NODE_WITH
|
||||
)
|
||||
} {
|
||||
steps.push_back(crate::builder::Step::NewLine);
|
||||
steps.push_back(crate::builder::Step::Pad);
|
||||
steps.push_back(crate::builder::Step::FormatWider(
|
||||
child.element,
|
||||
));
|
||||
} else if comment
|
||||
|| !matches!(
|
||||
child.element.kind(),
|
||||
rnix::SyntaxKind::NODE_ATTR_SET
|
||||
|
@ -84,11 +91,13 @@ pub fn rule(
|
|||
| rnix::SyntaxKind::NODE_STRING
|
||||
)
|
||||
{
|
||||
steps.push_back(crate::builder::Step::Indent);
|
||||
steps.push_back(crate::builder::Step::NewLine);
|
||||
steps.push_back(crate::builder::Step::Pad);
|
||||
steps.push_back(crate::builder::Step::FormatWider(
|
||||
child.element,
|
||||
));
|
||||
steps.push_back(crate::builder::Step::Dedent);
|
||||
} else {
|
||||
steps.push_back(crate::builder::Step::Whitespace);
|
||||
steps.push_back(crate::builder::Step::FormatWider(
|
||||
|
|
|
@ -86,18 +86,18 @@ pub fn rule(
|
|||
} else if false
|
||||
|| matches!(
|
||||
child_expr.element.kind(),
|
||||
rnix::SyntaxKind::NODE_ATTR_SET
|
||||
rnix::SyntaxKind::NODE_ASSERT
|
||||
| rnix::SyntaxKind::NODE_ATTR_SET
|
||||
| rnix::SyntaxKind::NODE_PAREN
|
||||
| rnix::SyntaxKind::NODE_LAMBDA
|
||||
| rnix::SyntaxKind::NODE_LET_IN
|
||||
| rnix::SyntaxKind::NODE_LIST
|
||||
| rnix::SyntaxKind::NODE_STRING
|
||||
| rnix::SyntaxKind::NODE_WITH
|
||||
)
|
||||
|| (matches!(
|
||||
child_expr.element.kind(),
|
||||
rnix::SyntaxKind::NODE_ASSERT
|
||||
| rnix::SyntaxKind::NODE_APPLY
|
||||
| rnix::SyntaxKind::NODE_WITH
|
||||
rnix::SyntaxKind::NODE_APPLY
|
||||
) && !newlines)
|
||||
{
|
||||
steps.push_back(crate::builder::Step::Whitespace);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/*
|
||||
b
|
||||
*/
|
||||
c)
|
||||
c)
|
||||
(assert
|
||||
/*
|
||||
a
|
||||
|
@ -18,7 +18,7 @@
|
|||
/*
|
||||
b
|
||||
*/
|
||||
c)
|
||||
c)
|
||||
(assert b; cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc)
|
||||
(assert b; cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc)
|
||||
]
|
||||
|
|
|
@ -26,10 +26,10 @@
|
|||
{
|
||||
meta = with lib;
|
||||
# comment
|
||||
{
|
||||
a = 1;
|
||||
b = 2;
|
||||
c = 3;
|
||||
};
|
||||
{
|
||||
a = 1;
|
||||
b = 2;
|
||||
c = 3;
|
||||
};
|
||||
}
|
||||
]
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
{ a = with b;with b;with b;
|
||||
1;
|
||||
}
|
||||
{binPath =
|
||||
{
|
||||
binPath =
|
||||
with pkgs;
|
||||
makeBinPath (
|
||||
[
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/*
|
||||
b
|
||||
*/
|
||||
c)
|
||||
c)
|
||||
(with
|
||||
/*
|
||||
a
|
||||
|
@ -18,7 +18,7 @@
|
|||
/*
|
||||
b
|
||||
*/
|
||||
c)
|
||||
c)
|
||||
(with b; cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc)
|
||||
(with b; cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc)
|
||||
{a = with b; 1;}
|
||||
|
@ -34,7 +34,7 @@
|
|||
{
|
||||
a = with b;
|
||||
# comment
|
||||
1;
|
||||
1;
|
||||
}
|
||||
{
|
||||
a = with b; 1;
|
||||
|
@ -60,8 +60,7 @@
|
|||
a = with b; with b; with b; 1;
|
||||
}
|
||||
{
|
||||
binPath =
|
||||
with pkgs;
|
||||
binPath = with pkgs;
|
||||
makeBinPath (
|
||||
[
|
||||
rsync
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue