mirror of
https://github.com/RGBCube/alejandra
synced 2025-07-29 19:47:45 +00:00
Allow tabs and spaces
This commit is contained in:
parent
04fe4d17dc
commit
d961847646
8 changed files with 59 additions and 1 deletions
|
@ -22,6 +22,7 @@ pub(crate) struct BuildCtx {
|
|||
pub pos_old: crate::position::Position,
|
||||
pub path: String,
|
||||
pub vertical: bool,
|
||||
pub indent: String,
|
||||
}
|
||||
|
||||
pub(crate) fn build(
|
||||
|
@ -99,7 +100,7 @@ fn build_step(
|
|||
add_token(
|
||||
builder,
|
||||
rnix::SyntaxKind::TOKEN_WHITESPACE,
|
||||
&format!("{0:<1$}", "", 2 * build_ctx.indentation),
|
||||
&build_ctx.indent.repeat(build_ctx.indentation),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ pub fn in_memory(
|
|||
path,
|
||||
pos_old: crate::position::Position::default(),
|
||||
vertical: true,
|
||||
indent,
|
||||
};
|
||||
|
||||
let after = crate::builder::build(&mut build_ctx, ast.node().into())
|
||||
|
|
6
src/alejandra/tests/indent/apply/in.nix
Normal file
6
src/alejandra/tests/indent/apply/in.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
foo =
|
||||
bar:
|
||||
baz:
|
||||
fnbody;
|
||||
}
|
4
src/alejandra/tests/indent/apply/out.nix
Normal file
4
src/alejandra/tests/indent/apply/out.nix
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
foo = bar: baz:
|
||||
fnbody;
|
||||
}
|
11
src/alejandra/tests/indent/attr_set/in.nix
Normal file
11
src/alejandra/tests/indent/attr_set/in.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
a = rec {
|
||||
a = {
|
||||
a = rec {
|
||||
a = {
|
||||
a = rec {a = {a = rec {a = {a = rec {a = {};};};};};};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
11
src/alejandra/tests/indent/attr_set/out.nix
Normal file
11
src/alejandra/tests/indent/attr_set/out.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
a = rec {
|
||||
a = {
|
||||
a = rec {
|
||||
a = {
|
||||
a = rec {a = {a = rec {a = {a = rec {a = {};};};};};};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
11
src/alejandra/tests/indent/list/in.nix
Normal file
11
src/alejandra/tests/indent/list/in.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
[
|
||||
# over indented
|
||||
1
|
||||
# under indented
|
||||
2
|
||||
# no indentation
|
||||
[1 2]
|
||||
[
|
||||
1 2 3
|
||||
]
|
||||
]
|
13
src/alejandra/tests/indent/list/out.nix
Normal file
13
src/alejandra/tests/indent/list/out.nix
Normal file
|
@ -0,0 +1,13 @@
|
|||
[
|
||||
# over indented
|
||||
1
|
||||
# under indented
|
||||
2
|
||||
# no indentation
|
||||
[1 2]
|
||||
[
|
||||
1
|
||||
2
|
||||
3
|
||||
]
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue