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

Merge pull request #144 from kamadorueda/kamadorueda

feat: indent with
This commit is contained in:
Kevin Amado 2022-02-18 17:15:18 -05:00 committed by GitHub
commit 0644375c56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 34 additions and 19 deletions

View file

@ -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

View file

@ -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(

View file

@ -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);

View file

@ -4,7 +4,7 @@
/*
b
*/
c)
c)
(assert
/*
a
@ -18,7 +18,7 @@
/*
b
*/
c)
c)
(assert b; cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc)
(assert b; cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc)
]

View file

@ -26,10 +26,10 @@
{
meta = with lib;
# comment
{
a = 1;
b = 2;
c = 3;
};
{
a = 1;
b = 2;
c = 3;
};
}
]

View file

@ -24,7 +24,8 @@
{ a = with b;with b;with b;
1;
}
{binPath =
{
binPath =
with pkgs;
makeBinPath (
[

View file

@ -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