Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a0ee4aa
Initial plan
Copilot Jul 29, 2026
c765f7a
fix: add explicit permissions to build-and-test job in release workflow
Copilot Jul 29, 2026
5926322
chore: remove accidentally committed nvim binary artifacts
Copilot Jul 29, 2026
5976f12
Apply remaining changes
Copilot Jul 29, 2026
e193054
chore: remove accidentally committed local artifacts
Copilot Jul 29, 2026
8e98bb7
fix: keep agent setup artifacts outside repository
Copilot Jul 29, 2026
b4e5e8a
fix: add explicit permissions to build-and-test reusable workflow cal…
yanuoma Jul 29, 2026
876d269
Skip explorer refresh when status is unchanged; fix stale on_file_sel…
esmuellert Jul 29, 2026
1397686
Initial plan
Copilot Jul 29, 2026
6616f0e
fix(actions): set least-privilege permissions in standalone workflow
Copilot Jul 29, 2026
367d9b2
Restrict GITHUB_TOKEN scope in standalone build workflow (#487)
esmuellert Jul 29, 2026
ac2c22e
chore: bump version to 2.55.2 [skip ci]
github-actions[bot] Jul 29, 2026
5d8c4cb
Add in-tree test framework, rename runner scripts, update CI/build to…
Copilot Jul 29, 2026
50b3020
Merge remote-tracking branch 'origin/main' into copilot/lookup-plenar…
Copilot Jul 29, 2026
ff5e8a2
Fix assert.equal semantics + add luassert compat shim
Copilot Jul 29, 2026
43c532c
docs: update remaining plenary references to the in-tree framework
Copilot Jul 29, 2026
b1fc7c9
Run spec files in parallel from Lua with grouped, non-interleaved output
Copilot Jul 29, 2026
fc07807
Label per-spec stderr, drop 0.10-only APIs from discovery and fallback
Copilot Jul 29, 2026
c259244
Refresh codediff-developer agent doc for current repo state
Copilot Jul 29, 2026
b150970
Merge remote-tracking branch 'origin/main' into copilot/lookup-plenar…
Copilot Jul 29, 2026
c32cce3
Stop OS filewatchers in tests and scope :checktime to one buffer
Copilot Jul 29, 2026
c43b1f9
Tear down the history .git watcher when it reports an error
Copilot Jul 29, 2026
d8fd4bc
Document the test bootstrap's autoread guard in tests/README.md
Copilot Jul 29, 2026
eb0a365
fix: stop E211 noise and index.lock contention from diff views
Copilot Jul 29, 2026
7dd8361
fix(view): open real files without E211 and without spurious 'modified'
Copilot Jul 29, 2026
155f549
test: pin core.autocrlf=false so Windows git warnings stay out of cap…
Copilot Jul 29, 2026
691d8ec
test(history): regression test for c43b1f9 watcher teardown on error
esmuellert Jul 30, 2026
9ecbe40
chore: bump version to 2.60.0
esmuellert Jul 30, 2026
3716a55
Merge branch 'main' into copilot/lookup-plenary-replacement
esmuellert Jul 30, 2026
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
137 changes: 112 additions & 25 deletions .github/agents/codediff-developer.agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,48 @@ You are a specialist developer for the **codediff.nvim** Neovim plugin - a VSCod
- Lua programming for Neovim plugins
- Neovim APIs (vim.api, vim.fn, autocmds, extmarks)
- Git operations and diff algorithms
- The nui.nvim UI library (Tree, Split components)
- Async patterns in Lua (callbacks, vim.schedule)
- The in-tree UI library `lua/codediff/ui/lib/` (Tree, Split, Line) — a drop-in
replacement for nui.nvim, so the plugin has no external Lua dependencies
- The in-tree test framework `tests/framework/` — a drop-in replacement for
plenary.nvim providing `describe/it/before_each/after_each/assert.*`
- Async patterns in Lua (callbacks, vim.schedule, vim.system)

## Repository Structure

```
lua/codediff/
├── init.lua -- Main entry, setup()
├── config.lua -- Configuration options
├── commands.lua -- :CodeDiff command handling
├── init.lua -- Main entry, setup() + navigation API
├── config.lua -- Configuration options and keymaps
├── commands.lua -- :CodeDiff command handling + completion
├── version.lua -- Version info
├── scrollsync.lua -- Scroll synchronization between panes
├── core/
│ ├── argparse/ -- Declarative command parser for :CodeDiff
│ ├── compat.lua -- Neovim version compatibility shims
│ ├── diff.lua -- FFI diff computation (C library)
│ ├── git.lua -- Async git operations
│ ├── dir.lua -- Directory comparison
│ ├── installer.lua -- Automatic native library installation
│ ├── path.lua -- Path normalization helpers
│ └── virtual_file.lua -- Virtual buffer handling
└── ui/
├── explorer/ -- File explorer sidebar
├── view/ -- Diff view management
├── lifecycle/ -- Session tracking
└── highlights.lua -- Syntax highlighting
├── history/ -- Commit history sidebar
├── conflict/ -- Merge conflict resolution
├── view/ -- Diff view management (side-by-side, inline)
├── lifecycle/ -- Session tracking and cleanup
├── lib/ -- In-tree Tree/Split/Line (replaces nui.nvim)
├── inline.lua -- Inline diff virtual-line rendering
├── move.lua -- Moved-code rendering
├── filler.lua -- Filler line alignment
├── layout.lua -- Window layout
├── auto_refresh.lua -- Buffer-change driven diff refresh
└── highlights.lua -- Highlight groups
```

`lua/vscode-diff/` only contains deprecated compatibility shims for the old
plugin name — never add new functionality there.

## Workflow for Fixing Issues

### 1. Understand the Issue
Expand All @@ -48,7 +68,8 @@ return {
setup = function(ctx, e2e)
ctx.repo = e2e.create_temp_git_repo()
ctx.repo.write_file("test.txt", {"original"})
ctx.repo.git("add . && git commit -m 'initial'")
ctx.repo.git("add .")
ctx.repo.git("commit -m 'initial'")
ctx.repo.write_file("test.txt", {"modified"})
vim.cmd("edit " .. ctx.repo.path("test.txt"))
end,
Expand All @@ -70,64 +91,130 @@ return {
}
```

`repo.git(args)` runs `git -C <repo> <args>`, so pass one git subcommand per
call. Chaining (`"add . && git commit -m 'x'"`) runs the second command in
Neovim's own cwd, not the temp repo.

Run with:
```bash
SCENARIO_FILE=/tmp/repro.lua nvim --headless -u tests/init.lua -c "luafile scripts/nvim-e2e.lua" -c "qa!" 2>&1
```

Committed scenarios in `tests/e2e/` are working examples and run the same way.

### 3. Implement the Fix
- Make minimal, focused changes
- Follow existing code patterns
- Add comments only where necessary

### 4. Validate
- Run the repro scenario again (should now pass)
- Run full test suite: `./tests/run_plenary_tests.sh`
- Run full test suite: `./tests/run_tests.sh` (or `make test-lua`)
- Run a single spec while iterating:
```bash
nvim --headless --noplugin -u tests/init.lua \
-c "lua require('tests.framework').run_and_exit('tests/ui/explorer/explorer_spec.lua')"
```
- Lint Lua changes: `make lint` (stylua), format with `make format`

Specs are auto-discovered under `tests/`, each runs in its own child Neovim, and
`tests/framework/supervisor.lua` runs them concurrently. Tune with
`CODEDIFF_TEST_JOBS` (default 2x CPUs, capped at 16; `1` forces sequential) and
`CODEDIFF_TEST_TIMEOUT` (per-spec ms, default 300000).

## E2E Helper Functions

```lua
-- Git repo
local repo = e2e.create_temp_git_repo()
repo.dir -- Repo root path
repo.write_file("path", {"lines"})
repo.git("add .")
repo.read_file("path")
repo.git("add .") -- One subcommand per call
repo.path("file.txt") -- Full path
repo.cleanup()

-- Waiting
e2e.wait(timeout_ms, condition_fn)
e2e.wait_for_explorer(timeout_ms)
e2e.wait_for_diff_ready(timeout_ms)
e2e.wait_for_new_tab(timeout_ms)
e2e.wait_for_buffer_content(bufnr, text, timeout_ms)

-- Windows
e2e.find_window_by_filetype("codediff-explorer")
-- Windows and buffers
e2e.find_window_by_filetype("codediff-explorer") -- also "codediff-history"
e2e.get_all_windows()
e2e.focus_window(winid)
e2e.focus_explorer()
e2e.get_buffer_lines(bufnr)

-- Navigation
e2e.next_file() -- ]f
e2e.prev_file() -- [f
e2e.next_hunk() -- ]c
e2e.toggle_stage() -- -
e2e.get_buffer_content(bufnr)
e2e.get_cursor_position()
e2e.set_cursor_position(line, col)

-- Diff session
e2e.get_diff_buffers() -- orig_buf, mod_buf
e2e.get_diff_session()
e2e.get_original_content()
e2e.get_modified_content()

-- Explorer
e2e.get_explorer_files()
e2e.select_explorer_item(line_num)

-- Navigation and actions
e2e.next_file() -- ]f
e2e.prev_file() -- [f
e2e.next_hunk() -- ]c
e2e.prev_hunk() -- [c
e2e.toggle_stage() -- -
e2e.toggle_explorer()-- <leader>b
e2e.next_conflict() -- ]x
e2e.accept_incoming()-- <leader>ct
e2e.diff_get() -- do
e2e.press("]c", 200)

