mirror of
https://github.com/RGBCube/alejandra
synced 2025-07-31 04:27:45 +00:00
feat: key-value without max-width
This commit is contained in:
parent
779ae36a60
commit
98cf2ef1df
4 changed files with 51 additions and 18 deletions
|
@ -33,8 +33,7 @@
|
||||||
version =
|
version =
|
||||||
let
|
let
|
||||||
commit = inputs.self.shortRev or "dirty";
|
commit = inputs.self.shortRev or "dirty";
|
||||||
date =
|
date = inputs.self.lastModifiedDate or inputs.self.lastModified or "19700101";
|
||||||
inputs.self.lastModifiedDate or inputs.self.lastModified or "19700101";
|
|
||||||
in
|
in
|
||||||
"${builtins.substring 0 8 date}_${commit}";
|
"${builtins.substring 0 8 date}_${commit}";
|
||||||
src = inputs.self.sourceInfo;
|
src = inputs.self.sourceInfo;
|
||||||
|
|
|
@ -4,9 +4,11 @@ pub fn rule(
|
||||||
) -> std::collections::LinkedList<crate::builder::Step> {
|
) -> std::collections::LinkedList<crate::builder::Step> {
|
||||||
let mut steps = std::collections::LinkedList::new();
|
let mut steps = std::collections::LinkedList::new();
|
||||||
|
|
||||||
let mut children = crate::children::Children::new(build_ctx, node);
|
let mut children = crate::children::Children::new_with_configuration(
|
||||||
|
build_ctx, node, true,
|
||||||
|
);
|
||||||
|
|
||||||
let layout = if children.has_comments() {
|
let layout = if children.has_comments() || children.has_newlines() {
|
||||||
&crate::config::Layout::Tall
|
&crate::config::Layout::Tall
|
||||||
} else {
|
} else {
|
||||||
build_ctx.config.layout()
|
build_ctx.config.layout()
|
||||||
|
@ -24,13 +26,17 @@ pub fn rule(
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**/
|
// /**/
|
||||||
children.drain_comments(|text| {
|
children.drain_comments_and_newlines(|element| match element {
|
||||||
steps.push_back(crate::builder::Step::NewLine);
|
crate::children::DrainCommentOrNewline::Comment(text) => {
|
||||||
steps.push_back(crate::builder::Step::Pad);
|
steps.push_back(crate::builder::Step::NewLine);
|
||||||
steps.push_back(crate::builder::Step::Comment(text));
|
steps.push_back(crate::builder::Step::Pad);
|
||||||
|
steps.push_back(crate::builder::Step::Comment(text));
|
||||||
|
}
|
||||||
|
crate::children::DrainCommentOrNewline::Newline(_) => {}
|
||||||
});
|
});
|
||||||
|
|
||||||
if let rnix::SyntaxKind::TOKEN_COMMENT =
|
if let rnix::SyntaxKind::TOKEN_COMMENT
|
||||||
|
| rnix::SyntaxKind::TOKEN_WHITESPACE =
|
||||||
children.peek_prev().unwrap().element.kind()
|
children.peek_prev().unwrap().element.kind()
|
||||||
{
|
{
|
||||||
steps.push_back(crate::builder::Step::NewLine);
|
steps.push_back(crate::builder::Step::NewLine);
|
||||||
|
@ -107,10 +113,13 @@ pub fn rule(
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**/
|
// /**/
|
||||||
children.drain_comments(|text| {
|
children.drain_comments_and_newlines(|element| match element {
|
||||||
steps.push_back(crate::builder::Step::Comment(text));
|
crate::children::DrainCommentOrNewline::Comment(text) => {
|
||||||
steps.push_back(crate::builder::Step::NewLine);
|
steps.push_back(crate::builder::Step::Comment(text));
|
||||||
steps.push_back(crate::builder::Step::Pad);
|
steps.push_back(crate::builder::Step::NewLine);
|
||||||
|
steps.push_back(crate::builder::Step::Pad);
|
||||||
|
}
|
||||||
|
crate::children::DrainCommentOrNewline::Newline(_) => {}
|
||||||
});
|
});
|
||||||
|
|
||||||
// b
|
// b
|
||||||
|
@ -125,13 +134,17 @@ pub fn rule(
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**/
|
// /**/
|
||||||
children.drain_comments(|text| {
|
children.drain_comments_and_newlines(|element| match element {
|
||||||
steps.push_back(crate::builder::Step::NewLine);
|
crate::children::DrainCommentOrNewline::Comment(text) => {
|
||||||
steps.push_back(crate::builder::Step::Pad);
|
steps.push_back(crate::builder::Step::NewLine);
|
||||||
steps.push_back(crate::builder::Step::Comment(text));
|
steps.push_back(crate::builder::Step::Pad);
|
||||||
|
steps.push_back(crate::builder::Step::Comment(text));
|
||||||
|
}
|
||||||
|
crate::children::DrainCommentOrNewline::Newline(_) => {}
|
||||||
});
|
});
|
||||||
|
|
||||||
if let rnix::SyntaxKind::TOKEN_COMMENT =
|
if let rnix::SyntaxKind::TOKEN_COMMENT
|
||||||
|
| rnix::SyntaxKind::TOKEN_WHITESPACE =
|
||||||
children.peek_prev().unwrap().element.kind()
|
children.peek_prev().unwrap().element.kind()
|
||||||
{
|
{
|
||||||
steps.push_back(crate::builder::Step::NewLine);
|
steps.push_back(crate::builder::Step::NewLine);
|
||||||
|
|
|
@ -21,6 +21,13 @@ rec /**/ {
|
||||||
, ...
|
, ...
|
||||||
}: { };
|
}: { };
|
||||||
|
|
||||||
|
a
|
||||||
|
/*b*/
|
||||||
|
=
|
||||||
|
/*c*/
|
||||||
|
1
|
||||||
|
/*d*/
|
||||||
|
;
|
||||||
|
|
||||||
p = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa { }
|
p = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa { }
|
||||||
a;
|
a;
|
||||||
|
|
|
@ -101,6 +101,20 @@ rec
|
||||||
}:
|
}:
|
||||||
{ };
|
{ };
|
||||||
|
|
||||||
|
a
|
||||||
|
/*
|
||||||
|
b
|
||||||
|
*/
|
||||||
|
=
|
||||||
|
/*
|
||||||
|
c
|
||||||
|
*/
|
||||||
|
1
|
||||||
|
/*
|
||||||
|
d
|
||||||
|
*/
|
||||||
|
;
|
||||||
|
|
||||||
p =
|
p =
|
||||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa { } a;
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa { } a;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue