Skip to content

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

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

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

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 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 runs nix 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
FileDescription
treefmt.nixAdds treefmt configuration for Nix/Dhall/PureScript/Lua formatting.
flake.nixWires treefmt-nix into the flake and installs a devShell pre-commit hook.
flake.lockAdds the treefmt-nix input lock entry.
.github/workflows/ci.ymlAdds a formatting check step; updates luacheck line length.
.gitignoreEnsures formatter config dotfiles are not ignored.
.tidyrc.jsonAdds purs-tidy configuration.
.lua-formatAdds LuaFormatter configuration.
AGENTS.mdDocuments formatting/linting commands and the formatting approach.
spago-test.dhallReformats Dhall configuration.
bench/Main.pursReformats a long string literal for purs-tidy output.
src/Data/String/Common.luaReformats Lua FFI code.
src/Data/String/CodePoints.luaReformats Lua FFI code.
src/Data/String/CodeUnits.pursPureScript formatting pass (layout/indentation).
src/Data/String/CodePoints.pursPureScript formatting pass (layout/indentation).
src/Data/String/NonEmpty/Internal.pursPureScript formatting pass (layout/indentation).
src/Data/String/NonEmpty/CodeUnits.pursPureScript formatting pass (layout/indentation).
src/Data/String/NonEmpty/CodePoints.pursPureScript formatting pass (layout/indentation).
src/Data/String/NonEmpty/CaseInsensitive.pursPureScript formatting pass (layout/indentation).
src/Data/Char/Gen.pursPureScript formatting pass (layout/indentation).
test/Test/Data/String.pursPureScript formatting pass (layout/indentation).
test/Test/Data/String/CodeUnits.pursPureScript formatting pass (layout/indentation).
test/Test/Data/String/CaseInsensitive.pursPureScript formatting pass (layout/indentation).
test/Test/Data/String/NonEmpty.pursPureScript formatting pass (layout/indentation).
test/Test/Data/String/NonEmpty/CodeUnits.pursPureScript formatting pass (layout/indentation).

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

Comment threadtreefmt.nix
Comment threadtreefmt.nix
Comment threadflake.nix
Comment threadsrc/Data/String/NonEmpty/Internal.purs
@Unisay
Unisay merged commit 10838df into masterJun 15, 2026
2 checks passed
@Unisay
Unisay deleted the chore/treefmt branch June 15, 2026 08:09
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