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

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

CopilotAI 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 repo-wide, Nix-flake-integrated formatting via treefmt (exposed as nix fmt), along with a CI format check and a dev-shell-installed pre-commit hook, and applies the first formatting pass across PureScript and Lua FFI sources.

Changes:

  • Add treefmt-nix integration in flake.nix (formatter + checks.formatting) and add a CI “Format check” step.
  • Add treefmt configuration (treefmt.nix) plus formatter configs for purs-tidy and LuaFormatter (.tidyrc.json, .lua-format), and update docs/ignore rules accordingly.
  • Apply formatting updates across existing *.purs sources, Lua FFI, regression tests, and benchmarks; align luacheck line-length budget to 130.

Reviewed changes

Copilot reviewed 17 out of 22 changed files in this pull request and generated 8 comments.

Show a summary per file
FileDescription
treefmt.nixDefines treefmt programs for Nix/Dhall/PureScript/Lua and global excludes.
flake.nixWires treefmt-nix into the flake, exposes formatter/check, and installs a pre-commit hook in the dev shell.
flake.lockAdds the treefmt-nix flake input lock entry.
.github/workflows/ci.ymlAdds --max-line-length 130 to luacheck and introduces a format-check step.
AGENTS.mdDocuments formatting commands and rationale (treefmt + LuaFormatter parentheses requirement).
.tidyrc.jsonAdds purs-tidy configuration used by treefmt.
.lua-formatAdds LuaFormatter configuration for Lua FFI formatting constraints.
.gitignoreEnsures new formatter config dotfiles are not ignored.
src/Data/Array.pursFormatting-only changes (line wraps/indentation).
src/Data/Array.luaFormatting-only changes to Lua FFI code style.
src/Data/Array/NonEmpty.pursFormatting-only changes (exports, type signatures, layout).
src/Data/Array/NonEmpty/Internal.pursFormatting-only changes to derived instance declarations.
src/Data/Array/ST.pursFormatting-only changes to foreign import type formatting.
src/Data/Array/ST/Iterator.pursFormatting-only changes to type signature layout.
bench/Data/Array.pursFormatting-only changes to let layout.
test/regression/array_st.luaFormatting-only changes to Lua regression test formatting.
test/Test/Data/UndefinedOr.pursFormatting-only changes to foreign import type layout.
test/Test/Data/Array/ST/Partial.pursFormatting-only changes (array literal spacing).
test/Test/Data/Array/ST.pursFormatting-only changes (wrapping/indentation).
test/Test/Data/Array/Partial.pursFormatting-only changes (array literal spacing).
test/Test/Data/Array/NonEmpty.pursFormatting-only changes (wrapping/indentation).
test/Test/Data/Array.pursFormatting-only changes (wrapping/indentation).

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

Comment threadflake.nix
Comment threadtest/Test/Data/Array/ST.purs
Comment threadtest/Test/Data/Array/NonEmpty.purs
Comment threadtest/Test/Data/Array/NonEmpty.purs
Comment threadtest/Test/Data/Array/NonEmpty.purs
Comment threadtest/Test/Data/Array.purs
Comment threadtest/Test/Data/Array.purs
Comment threadtest/Test/Data/Array.purs
@Unisay
Unisay merged commit de5d9d8 into masterJun 15, 2026
2 checks passed
@Unisay
Unisay deleted the chore/treefmt branch June 15, 2026 08:08
Sign up for freeto 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

@Unisay