diff --git a/go/default.nix b/go/default.nix index 819ac13a9..598b9239e 100644 --- a/go/default.nix +++ b/go/default.nix @@ -262,6 +262,14 @@ let # gofumpt/gotools are the same igloo `pkgs` builds the dev-shell carries, # so the Go output matches the dev-loop formatter. null on the non-flake # `import ./go/default.nix` path (treelint absent). + # tommy's conformist codegen linter driver ([linter.tommy-codegen]), owned by + # the tommy flake so the pinned tommy input resolves which tommy backs it (no + # per-repo driver duplication). It bakes that tommy in and skips when go is + # absent. Regenerates the *_tommy.go companions so they land in the + # `conformist --commit` chore; `just build-go-generate` remains the + # NATO-ordered regen path. + tommyCodegen = tommy.packages.${system}.conformist-tommy-codegen; + treelint-fmt = if treelint == null then null @@ -275,6 +283,13 @@ let pkgs.nixfmt pkgs.shfmt pkgs.shellcheck + # tommy (TOML formatter, [formatter.tommy]) + go + the codegen driver + # ([linter.tommy-codegen]), so the wrapper resolves the formatter and + # the codegen repair regen. go is needed by `tommy generate`'s + # go/packages analysis in repair mode. + tommy.packages.${system}.default + pkgs.go_1_26 + tommyCodegen ]; text = ''exec conformist "$@"''; }; diff --git a/treelint.toml b/treelint.toml index 218525362..95eaec681 100644 --- a/treelint.toml +++ b/treelint.toml @@ -53,6 +53,13 @@ command = "shfmt" options = ["-w", "-i", "2", "-s", "-ci"] includes = ["*.sh", "*.bash"] +# TOML via tommy's CST-preserving formatter (`tommy fmt`). treelint.toml itself +# is excluded above (intentional layout). +[formatter.tommy] +command = "tommy" +options = ["fmt"] +includes = ["*.toml"] + # Linter: shellcheck runs read-only in `treelint check` (no repair-command, so # it is a no-op in repair mode). Catches shell bugs the formatters miss. [linter.shellcheck] @@ -61,3 +68,19 @@ includes = ["*.sh", "*.bash"] # go/vimdiff.bash is the vendored upstream git-vimdiff mergetool test harness; # it carries ~40 shellcheck findings we don't own. shfmt still formats it. excludes = ["go/vimdiff.bash"] + +# tommy codegen as a REPAIR linter: `treelint` / `conformist --commit` runs +# `tommy generate` for every `//go:generate tommy generate` source file, so the +# regenerated *_tommy.go companions land in the auto-fix chore. The driver +# self-gates on tommy + go (present on the treelint-fmt wrapper PATH), so it is a +# no-op where the toolchain is absent. The CHECK command is a deliberate no-op +# (`true`) so `treelint check` never reports false codegen drift — `tommy +# generate --check` compares against tommy's raw render, which differs from the +# committed file once it is re-run through gofumpt (see `just build-go-generate` +# / `codemod-go-fmt`); true staleness stays gated by that recipe. +# passes-files=false: the driver walks the tree for the directive itself. +[linter.tommy-codegen] +command = "true" +repair-command = "conformist-tommy-codegen" +includes = ["*.go", "**/*.go"] +passes-files = false