Skip to content

Commit cf48c8c

Browse files
committed
add formatter for python
1 parent 0bce18a commit cf48c8c

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

flake.nix

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
inputs.treefmt-nix.flakeModule
2626
];
2727

28-
perSystem = { config, ... }: {
28+
perSystem = { config, pkgs, lib, ... }: {
2929
treefmt = {
3030
projectRootFile = "flake.nix";
3131
programs.mdsh.enable = true;
@@ -35,6 +35,18 @@
3535
programs.prettier.enable = true;
3636
settings.formatter.prettier.options = [ "--prose-wrap" "always" ];
3737
settings.formatter.shellcheck.options = [ "-s" "bash" ];
38+
settings.formatter.python = {
39+
command = "sh";
40+
options = [
41+
"-eucx"
42+
''
43+
${lib.getExe pkgs.ruff} --fix "$@"
44+
${lib.getExe pkgs.black} "$@"
45+
''
46+
"--" # this argument is ignored by bash
47+
];
48+
includes = [ "*.py" ];
49+
};
3850
};
3951
formatter = config.treefmt.build.wrapper;
4052
};

0 commit comments

Comments
 (0)