Skip to content

Commit a05be41

Browse files
authored
Add cabal-gild, a cabal formatter (#361)
1 parent 6a846d3 commit a05be41

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ functions.
221221
<!-- `> bash ./supported-programs.sh` -->
222222

223223
<!-- BEGIN mdsh -->
224-
`treefmt-nix` currently supports 107 formatters:
224+
`treefmt-nix` currently supports 108 formatters:
225225

226226
* [actionlint](programs/actionlint.nix)
227227
* [alejandra](programs/alejandra.nix)
@@ -232,6 +232,7 @@ functions.
232232
* [buf](programs/buf.nix)
233233
* [buildifier](programs/buildifier.nix)
234234
* [cabal-fmt](programs/cabal-fmt.nix)
235+
* [cabal-gild](programs/cabal-gild.nix)
235236
* [clang-format](programs/clang-format.nix)
236237
* [cljfmt](programs/cljfmt.nix)
237238
* [cmake-format](programs/cmake-format.nix)

examples/formatter-cabal-gild.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Example generated by ../examples.sh
2+
[formatter.cabal-gild]
3+
command = "cabal-gild-wrapper"
4+
excludes = []
5+
includes = ["*.cabal", "cabal.project", "cabal.project.local"]
6+
options = []

programs/cabal-gild.nix

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
mkFormatterModule,
3+
lib,
4+
config,
5+
pkgs,
6+
...
7+
}:
8+
9+
let
10+
cfg = config.programs.cabal-gild;
11+
in
12+
{
13+
meta.maintainers = [ ];
14+
15+
imports = [
16+
(mkFormatterModule {
17+
name = "cabal-gild";
18+
package = [
19+
"haskellPackages"
20+
"cabal-gild"
21+
];
22+
includes = [
23+
"*.cabal"
24+
"cabal.project"
25+
"cabal.project.local"
26+
];
27+
})
28+
];
29+
30+
config = lib.mkIf cfg.enable {
31+
settings.formatter.cabal-gild = {
32+
# cabal-gild doesn't support multiple file targets
33+
# https://github.com/tfausak/cabal-gild/issues/35
34+
command = pkgs.writeShellApplication {
35+
name = "cabal-gild-wrapper";
36+
text = ''
37+
for file in "$@"; do
38+
${lib.getExe cfg.package} --io="$file"
39+
done
40+
'';
41+
};
42+
};
43+
};
44+
}

0 commit comments

Comments
 (0)