Skip to content

Commit 5575f9f

Browse files
committed
chore: add fmt commit hook
1 parent 2b53687 commit 5575f9f

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,11 @@ just test
119119
```
120120

121121
Will clone and build the currently supported version of the Go treesitter parser and use that for the tests.
122+
123+
## Git Hooks
124+
125+
To enable the pre-commit hook that runs `just fmt`:
126+
127+
```bash
128+
git config core.hooksPath hooks
129+
```

hooks/pre-commit

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
# Run formatter before commit
4+
echo "Running formatter..."
5+
just fmt
6+
7+
# Check if fmt made any changes
8+
if ! git diff --quiet; then
9+
echo "Formatter made changes. Please stage the changes and commit again."
10+
exit 1
11+
fi
12+
13+
echo "Formatting check passed."

justfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
fmt:
22
stylua lua/ --config-path=stylua.toml
33

4+
fmt-check:
5+
stylua lua/ --check --config-path=stylua.toml
6+
47
install-plenary:
58
#!/bin/bash
69
echo "===== Setting up Plenary.nvim ====="

0 commit comments

Comments
 (0)