Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
chore: add treefmt formatting (nix fmt + pre-commit + CI check)#2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| /.* | ||
| !/.gitignore | ||
| !/.github/ | ||
| !/.tidyrc.json | ||
| !/.lua-format | ||
| /output/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # LuaFormatter config for the hand-written FFI under src/. | ||
| # 2-space indent. Keep simple functions on one line; column_limit sits a few | ||
| # columns under luacheck's 130 limit because lua-format under-counts the leading | ||
| # indent and trailing comma, so this keeps every emitted line within 130. | ||
| indent_width: 2 | ||
| use_tab: false | ||
| column_limit: 126 | ||
| continuation_indent_width: 2 | ||
| keep_simple_function_one_line: true | ||
| keep_simple_control_block_one_line: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "importSort": "source", | ||
| "importWrap": "source", | ||
| "indent": 2, | ||
| "operatorsFile": null, | ||
| "ribbon": 1, | ||
| "typeArrowPlacement": "first", | ||
| "unicode": "source", | ||
| "width": 80 | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -9,16 +9,33 @@ | ||
| inputs.nixpkgs.follows = "nixpkgs"; | ||
| }; | ||
| pslua.url = "github:purescript-lua/purescript-lua"; | ||
| treefmt-nix = { | ||
| url = "github:numtide/treefmt-nix"; | ||
| inputs.nixpkgs.follows = "nixpkgs"; | ||
| }; | ||
| }; | ||
| outputs = { self, nixpkgs, flake-utils, purescript-overlay, pslua }: | ||
| flake-utils.lib.eachDefaultSystem (system: | ||
| outputs = | ||
| { | ||
| self, | ||
| nixpkgs, | ||
| flake-utils, | ||
| purescript-overlay, | ||
| pslua, | ||
| treefmt-nix, | ||
| }: | ||
| flake-utils.lib.eachDefaultSystem ( | ||
| system: | ||
| let | ||
| pkgs = import nixpkgs { | ||
| inherit system; | ||
| overlays = [ purescript-overlay.overlays.default ]; | ||
| }; | ||
| in { | ||
| treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix; | ||
| in | ||
| { | ||
| formatter = treefmtEval.config.build.wrapper; | ||
| checks.formatting = treefmtEval.config.build.check self; | ||
| devShell = pkgs.mkShell { | ||
| buildInputs = with pkgs; [ | ||
| dhall | ||
| @@ -31,8 +48,26 @@ | ||
| spago-bin.spago-0_21_0 | ||
| treefmt | ||
| ]; | ||
| # Install a content-based pre-commit hook. It compares the working | ||
| # tree diff before and after `nix fmt`, so it only objects to changes | ||
| # the formatter itself introduces (not the developer's existing | ||
| # unstaged work) and is not fooled by formatters that only bump mtime. | ||
| # Rewritten each shell entry to stay in sync with this flake. | ||
| shellHook = '' | ||
| hook=.git/hooks/pre-commit | ||
| if [ -d .git ]; then | ||
| printf '%s\n' \ | ||
| '#!/usr/bin/env bash' \ | ||
| 'before=$(git diff)' \ | ||
| 'nix fmt >/dev/null 2>&1 || exit 0' \ | ||
Unisay marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| '[ "$before" = "$(git diff)" ] || { echo "nix fmt changed files; re-stage them, then commit." >&2; exit 1; }' \ | ||
| > "$hook" | ||
| chmod +x "$hook" | ||
| fi | ||
| ''; | ||
| }; | ||
| }); | ||
| } | ||
| ); | ||
| # --- Flake Local Nix Configuration ---------------------------- | ||
| nixConfig = { | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.