Skip to content

Commit 14a5573

Browse files
committed
feat: simplify flag
1 parent 5eda4ee commit 14a5573

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

examples/formatter-shfmt.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
command = "shfmt"
44
excludes = []
55
includes = ["*.sh", "*.bash", "*.envrc", "*.envrc.*"]
6-
options = ["-s", "-w", "-i", "2"]
6+
options = ["-w", "-i", "2", "-s"]

programs/shfmt.nix

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ in
1717
imports = [
1818
(mkFormatterModule {
1919
name = "shfmt";
20-
args = [
21-
"-s"
22-
"-w"
23-
];
20+
args = [ "-w" ];
2421
includes = [
2522
"*.sh"
2623
"*.bash"
@@ -42,12 +39,22 @@ in
4239
shfmt](https://github.com/patrickvane/shfmt#description).
4340
'';
4441
};
42+
43+
simplify = lib.mkOption {
44+
type = lib.types.bool;
45+
default = true;
46+
description = ''
47+
Enables the `-s` (`--simplify`) flag, which simplifies code where possible.
48+
'';
49+
};
4550
};
4651

4752
config = lib.mkIf cfg.enable {
48-
settings.formatter.shfmt.options = lib.optionals (!isNull cfg.indent_size) [
49-
"-i"
50-
(toString cfg.indent_size)
51-
];
53+
settings.formatter.shfmt.options =
54+
(lib.optionals (!isNull cfg.indent_size) [
55+
"-i"
56+
(toString cfg.indent_size)
57+
])
58+
++ (lib.optionals (cfg.simplify) [ "-s" ]);
5259
};
5360
}

0 commit comments

Comments
 (0)