Skip to content

chore: add treefmt formatting (nix fmt + pre-commit + CI check)#5

Merged
Unisay merged 1 commit into
masterfrom
chore/treefmt
Jun 15, 2026
Merged

chore: add treefmt formatting (nix fmt + pre-commit + CI check)#5
Unisay merged 1 commit into
masterfrom
chore/treefmt

Conversation

@Unisay

@Unisay Unisay commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

Roll the ecosystem formatting setup (ADR 0007, piloted in purescript-lua/purescript-lua-effect#6) onto this fork.

Tooling. Copies treefmt.nix/.tidyrc.json/.lua-format and wires treefmt-nix into the flake: nix fmt formats, checks.formatting is exposed, the dev shell installs a content-based pre-commit hook, and CI gains a format-check step. The check is content-based (nix fmt && git diff --exit-code) rather than treefmt --ci, since the in-place formatters bump mtime even when content is unchanged.

Fork specifics. No hand-written FFI here, so luacheck stays over the generated dist/; the --max-line-length is raised to 130 to match the Lua budget. The .purs was already purs-tidy clean, so the diff is just the tooling wiring. Verified locally: build + luacheck --max-line-length 130 green.

Wire treefmt via treefmt-nix: nixfmt, dhall format, purs-tidy (.tidyrc.json)
and LuaFormatter for the FFI (.lua-format, kept over StyLua because it
preserves the parentheses pslua's parser needs). `nix fmt` formats; the dev
shell installs a content-based pre-commit hook and CI runs
`nix fmt && git diff --exit-code` (content-based, since the in-place
formatters bump mtime and would trip treefmt --fail-on-change). Lua lines
budget 130 cols, matching the raised `luacheck --max-line-length`. This fork
has no hand-written FFI, so luacheck stays over the generated dist/.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a repo-wide formatting setup using treefmt-nix, wiring it into the flake so nix fmt works locally, a formatting check is exposed via flake checks, CI enforces formatting, and the dev shell installs a pre-commit hook to block unformatted commits.

Changes:

  • Add treefmt.nix and wire treefmt-nix into flake.nix (formatter + checks.formatting) with a dev-shell pre-commit hook.
  • Introduce formatter configs for PureScript and Lua (.tidyrc.json, .lua-format) and ensure they’re not ignored by git.
  • Update CI and contributor docs to include formatting and updated luacheck settings.

Reviewed changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
treefmt.nix Defines treefmt formatters (nix/dhall/purs-tidy/lua-format) and global excludes.
flake.nix Adds treefmt-nix input, exposes formatter/checks.formatting, and installs a pre-commit hook in devShell.
flake.lock Locks the new treefmt-nix dependency.
AGENTS.md Documents formatting (nix fmt) and updates luacheck line-length guidance.
.tidyrc.json Adds purs-tidy formatting configuration.
.lua-format Adds LuaFormatter configuration.
.gitignore Unignores the new formatter config dotfiles so they can be committed.
.github/workflows/ci.yml Adds a nix fmt && git diff --exit-code formatting check step and updates luacheck flags.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread treefmt.nix
Comment thread treefmt.nix
Comment thread flake.nix
Comment thread .lua-format
@Unisay Unisay merged commit e470eb9 into master Jun 15, 2026
2 checks passed
@Unisay Unisay deleted the chore/treefmt branch June 15, 2026 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants