Skip to content

Commit 1b9b6f9

Browse files
authored
wgslfmt: init (#448)
1 parent 5b4ee75 commit 1b9b6f9

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

README.md

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

224224
<!-- BEGIN mdsh -->
225-
`treefmt-nix` currently supports 120 formatters:
225+
`treefmt-nix` currently supports 121 formatters:
226226

227227
* [actionlint](programs/actionlint.nix)
228228
* [aiken](programs/aiken.nix)
@@ -338,6 +338,7 @@ functions.
338338
* [typos](programs/typos.nix)
339339
* [typstfmt](programs/typstfmt.nix)
340340
* [typstyle](programs/typstyle.nix)
341+
* [wgslfmt](programs/wgslfmt.nix)
341342
* [xmllint](programs/xmllint.nix)
342343
* [yamlfmt](programs/yamlfmt.nix)
343344
* [yapf](programs/yapf.nix)

examples/formatter-wgslfmt.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.wgslfmt]
3+
command = "wgslfmt"
4+
excludes = []
5+
includes = ["*.wgsl"]
6+
options = []

programs/wgslfmt.nix

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
lib,
3+
config,
4+
mkFormatterModule,
5+
...
6+
}:
7+
let
8+
cfg = config.programs.wgslfmt;
9+
in
10+
{
11+
meta.maintainers = [ ];
12+
13+
imports = [
14+
(mkFormatterModule {
15+
name = "wgslfmt";
16+
package = "wgsl-analyzer";
17+
mainProgram = "wgslfmt";
18+
includes = [ "*.wgsl" ];
19+
})
20+
];
21+
22+
options.programs.wgslfmt = {
23+
tabs = lib.mkEnableOption "Use tabs for indentation (instead of spaces)";
24+
};
25+
26+
config = lib.mkIf cfg.enable {
27+
settings.formatter.wgslfmt.options = lib.optional cfg.tabs "--tabs";
28+
};
29+
}

0 commit comments

Comments
 (0)