Skip to content

Commit 63d63d9

Browse files
committed
clippy: init
1 parent 337a4fe commit 63d63d9

3 files changed

Lines changed: 53 additions & 1 deletion

File tree

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 126 formatters:
225+
`treefmt-nix` currently supports 128 formatters:
226226

227227
* [actionlint](programs/actionlint.nix)
228228
* [aiken](programs/aiken.nix)
@@ -238,6 +238,7 @@ functions.
238238
* [cabal-gild](programs/cabal-gild.nix)
239239
* [clang-format](programs/clang-format.nix)
240240
* [clang-tidy](programs/clang-tidy.nix)
241+
* [clippy](programs/clippy.nix)
241242
* [cljfmt](programs/cljfmt.nix)
242243
* [cmake-format](programs/cmake-format.nix)
243244
* [csharpier](programs/csharpier.nix)

examples/formatter-clippy.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.clippy]
3+
command = "clippy"
4+
excludes = []
5+
includes = ["*.rs"]
6+
options = ["--edition", "2024"]

programs/clippy.nix

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
lib,
3+
config,
4+
mkFormatterModule,
5+
...
6+
}:
7+
let
8+
cfg = config.programs.clippy;
9+
in
10+
{
11+
meta.maintainers = [
12+
"DigitalBrewStudios/Treefmt-nix"
13+
];
14+
15+
imports = [
16+
(mkFormatterModule {
17+
name = "clippy";
18+
mainProgram = "clippy";
19+
includes = [ "*.rs" ];
20+
})
21+
];
22+
23+
options.programs.clippy = {
24+
denyWarnings = lib.mkEnableOption "clippy to denyWarnings";
25+
edition = lib.mkOption {
26+
type = lib.types.str;
27+
default = "2024";
28+
description = ''
29+
Rust edition to target when linting
30+
'';
31+
};
32+
};
33+
34+
config = lib.mkIf cfg.enable {
35+
settings.formatter.clippy = {
36+
options = [
37+
"--edition"
38+
cfg.edition
39+
]
40+
++ lib.optionals cfg.denyWarnings [
41+
"--deny-warnings"
42+
];
43+
};
44+
};
45+
}

0 commit comments

Comments
 (0)