Skip to content

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

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

chore: add treefmt formatting (nix fmt + pre-commit + CI check)#4
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.

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 rolls out a repo-wide formatting setup using treefmt-nix, wiring nix fmt into the flake and adding a CI format-check step, alongside the initial formatter pass over existing PureScript/Lua sources.

Changes:

  • Add treefmt.nix + formatter configs (.tidyrc.json, .lua-format) and expose nix fmt via the flake formatter.
  • Add a CI “Format check” step using nix fmt && git diff --exit-code, and align luacheck’s max line length to 130.
  • Apply the first formatting pass to *.purs and Lua FFI.

Reviewed changes

Copilot reviewed 8 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
treefmt.nix Defines treefmt-nix programs/formatters and global excludes.
flake.nix Adds treefmt-nix input, exposes formatter/checks.formatting, and installs a pre-commit hook via shellHook.
flake.lock Locks treefmt-nix input.
AGENTS.md Documents formatting workflow (nix fmt + content-based check) and updates luacheck command.
.tidyrc.json Configures purs-tidy formatting options.
.lua-format Configures LuaFormatter to stay within luacheck’s line-length constraints.
.gitignore Un-ignores the new formatter config dotfiles.
.github/workflows/ci.yml Adds format-check step and updates luacheck invocation.
src/Data/Function/Uncurried.purs Formatter-driven layout changes for foreign imports and signatures.
src/Data/Function/Uncurried.lua Formatter-driven reflow of nested function returns while preserving required parentheses wrapping.

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

Comment thread flake.nix
@Unisay Unisay merged commit e2d7a31 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