-- Git state and assertions
e2e.get_git_status(repo.dir)
e2e.is_file_staged(repo.dir, "file.txt")
e2e.assert_contains(str, substr, msg)
e2e.assert_equals(expected, actual, msg)
e2e.assert_true(value, msg)

-- Commands
e2e.exec("CodeDiff HEAD~1")
```

In explorer mode the diff panes are placeholders until a file is selected, so
`get_modified_content()` returns an empty string right after
`wait_for_diff_ready()`. Select a file first (`e2e.next_file()` or
`e2e.select_explorer_item(line)`) before asserting on diff content.

## Key Files for Common Issues

| Issue Type | Key Files |
|------------|-----------|
| Explorer display | `ui/explorer/render.lua`, `ui/explorer/nodes.lua` |
| File navigation | `ui/explorer/actions.lua` |
| Diff rendering | `ui/view/render.lua`, `core/diff.lua` |
| Explorer display | `ui/explorer/render.lua`, `ui/explorer/nodes.lua`, `ui/explorer/line_layout.lua` |
| File navigation | `ui/explorer/actions.lua`, `ui/view/navigation.lua` |
| Diff rendering | `ui/view/render.lua`, `ui/view/side_by_side.lua`, `core/diff.lua` |
| Inline view | `ui/inline.lua`, `ui/view/inline_view.lua` |
| Moved code | `ui/move.lua`, `ui/filler.lua` |
| Git operations | `core/git.lua` |
| Staging/unstaging | `ui/explorer/actions.lua` |
| Keymaps | `ui/explorer/keymaps.lua`, `ui/view/keymaps.lua` |
| Staging/unstaging | `ui/explorer/actions.lua` (files), `ui/view/keymaps.lua` (hunks) |
| Merge conflicts | `ui/conflict/` |
| Commit history | `ui/history/` |
| Command parsing | `commands.lua`, `core/argparse/` |
| Keymaps | `ui/explorer/keymaps.lua`, `ui/view/keymaps.lua`, `config.lua` |
| Session lifecycle | `ui/lifecycle/init.lua` |
| Window layout | `ui/layout.lua`, `ui/scroll.lua`, `scrollsync.lua` |

## Important Notes

- The plugin module is `codediff` (not `vscode-diff`)
- Always use the test init: `nvim --headless -u tests/init.lua`
- Create scenario files in `/tmp/`, never in the repo
- No external Lua dependencies: nui.nvim and plenary.nvim are replaced by
in-tree `lua/codediff/ui/lib/` and `tests/framework/`
- Create ad-hoc repro scenario files in `/tmp/`, never in the repo; only add a
scenario to `tests/e2e/` when it is worth keeping
- Clean up temp repos in the cleanup phase
- Tests must use current production APIs — never reintroduce removed APIs for
backward compatibility
2 changes: 1 addition & 1 deletion .github/instructions/tests.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ applyTo: "tests/**"
When working with tests in this directory:

- **Extend existing tests**: Add new test cases to existing test files whenever possible; only create new test files when covering genuinely distinct functionality
- **Update test runner**: Always add newly created test files to `tests/run_tests.sh` script to ensure they run in CI
- **Test runner**: Spec files are auto-discovered by `tests/framework/supervisor.lua`; a new `*_spec.lua` under `tests/` runs in CI with no runner changes
- **No legacy API in tests**: When fixing tests, always update them to use the latest API; never add backward compatibility or reintroduce removed APIs for test compatibility—tests must use current production APIs
8 changes: 4 additions & 4 deletions .github/skills/nvim-e2e-workflow/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This skill enables end-to-end investigation and fixing of Lua plugin issues usin
- **Plugin name**: codediff (formerly vscode-diff)
- **Type**: Neovim Lua plugin with native C bindings
- **Main module**: `require("codediff")`
- **Test framework**: plenary.nvim
- **Test framework**: in-tree `tests/framework/` (no external test deps)

---

Expand Down Expand Up @@ -93,7 +93,7 @@ SCENARIO_FILE=/tmp/repro.lua nvim --headless -u tests/init.lua -c "luafile scrip

Then run the full test suite:
```bash
./tests/run_plenary_tests.sh
./tests/run_tests.sh
```

---
Expand Down Expand Up @@ -321,13 +321,13 @@ nvim --headless -u tests/init.lua -c "lua print(vim.inspect(require('codediff.co

**Run all tests:**
```bash
./tests/run_plenary_tests.sh
./tests/run_tests.sh
```

**Run single test file:**
```bash
nvim --headless --noplugin -u tests/init.lua \
-c "lua require('plenary.test_harness').test_file('tests/explorer_spec.lua', { minimal_init = 'tests/init.lua' })"
-c "lua require('tests.framework').run_and_exit('tests/explorer_spec.lua')"
```

---
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ jobs:
- name: Run Neovim tests (Windows)
if: startsWith(matrix.runs-on, 'windows')
shell: bash
run: ./tests/run_plenary_tests.sh
run: ./tests/run_tests.sh

- name: Upload build artifacts
if: success()
Expand Down
19 changes: 2 additions & 17 deletions .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,8 @@ jobs:
echo "$HOME/nvim/bin" >> "$GITHUB_PATH"
"$HOME/nvim/bin/nvim" --version | head -n 1

# Preinstall plenary.nvim so the coding agent doesn't need github.com at task time.
# tests/init.lua expects it under vim.fn.stdpath("data")/plenary.nvim, which on
# Linux resolves to $HOME/.local/share/nvim/plenary.nvim.
# nui.nvim is not a runtime or test dependency (verified: zero require("nui...") in lua/).
- name: Cache plenary.nvim
id: cache-plenary
uses: actions/cache@v5
with:
path: ~/.local/share/nvim/plenary.nvim
key: plenary-nvim-${{ runner.os }}-v1

- name: Install plenary.nvim
if: steps.cache-plenary.outputs.cache-hit != 'true'
run: |
mkdir -p "$HOME/.local/share/nvim"
git clone --depth=1 https://github.com/nvim-lua/plenary.nvim \
"$HOME/.local/share/nvim/plenary.nvim"
# The test framework is in-tree at tests/framework/ — no external clone needed.
# nui.nvim is installed on-demand by tests/init.lua only if a test actually requires it.

- name: Build native library
run: make build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/standalone-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ jobs:
if: matrix.os != 'windows-latest'
run: |
nvim --headless --noplugin -u tests/init.lua \
-c "lua require('plenary.test_harness').test_file('tests/full_integration_spec.lua', { minimal_init = vim.fn.getcwd() .. '/tests/init.lua' })"
-c "lua require('tests.framework').run_and_exit('tests/full_integration_spec.lua')"

- name: Run integration test (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
nvim --headless --noplugin -u tests/init.lua -c "lua require('plenary.test_harness').test_file('tests/full_integration_spec.lua', { minimal_init = vim.fn.getcwd() .. '/tests/init.lua' })"
nvim --headless --noplugin -u tests/init.lua -c "lua require('tests.framework').run_and_exit('tests/full_integration_spec.lua')"
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@ example/
.DS_Store
Thumbs.db
.cache/
tests/plenary.nvim
compile_commands.json
build/include/version.h
7 changes: 0 additions & 7 deletions ATTRIBUTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,6 @@ The following dependencies are not bundled but are required for full functionali
**Source**: https://github.com/MunifTanjim/nui.nvim
**Purpose**: UI components for file explorer

### plenary.nvim

**License**: MIT License
**Maintainers**: nvim-lua community
**Source**: https://github.com/nvim-lua/plenary.nvim
**Purpose**: Test framework (development only)

---

## Architectural Inspiration
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ test-c: build
\t@cd build && ctest --output-on-failure

test-lua:
\t@./tests/run_plenary_tests.sh
\t@./tests/run_tests.sh

lint:
\t@stylua --check lua
Expand Down Expand Up @@ -119,7 +119,7 @@ test-c: build
\tctest --test-dir build --output-on-failure -C Release

test-lua:
\ttests\\run_plenary_tests.cmd
\ttests\\run_tests.cmd

lint:
\tstylua --check lua
Expand Down
2 changes: 1 addition & 1 deletion Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Makefile.win

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ codediff.nvim/
│ └── vscode-diff/ # Backward compatibility shims
├── plugin/ # Plugin entry point
│ └── codediff.lua # Auto-loaded on startup
├── tests/ # Test suite (plenary.nvim)
├── tests/ # Test suite (in-tree tests/framework/)
├── docs/ # Documentation and development history
├── Makefile # Build automation
└── README.md
Expand All @@ -835,7 +835,7 @@ codediff.nvim/
- [x] Syntax highlighting preservation (LSP semantic tokens + TreeSitter)
- [x] Read-only buffers with virtual filler lines for alignment
- [x] Flexible highlight configuration (colorscheme-aware)
- [x] Integration tests (C + Lua with plenary.nvim)
- [x] Integration tests (C + Lua via in-tree `tests/framework/` runner)
- [x] File history mode (per-commit review, similar to DiffviewFileHistory)

### Future Enhancements
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.59.0
2.60.0
4 changes: 2 additions & 2 deletions docs/development/05-architecture/timeout-mechanism.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Coverage:
- VSCode parity (2): line+char Myers, structure consistency
- Edge cases (3): zero/negative timeout, empty files

Run: `nvim --headless -u tests/init.lua -c "lua require('plenary.test_harness').test_file('tests/timeout_spec.lua')"`
Run: `nvim --headless -u tests/init.lua -c "lua require('tests.framework').run_and_exit('tests/timeout_spec.lua')"`

## Files Modified

Expand All @@ -97,7 +97,7 @@ Run: `nvim --headless -u tests/init.lua -c "lua require('plenary.test_harness').
6. `lua/vscode-diff/auto_refresh.lua` - Pass timeout from config
7. `lua/vscode-diff/commands.lua` - Pass timeout from config (2 places)
8. `tests/timeout_spec.lua` - Comprehensive test suite
9. `tests/run_plenary_tests.sh` - Added to test runner
9. `tests/run_tests.sh` - Added to test runner

---

Expand Down
Loading
Loading