Skip to content

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

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

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

Conversation

@Unisay

@Unisay Unisay commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

Pilot of the ecosystem formatting setup (ADR 0007). Wires treefmt via treefmt-nix and formats the tree.

Tooling. treefmt.nix runs nixfmt, dhall format, purs-tidy (.tidyrc.json) and LuaFormatter (.lua-format). LuaFormatter is kept over StyLua because it preserves the parentheses pslua's foreign-file parser requires; the FFI keeps its compact one-line style with a 130-column budget, matching the raised luacheck --max-line-length 130.

Wiring. nix fmt formats; the flake exposes checks.formatting; the dev shell installs a pre-commit hook; CI gains a format-check step. The check is content-based (nix fmt && git diff --exit-code) rather than treefmt --ci, because the in-place formatters bump mtime even when content is unchanged, which trips treefmt's --fail-on-change.

Diff. Most of the changes are the first format pass over *.purs and the *.lua FFI. Verified locally: build, regression test, luacheck --max-line-length 130, and the content-based format check all pass.

This is the template for rolling the same setup across the other forks + compiler.

@Unisay Unisay requested a review from Copilot June 14, 2026 20:22
@Unisay Unisay self-assigned this Jun 14, 2026

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 pilots an ecosystem-wide formatting setup by integrating treefmt (via treefmt-nix) into the flake, wiring nix fmt as the unified formatter entrypoint, and enforcing formatting via a content-based check in CI (plus an installed pre-commit hook in the dev shell).

Changes:

  • Add treefmt.nix configuration and expose formatter / checks.formatting from the flake.
  • Add CI “Format check” step (nix fmt && git diff --exit-code) and document formatting/linting commands.
  • Apply an initial formatting pass across PureScript and Lua (FFI) sources and configs.

Reviewed changes

Copilot reviewed 11 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
treefmt.nix Defines tree-wide formatting rules (nixfmt, dhall, purs-tidy, lua-format) and excludes generated/vendor directories.
flake.nix Adds treefmt-nix, exposes formatter + formatting check, and installs a pre-commit hook from the dev shell.
flake.lock Locks the new treefmt-nix input.
.github/workflows/ci.yml Adds a content-based formatting verification step in CI.
AGENTS.md Documents the new nix fmt workflow and updated luacheck line-length setting.
.tidyrc.json Adds purs-tidy configuration for PureScript formatting.
.lua-format Adds LuaFormatter configuration for FFI formatting.
.gitignore Ensures the new dotfiles are tracked despite the broad dotfile ignore rule.
spago.dhall Formatting cleanup (whitespace).
src/Effect/Uncurried.purs PureScript formatting (layout/line breaks) for readability and consistency.
src/Effect/Uncurried.lua Lua FFI formatting (compact style consistent with formatter config).
src/Effect.purs PureScript formatting adjustments (exports + foreign import layout).
src/Effect.lua Lua formatting (compact style).
test/regression/uncurried.lua Test formatting adjustments.

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

Comment thread flake.nix Outdated
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.
@Unisay Unisay merged commit 59ac8de into master Jun 14, 2026
1 check passed
@Unisay Unisay deleted the chore/treefmt branch June 14, 2026 20:36
This was referenced Jun 14, 2026
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