Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .claude/hooks/format.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
#
# Claude Code Hook: Format Files
# Triggers after Claude edits/writes files and runs nix fmt
# Triggers after Claude edits/writes files and runs treefmt (via mise)
#
# Environment variables provided by Claude Code:
# - CLAUDE_PROJECT_DIR: Path to the project directory
Expand Down Expand Up @@ -75,18 +75,18 @@ main() {
exit 1
fi

log "${YELLOW}Formatting file with nix fmt...${NC}"
log "${YELLOW}Formatting file with treefmt...${NC}"

# Change to project directory
cd "${CLAUDE_PROJECT_DIR}"

# Run nix fmt on the file
if nix fmt "$FILE_PATH" 2>/dev/null; then
# Run treefmt on the file
if mise exec -- treefmt "$FILE_PATH" 2>/dev/null; then
log "${GREEN}✓ Successfully formatted: $FILE_PATH${NC}"
exit 0
else
EXIT_CODE=$?
log "${RED}✗ nix fmt failed with exit code $EXIT_CODE${NC}"
log "${RED}✗ treefmt failed with exit code $EXIT_CODE${NC}"
log "${RED}This indicates the file has formatting issues that need manual attention${NC}"

# Don't fail the hook - just warn about formatting issues
Expand Down
29 changes: 0 additions & 29 deletions .devcontainer/Dockerfile

This file was deleted.

11 changes: 3 additions & 8 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
{
"name": "claudecode.nvim Development",
"build": {
"dockerfile": "Dockerfile"
},
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/devcontainers/features/git:1": {}
"ghcr.io/devcontainers-extra/features/mise:1": {}
},
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.defaultProfile.linux": "bash"
},
"extensions": ["jnoortheen.nix-ide"]
"extensions": ["hverlin.mise-vscode"]
}
},
"postCreateCommand": "bash .devcontainer/post-create.sh",
Expand Down
50 changes: 26 additions & 24 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
#!/bin/bash
set -euo pipefail

# Source Nix environment
. /home/vscode/.nix-profile/etc/profile.d/nix.sh

# Verify Nix is available
if ! command -v nix &>/dev/null; then
echo "Error: Nix is not installed properly"
# Ensure the feature-installed mise is on PATH for this script.
export PATH="$HOME/.local/bin:/usr/local/bin:$PATH"
if ! command -v mise &>/dev/null; then
echo "Error: mise is not on PATH after the devcontainer feature install" >&2
exit 1
fi

echo "✅ Nix is installed and available"
echo ""
echo "📦 claudecode.nvim Development Container Ready!"
echo ""
echo "To enter the development shell with all dependencies, run:"
echo " nix develop"
# Build deps: PUC Lua builds from source, and the test rocks compile C modules.
sudo apt-get -o Acquire::Retries=3 update
sudo apt-get -o Acquire::Retries=3 install -y build-essential libreadline-dev unzip

# Activate mise in interactive shells (puts the toolchain + fixtures/bin on PATH).
if ! grep -qs 'mise activate bash' "$HOME/.bashrc"; then
echo 'eval "$(mise activate bash)"' >>"$HOME/.bashrc"
fi

echo ""
echo "This will provide:"
echo " - Neovim"
echo " - Lua and LuaJIT"
echo " - busted (test framework)"
echo " - luacheck (linter)"
echo " - stylua (formatter)"
echo " - All other development tools"
echo "📦 Provisioning the claudecode.nvim development environment with mise..."

mise trust
mise install
mise run setup

echo ""
echo "You can also run development commands directly:"
echo " - make # Run full validation (format, lint, test)"
echo " - make test # Run tests"
echo " - make check # Run linter"
echo " - make format # Format code"
echo "✅ claudecode.nvim development environment ready."
echo " mise run all # full validation (format, lint, test)"
echo " mise run test # run tests"
echo " mise run check # lint"
echo " mise run format # format"
echo " mise tasks # list all tasks"
12 changes: 0 additions & 12 deletions .envrc

This file was deleted.

63 changes: 26 additions & 37 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ concurrency:
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

jobs:
# Unit/component tests run under LuaJIT with a mocked vim global (busted), so
# they do not need a real Neovim binary — hence no neovim-version matrix here.
# Real-Neovim coverage lives in the integration-tests job below.
unit-tests:
runs-on: ubuntu-latest
strategy:
matrix:
neovim-version: ["stable", "nightly"]

steps:
- name: Checkout
Expand All @@ -29,38 +29,38 @@ jobs:
fetch-depth: 0
persist-credentials: false

- name: Setup Nix
uses: nixbuild/nix-quick-install-action@5bb6a3b3abe66fd09bbf250dce8ada94f856a703 # v30
# Build deps: PUC Lua builds from source, and the test rocks compile C modules.
- name: Install build dependencies
run: |
sudo apt-get -o Acquire::Retries=3 update
sudo apt-get -o Acquire::Retries=3 install -y build-essential libreadline-dev unzip

- uses: nix-community/cache-nix-action@135667ec418502fa5a3598af6fb9eb733888ce6a # v6.1.3
with:
primary-key: nix-claudecode-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
restore-prefixes-first-match: nix-claudecode-${{ runner.os }}-
gc-max-store-size-linux: 2G
purge: true
purge-prefixes: nix-claudecode-${{ runner.os }}-
purge-created: 0
purge-primary-key: never
- name: Set up mise
uses: jdx/mise-action@1648a7812b9aeae629881980618f079932869151 # v4.0.1

