Skip to content

Commit 7bcc421

Browse files
Merge branch 'main' into fix/diff-window-layout-restoration
2 parents 442c2ed + 340319e commit 7bcc421

File tree

95 files changed

+5736
-1173
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+5736
-1173
lines changed

.claude/hooks/format.sh

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Claude Code Hook: Format Files
4+
# Triggers after Claude edits/writes files and runs nix fmt
5+
#
6+
# Environment variables provided by Claude Code:
7+
# - CLAUDE_PROJECT_DIR: Path to the project directory
8+
# - CLAUDE_TOOL_NAME: Name of the tool that was executed
9+
# - CLAUDE_TOOL_ARGS: JSON string containing tool arguments
10+
11+
set -euo pipefail
12+
13+
# Colors for output
14+
RED='\033[0;31m'
15+
GREEN='\033[0;32m'
16+
YELLOW='\033[1;33m'
17+
NC='\033[0m' # No Color
18+
19+
# Log function
20+
log() {
21+
echo -e "[$(date '+%H:%M:%S')] $1" >&2
22+
}
23+
24+
# Parse tool arguments to get the file path
25+
get_file_path() {
26+
# Read hook input from stdin
27+
local hook_input
28+
if [ -t 0 ]; then
29+
# No stdin input available
30+
log "DEBUG: No stdin input available"
31+
return
32+
fi
33+
34+
hook_input=$(cat)
35+
log "DEBUG: Hook input = $hook_input"
36+
37+
# Try to extract file_path from tool_input
38+
local file_path
39+
file_path=$(echo "$hook_input" | grep -o '"file_path"[[:space:]]*:[[:space:]]*"[^"]*"' | sed 's/.*"file_path"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/')
40+
41+
if [ -n "$file_path" ]; then
42+
echo "$file_path"
43+
return
44+
fi
45+
46+
# Try extracting any file path from the input
47+
local any_file_path
48+
any_file_path=$(echo "$hook_input" | grep -o '"[^"]*\.[^"]*"' | sed 's/"//g' | head -1)
49+
50+
if [ -n "$any_file_path" ]; then
51+
echo "$any_file_path"
52+
return
53+
fi
54+
55+
log "DEBUG: Could not extract file path from hook input"
56+
}
57+
58+
# Main logic
59+
main() {
60+
log "${YELLOW}Claude Code Hook: File Formatter${NC}"
61+
62+
# Get the file path from tool arguments
63+
FILE_PATH=$(get_file_path)
64+
65+
if [ -z "$FILE_PATH" ]; then
66+
log "${RED}Error: Could not determine file path from tool arguments${NC}"
67+
exit 1
68+
fi
69+
70+
log "Tool: ${CLAUDE_TOOL_NAME:-unknown}, File: $FILE_PATH"
71+
72+
# Check if file exists
73+
if [ ! -f "$FILE_PATH" ]; then
74+
log "${RED}Error: File does not exist: $FILE_PATH${NC}"
75+
exit 1
76+
fi
77+
78+
log "${YELLOW}Formatting file with nix fmt...${NC}"
79+
80+
# Change to project directory
81+
cd "${CLAUDE_PROJECT_DIR}"
82+
83+
# Run nix fmt on the file
84+
if nix fmt "$FILE_PATH" 2>/dev/null; then
85+
log "${GREEN}✓ Successfully formatted: $FILE_PATH${NC}"
86+
exit 0
87+
else
88+
EXIT_CODE=$?
89+
log "${RED}✗ nix fmt failed with exit code $EXIT_CODE${NC}"
90+
log "${RED}This indicates the file has formatting issues that need manual attention${NC}"
91+
92+
# Don't fail the hook - just warn about formatting issues
93+
# This allows Claude's operation to continue while alerting about format problems
94+
log "${YELLOW}Continuing with Claude's operation, but please fix formatting issues${NC}"
95+
exit 0
96+
fi
97+
}
98+
99+
# Run main function
100+
main "$@"

.claude/settings.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"hooks": {
3+
"PostToolUse": [
4+
{
5+
"matcher": "Write|Edit",
6+
"hooks": [
7+
{
8+
"type": "command",
9+
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/format.sh"
10+
}
11+
]
12+
}
13+
]
14+
}
15+
}

.envrc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#!/usr/bin/env bash
22

3-
if ! has nix_direnv_version || ! nix_direnv_version 3.0.6; then
4-
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.6/direnvrc" "sha256-RYcUJaRMf8oF5LznDrlCXbkOQrywm0HDv1VjYGaJGdM="
3+
if ! has nix_direnv_version || ! nix_direnv_version 3.0.7; then
4+
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.7/direnvrc" "sha256-RYcUJaRMf8oF5LznDrlCXbkOQrywm0HDv1VjYGaJGdM="
55
fi
66

77
nix_direnv_manual_reload
88

99
use flake .
10+
11+
# Add fixtures/bin to PATH for nvim config aliases
12+
PATH_add fixtures/bin

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,6 @@ luacov.stats.out
6161
# direnv
6262
.direnv
6363

64-
.claude
64+
.claude/*
65+
!.claude/settings.json
66+
!.claude/hooks/

.luarc.json

Lines changed: 0 additions & 19 deletions
This file was deleted.

ARCHITECTURE.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ lua/claudecode/
205205

206206
## Testing
207207

208+
### Automated Testing
209+
208210
Three-layer testing strategy using busted:
209211

210212
```lua
@@ -234,6 +236,31 @@ describe("full flow", function()
234236
end)
235237
```
236238

239+
### Integration Testing with Fixtures
240+
241+
Manual testing with real Neovim configurations in the `fixtures/` directory:
242+
243+
```bash
244+
# Test with different file explorers
245+
source fixtures/nvim-aliases.sh
246+
vv nvim-tree # Test with nvim-tree integration
247+
vv oil # Test with oil.nvim integration
248+
vv mini-files # Test with mini.files integration
249+
vv netrw # Test with built-in netrw
250+
251+
# Each fixture provides:
252+
# - Complete Neovim configuration
253+
# - Plugin dependencies
254+
# - Development keybindings
255+
# - Integration-specific testing scenarios
256+
```
257+
258+
**Fixture Architecture**:
259+
260+
- `fixtures/bin/` - Helper scripts (`vv`, `vve`, `list-configs`)
261+
- `fixtures/[integration]/` - Complete Neovim configs for testing
262+
- `fixtures/nvim-aliases.sh` - Shell aliases for easy testing
263+
237264
## Performance & Security
238265

239266
- **Debounced Updates**: 50ms delay on selection changes

0 commit comments

Comments
 (0)