Skip to content

Commit 9828d43

Browse files
committed
feat: rebase Vladimir's pr
1 parent e2c843c commit 9828d43

File tree

47 files changed

+35
-6416
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+35
-6416
lines changed

src/alejandra/src/builder.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::config::Config;
2+
use crate::config::Indentation;
23

34
#[derive(PartialEq)]
45
pub(crate) enum Step {
@@ -15,14 +16,13 @@ pub(crate) enum Step {
1516

1617
#[derive(Clone)]
1718
pub(crate) struct BuildCtx {
18-
pub _config: Config,
19+
pub config: Config,
1920
pub force_wide: bool,
2021
pub force_wide_success: bool,
2122
pub indentation: usize,
2223
pub pos_old: crate::position::Position,
2324
pub path: String,
2425
pub vertical: bool,
25-
pub indent: String,
2626
}
2727

2828
pub(crate) fn build(
@@ -100,7 +100,12 @@ fn build_step(
100100
add_token(
101101
builder,
102102
rnix::SyntaxKind::TOKEN_WHITESPACE,
103-
&build_ctx.indent.repeat(build_ctx.indentation),
103+
&match build_ctx.config.indentation {
104+
Indentation::FourSpaces => " ",
105+
Indentation::Tabs => "\t",
106+
Indentation::TwoSpaces => " ",
107+
}
108+
.repeat(build_ctx.indentation),
104109
);
105110
}
106111
}

src/alejandra/src/config.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,19 @@ use serde::Deserialize;
22

33
/// Configuration used by the formatter
44
#[derive(Clone, Copy, Default, Deserialize)]
5-
pub struct Config {}
5+
pub struct Config {
6+
/// Indentation to use
7+
pub indentation: Indentation,
8+
}
9+
10+
#[derive(Clone, Copy, Default, Deserialize)]
11+
/// Indentation options
12+
pub enum Indentation {
13+
/// Four spaces
14+
FourSpaces,
15+
/// Tabs
16+
Tabs,
17+
#[default]
18+
/// Two spaces
19+
TwoSpaces,
20+
}

src/alejandra/src/format.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,13 @@ pub fn in_memory(
3232
}
3333

3434
let mut build_ctx = crate::builder::BuildCtx {
35-
_config: config,
35+
config,
3636
force_wide: false,
3737
force_wide_success: true,
3838
indentation: 0,
3939
path,
4040
pos_old: crate::position::Position::default(),
4141
vertical: true,
42-
indent,
4342
};
4443

4544
let after = crate::builder::build(&mut build_ctx, ast.node().into())

src/alejandra/tests/cases/apply/out.nix

-112
This file was deleted.

src/alejandra/tests/cases/assert/out.nix

-44
This file was deleted.

src/alejandra/tests/cases/attr_set/out.nix

-138
This file was deleted.

0 commit comments

Comments
 (0)