- name: Setup Neovim
uses: rhysd/action-setup-vim@8e931b9954b19d4203d5caa5ff5521f3bc21dcc7 # v1.4.2
# Cache the rock tree (rebuilt from luarocks.org otherwise); a miss just rebuilds.
- name: Cache Lua test rocks
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
neovim: true
version: ${{ matrix.neovim-version }}
path: .luarocks
key: luarocks-${{ runner.os }}-${{ hashFiles('mise.toml') }}

- name: Install Lua test rocks
run: mise run setup

- name: Run Luacheck
run: nix develop .#ci -c make check
- name: Run luacheck
run: mise run check

- name: Run tests
run: nix develop .#ci -c make test
run: mise run test

- name: Check formatting
run: nix flake check
run: mise run format-check

- name: Generate coverage report
run: |
if [ -f "luacov.stats.out" ]; then
nix develop .#ci -c luacov
mise exec -- luacov

echo "Creating lcov.info from luacov.report.out"
{
Expand Down Expand Up @@ -134,19 +134,8 @@ jobs:
fetch-depth: 0
persist-credentials: false

- name: Setup Nix
uses: nixbuild/nix-quick-install-action@5bb6a3b3abe66fd09bbf250dce8ada94f856a703 # v30

- uses: nix-community/cache-nix-action@135667ec418502fa5a3598af6fb9eb733888ce6a # v6.1.3
with:
primary-key: nix-claudecode-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
restore-prefixes-first-match: nix-claudecode-${{ runner.os }}-
gc-max-store-size-linux: 2G
purge: true
purge-prefixes: nix-claudecode-${{ runner.os }}-
purge-created: 0
purge-primary-key: never

# Neovim here comes from action-setup-vim (matrix-driven), independent of
# the mise.toml neovim pin used for local dev.
- name: Setup Neovim
uses: rhysd/action-setup-vim@8e931b9954b19d4203d5caa5ff5521f3bc21dcc7 # v1.4.2
with:
Expand All @@ -159,4 +148,4 @@ jobs:
ln -s "$(pwd)" ~/.local/share/nvim/site/pack/vendor/start/claudecode.nvim

- name: Run integration tests
run: nix develop .#ci -c ./scripts/run_integration_tests_individually.sh
run: ./scripts/run_integration_tests_individually.sh
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ luac.out
*.zip
*.tar.gz

# Project-local Lua rock tree built by `mise run setup`
/.luarocks/

# Object files
*.o
*.os
Expand Down
15 changes: 8 additions & 7 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@

## Build, Test, and Development Commands

- `make check`: Syntax checks + `luacheck` on `lua/` and `tests/`.
- `make format`: Format with StyLua (via Nix `nix fmt` in this repo).
- `make test`: Run Busted tests with coverage (outputs `luacov.stats.out`).
- `make clean`: Remove coverage artifacts.
- Setup (one time): install [mise](https://mise.jdx.dev), then `mise install && mise run setup` to provision the toolchain and build the Lua test rocks. Activate mise in your shell (`eval "$(mise activate bash)"` in your rc) so bare tools like `busted`/`nvim` are on PATH; otherwise prefix with `mise exec --`. Run `mise tasks` to list all tasks.
- `mise run check`: Syntax checks + `luacheck` on `lua/` and `tests/`.
- `mise run format`: Format the tree with treefmt (replaces the former `nix fmt`).
- `mise run test`: Run Busted tests with coverage (outputs `luacov.stats.out`).
- `mise run clean`: Remove coverage artifacts.
Examples:
- Run all tests: `make test`
- Run all tests: `mise run test`
- Run one file: `busted -v tests/unit/terminal_spec.lua`

## Coding Style & Naming Conventions
Expand All @@ -32,13 +33,13 @@
- File naming: `*_spec.lua` or `*_test.lua` under `tests/unit` or `tests/integration`.
- Mocks/helpers: place in `tests/mocks` and `tests/helpers`; prefer pure‑Lua mocks.
- Coverage: keep high signal; exercise server, tools, diff, and terminal paths.
- Quick tip: prefer `make test` (it sets `LUA_PATH` and coverage flags).
- Quick tip: prefer `mise run test` (it sets `LUA_PATH` and coverage flags).

## Commit & Pull Request Guidelines

- Commits: Use Conventional Commits (e.g., `feat:`, `fix:`, `docs:`, `test:`, `chore:`). Keep messages imperative and scoped.
- PRs: include a clear description, linked issues, repro steps, and tests. Update docs (`README.md`, `ARCHITECTURE.md`, or `DEVELOPMENT.md`) when behavior changes.
- Pre-flight: run `make format`, `make check`, and `make test`. Attach screenshots or terminal recordings for UX-visible changes (diff flows, terminal behavior).
- Pre-flight: run `mise run all` (format, lint, test). Attach screenshots or terminal recordings for UX-visible changes (diff flows, terminal behavior).

## Security & Configuration Tips

Expand Down
Loading
Loading