Skip to content

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

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

chore: add treefmt formatting (nix fmt + pre-commit + CI check)#2
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. LuaFormatter is kept over StyLua because it preserves the parentheses pslua's foreign-file parser requires; luacheck --max-line-length raised to 130 to match.

Diff. The bulk is the first nix fmt pass over *.purs and the *.lua FFI. Verified locally: build + luacheck --max-line-length 130 green + regression test.

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`. The bulk
of the diff is the first format pass.

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 introduces a standardized formatting workflow for the repo by wiring treefmt-nix into the flake (so nix fmt becomes the canonical formatter), adding a content-based formatting check for CI, and documenting the workflow. It also includes a first-pass reformat of existing PureScript and Lua FFI sources to match the configured formatters.

Changes:

  • Add treefmt-nix integration to the flake (formatter, checks.formatting) and install a pre-commit hook from the dev shell.
  • Add formatter configuration for Nix/Dhall/PureScript/Lua via treefmt.nix, .tidyrc.json, and .lua-format.
  • Add CI format-check step and update luacheck line-length budget; apply formatting across touched *.purs / FFI *.lua.

Reviewed changes

Copilot reviewed 9 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
treefmt.nix Adds treefmt-nix module config for nixfmt/dhall/purs-tidy/lua-format and global excludes.
flake.nix Wires treefmt-nix into formatter/checks.formatting and installs a pre-commit hook via shellHook.
flake.lock Pins the new treefmt-nix input.
AGENTS.md Documents updated lint/format commands and explains formatting approach.
.tidyrc.json Configures purs-tidy formatting behavior.
.lua-format Configures LuaFormatter rules and line-length budget assumptions.
.gitignore Ensures new dotfile configs are not ignored.
.github/workflows/ci.yml Adds nix fmt && git diff --exit-code format check and updates luacheck max line length.
src/Control/Monad/ST/Uncurried.purs Formatting-only changes from purs-tidy.
src/Control/Monad/ST/Uncurried.lua Formatting-only changes from LuaFormatter.
src/Control/Monad/ST/Internal.purs Formatting-only changes (layout/type signature wrapping).

💡 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 flake.nix
@Unisay Unisay merged commit b73b949 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