Skip to content

Commit 65b4eb0

Browse files
committed
add formatter for python
1 parent 0bf2cd3 commit 65b4eb0

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

treefmt/flake-module.nix

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
imports = [
33
inputs.treefmt-nix.flakeModule
44
];
5-
perSystem = { config, ... }: {
5+
perSystem = { config, lib, pkgs, ... }: {
66
treefmt = {
77
projectRootFile = "flake.nix";
88
programs.mdsh.enable = true;
@@ -11,6 +11,18 @@
1111
programs.shfmt.enable = true;
1212
programs.deno.enable = true;
1313
settings.formatter.shellcheck.options = [ "-s" "bash" ];
14+
settings.formatter.python = {
15+
command = "sh";
16+
options = [
17+
"-eucx"
18+
''
19+
${lib.getExe pkgs.ruff} --fix "$@"
20+
${lib.getExe pkgs.ruff} "fmt" "$@"
21+
''
22+
"--" # this argument is ignored by bash
23+
];
24+
includes = [ "*.py" ];
25+
};
1426
};
1527
formatter = config.treefmt.build.wrapper;
1628
};

0 commit comments

Comments
 (0)