mirror of
https://github.com/RGBCube/alejandra
synced 2025-08-01 13:07:47 +00:00
Merge pull request #148 from kamadorueda/kamadorueda
feat: brace like after pattern entry
This commit is contained in:
commit
0d09692a3e
4 changed files with 54 additions and 11 deletions
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -91,6 +91,18 @@ Types of changes
|
||||||
+ _
|
+ _
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- Brace-like elements after a pattern entry now follow the exclamation mark:
|
||||||
|
|
||||||
|
```diff
|
||||||
|
- rootPoolProperties ?
|
||||||
|
- {
|
||||||
|
- autoexpand = "on";
|
||||||
|
- },
|
||||||
|
+ rootPoolProperties ? {
|
||||||
|
+ autoexpand = "on";
|
||||||
|
+ },
|
||||||
|
```
|
||||||
|
|
||||||
## [0.2.0] - 2022-02-17
|
## [0.2.0] - 2022-02-17
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -63,23 +63,33 @@ pub fn rule(
|
||||||
|
|
||||||
// expr
|
// expr
|
||||||
let child = children.get_next().unwrap();
|
let child = children.get_next().unwrap();
|
||||||
let single_line = crate::builder::fits_in_single_line(
|
let mut dedent = false;
|
||||||
|
|
||||||
|
if comment {
|
||||||
|
steps.push_back(crate::builder::Step::NewLine);
|
||||||
|
steps.push_back(crate::builder::Step::Pad);
|
||||||
|
} else if matches!(
|
||||||
|
child.element.kind(),
|
||||||
|
rnix::SyntaxKind::NODE_ATTR_SET
|
||||||
|
| rnix::SyntaxKind::NODE_IDENT
|
||||||
|
| rnix::SyntaxKind::NODE_PAREN
|
||||||
|
| rnix::SyntaxKind::NODE_LAMBDA
|
||||||
|
| rnix::SyntaxKind::NODE_LET_IN
|
||||||
|
| rnix::SyntaxKind::NODE_LIST
|
||||||
|
| rnix::SyntaxKind::NODE_LITERAL
|
||||||
|
| rnix::SyntaxKind::NODE_STRING,
|
||||||
|
) || crate::builder::fits_in_single_line(
|
||||||
build_ctx,
|
build_ctx,
|
||||||
child.element.clone(),
|
child.element.clone(),
|
||||||
);
|
) {
|
||||||
|
steps.push_back(crate::builder::Step::Whitespace);
|
||||||
if single_line {
|
|
||||||
if comment {
|
|
||||||
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;
|
||||||
steps.push_back(crate::builder::Step::Indent);
|
steps.push_back(crate::builder::Step::Indent);
|
||||||
steps.push_back(crate::builder::Step::NewLine);
|
steps.push_back(crate::builder::Step::NewLine);
|
||||||
steps.push_back(crate::builder::Step::Pad);
|
steps.push_back(crate::builder::Step::Pad);
|
||||||
}
|
}
|
||||||
|
|
||||||
match layout {
|
match layout {
|
||||||
crate::config::Layout::Tall => {
|
crate::config::Layout::Tall => {
|
||||||
steps.push_back(crate::builder::Step::FormatWider(
|
steps.push_back(crate::builder::Step::FormatWider(
|
||||||
|
@ -90,7 +100,7 @@ pub fn rule(
|
||||||
steps.push_back(crate::builder::Step::Format(child.element));
|
steps.push_back(crate::builder::Step::Format(child.element));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !single_line {
|
if dedent {
|
||||||
steps.push_back(crate::builder::Step::Dedent);
|
steps.push_back(crate::builder::Step::Dedent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,16 @@
|
||||||
gomod2nix,
|
gomod2nix,
|
||||||
mach-nix,
|
mach-nix,
|
||||||
}@inp: _)
|
}@inp: _)
|
||||||
|
({
|
||||||
|
a ? [
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
],
|
||||||
|
b ? {
|
||||||
|
# ...
|
||||||
|
}
|
||||||
|
}: _)
|
||||||
({}: _)
|
({}: _)
|
||||||
({ a }: _)
|
({ a }: _)
|
||||||
({ /**/ }: _)
|
({ /**/ }: _)
|
||||||
|
|
|
@ -11,6 +11,17 @@
|
||||||
mach-nix,
|
mach-nix,
|
||||||
} @ inp:
|
} @ inp:
|
||||||
_)
|
_)
|
||||||
|
({
|
||||||
|
a ? [
|
||||||
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
|
],
|
||||||
|
b ? {
|
||||||
|
# ...
|
||||||
|
},
|
||||||
|
}:
|
||||||
|
_)
|
||||||
({}: _)
|
({}: _)
|
||||||
({a}: _)
|
({a}: _)
|
||||||
({
|
({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue