From 66511538044ac043fe893486816d74d6c6445009 Mon Sep 17 00:00:00 2001 From: Rasmus Rendal Date: Thu, 23 Jul 2026 15:36:48 +0200 Subject: [PATCH] feat(formatting): Add shfmt Upstreamed from another Famedly repository, so you know these formatter options are popular. --- nix/general/formatting.nix | 9 +++++++++ treefmt.toml | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/nix/general/formatting.nix b/nix/general/formatting.nix index 40c16b7..745628f 100644 --- a/nix/general/formatting.nix +++ b/nix/general/formatting.nix @@ -13,6 +13,15 @@ excludes = config.filegen.generatedFiles; }; + + # We include shfmt in general, because all projects probably use shell scripts + programs.shfmt = { + enable = true; + # Setting the indent_size to 0 uses tabs for indentation + indent_size = 0; + }; + settings.formatter.shfmt.command = "shfmt"; + }; filegen.settings.files = [ diff --git a/treefmt.toml b/treefmt.toml index b06e925..1ecd6cc 100644 --- a/treefmt.toml +++ b/treefmt.toml @@ -29,3 +29,9 @@ command = "rustfmt" excludes = [] includes = ["*.rs"] options = ["--config", "skip_children=true", "--edition", "2024"] + +[formatter.shfmt] +command = "shfmt" +excludes = [] +includes = ["*.sh", "*.bash", "*.envrc", "*.envrc.*"] +options = ["-w", "-i", "0", "-s"]