Skip to content

Commit 5148be9

Browse files
committed
feat: switch to treefmt
1 parent 0412a90 commit 5148be9

File tree

2 files changed

+79
-6
lines changed

2 files changed

+79
-6
lines changed

flake.nix

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,14 @@
2525
config,
2626
...
2727
}:
28+
let
29+
clang-tools = pkgs.llvmPackages_19.clang-tools;
30+
in
2831
{
2932
packages = {
3033
default = pkgs.callPackage ./nix { };
3134
};
32-
formatter = pkgs.nixfmt-rfc-style;
35+
formatter = pkgs.treefmt;
3336

3437
# the development environment for this project
3538
# provides `cmake`, `clang`, `clangd`, and all required dependencies (boost, opencv, libtorch)
@@ -39,10 +42,9 @@
3942
'';
4043
stdenv = pkgs.llvmPackages_19.stdenv;
4144
packages =
42-
with pkgs;
4345
[
44-
llvmPackages_19.clang-tools
45-
mesonlsp
46+
pkgs.mesonlsp
47+
clang-tools
4648
]
4749
++ config.packages.default.buildInputs
4850
++ config.packages.default.nativeBuildInputs;
@@ -58,10 +60,17 @@
5860
};
5961

6062
git-hooks.hooks = {
61-
clang-format.enable = true;
6263
shellcheck.enable = true;
63-
nixfmt-rfc-style.enable = true;
64+
treefmt.enable = true;
65+
treefmt.settings.formatters = [
66+
pkgs.nixfmt-rfc-style
67+
clang-tools
68+
pkgs.taplo
69+
pkgs.meson
70+
pkgs.nodePackages_latest.prettier
71+
];
6472
};
73+
6574
};
6675
};
6776
};

treefmt.toml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
excludes = [
2+
"flake.lock",
3+
"*.png",
4+
"*.jpg",
5+
"*.jpeg",
6+
".clang-format",
7+
".clangd",
8+
".envrc",
9+
".gitignore",
10+
]
11+
12+
[formatter.nixfmt-rfc-style]
13+
command = "nixfmt"
14+
excludes = []
15+
includes = ["*.nix"]
16+
options = []
17+
18+
[formatter.clang-format]
19+
command = "clang-format"
20+
excludes = []
21+
includes = ["*.c", "*.cc", "*.cpp", "*.h", "*.hh", "*.hpp", "*.proto"]
22+
options = ["-i"]
23+
24+
[formatter.meson]
25+
command = "meson"
26+
excludes = []
27+
includes = [
28+
"meson.build",
29+
"meson.options",
30+
"meson_options.txt",
31+
"*/meson.build",
32+
"*/meson.options",
33+
"*/meson_options.txt",
34+
]
35+
options = ["fmt", "-i"]
36+
37+
[formatter.taplo]
38+
command = "taplo"
39+
excludes = []
40+
includes = ["*.toml"]
41+
options = ["format"]
42+
43+
[formatter.prettier]
44+
command = "prettier"
45+
excludes = []
46+
includes = [
47+
"*.cjs",
48+
"*.css",
49+
"*.html",
50+
"*.js",
51+
"*.json",
52+
"*.json5",
53+
"*.jsx",
54+
"*.md",
55+
"*.mdx",
56+
"*.mjs",
57+
"*.scss",
58+
"*.ts",
59+
"*.tsx",
60+
"*.vue",
61+
"*.yaml",
62+
"*.yml",
63+
]
64+
options = ["--write"]

0 commit comments

Comments
 (0)