chore: add treefmt formatting (nix fmt + pre-commit + CI check)#5
Merged
Conversation
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.
There was a problem hiding this comment.
Pull request overview
This PR introduces treefmt-based formatting to the repo via Nix (including nix fmt, a formatting check exposed as a flake check, a pre-commit hook installed in the dev shell, and a CI “format check” step), and applies an initial formatting pass across PureScript, Lua FFI, and Dhall sources.
Changes:
- Add treefmt-nix integration to the flake (
formatter,checks.formatting) and a devShell pre-commit hook that runsnix fmt. - Add formatter configuration files (
treefmt.nix,.tidyrc.json,.lua-format) and update CI to enforce formatting. - Reformat PureScript/Lua/Dhall sources to match the new formatting setup.
Reviewed changes
Copilot reviewed 19 out of 24 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| treefmt.nix | Adds treefmt configuration for Nix/Dhall/PureScript/Lua formatting. |
| flake.nix | Wires treefmt-nix into the flake and installs a devShell pre-commit hook. |
| flake.lock | Adds the treefmt-nix input lock entry. |
| .github/workflows/ci.yml | Adds a formatting check step; updates luacheck line length. |
| .gitignore | Ensures formatter config dotfiles are not ignored. |
| .tidyrc.json | Adds purs-tidy configuration. |
| .lua-format | Adds LuaFormatter configuration. |
| AGENTS.md | Documents formatting/linting commands and the formatting approach. |
| spago-test.dhall | Reformats Dhall configuration. |
| bench/Main.purs | Reformats a long string literal for purs-tidy output. |
| src/Data/String/Common.lua | Reformats Lua FFI code. |
| src/Data/String/CodePoints.lua | Reformats Lua FFI code. |
| src/Data/String/CodeUnits.purs | PureScript formatting pass (layout/indentation). |
| src/Data/String/CodePoints.purs | PureScript formatting pass (layout/indentation). |
| src/Data/String/NonEmpty/Internal.purs | PureScript formatting pass (layout/indentation). |
| src/Data/String/NonEmpty/CodeUnits.purs | PureScript formatting pass (layout/indentation). |
| src/Data/String/NonEmpty/CodePoints.purs | PureScript formatting pass (layout/indentation). |
| src/Data/String/NonEmpty/CaseInsensitive.purs | PureScript formatting pass (layout/indentation). |
| src/Data/Char/Gen.purs | PureScript formatting pass (layout/indentation). |
| test/Test/Data/String.purs | PureScript formatting pass (layout/indentation). |
| test/Test/Data/String/CodeUnits.purs | PureScript formatting pass (layout/indentation). |
| test/Test/Data/String/CaseInsensitive.purs | PureScript formatting pass (layout/indentation). |
| test/Test/Data/String/NonEmpty.purs | PureScript formatting pass (layout/indentation). |
| test/Test/Data/String/NonEmpty/CodeUnits.purs | PureScript formatting pass (layout/indentation). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-formatand wires treefmt-nix into the flake:nix fmtformats,checks.formattingis 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 thantreefmt --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-lengthraised to 130 to match.Diff. The bulk is the first
nix fmtpass over*.pursand the*.luaFFI. Verified locally: build +luacheck --max-line-length 130green + regression test.