Skip to content

Commit bebe01c

Browse files
sudo-teecameronr
andauthored
feat(rendering): incremental rendering (#62)
Introduces an incremental rendering that updates only the changed portion(s) of the buffer instead of re-rendering everything on every change. This reduces CPU usages for large sessions. This PR also incorporate a functional test suite in `tests/manual` where you can record a run snapshot tests. This is a major revision of the rendering system. Co-authored-by: Cameron Ring <[email protected]>
1 parent 0f2d1e5 commit bebe01c

File tree

96 files changed

+62686
-1701
lines changed

Some content is hidden

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

96 files changed

+62686
-1701
lines changed

.emmyrc.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/EmmyLuaLs/emmylua-analyzer-rust/refs/heads/main/crates/emmylua_code_analysis/resources/schema.json",
3+
"runtime": {
4+
"version": "LuaJIT"
5+
},
6+
"workspace": {
7+
"library": [
8+
"$VIMRUNTIME",
9+
"$HOME/.local/share/nvim/lazy/luvit-meta/library/uv.lua",
10+
],
11+
"ignoreGlobs": [
12+
"**/*_spec.lua"
13+
]
14+
}
15+
}

.github/workflows/tests.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# From
2+
# https://github.com/shortcuts/neovim-plugin-boilerplate/blob/main/.github/workflows/main.yml
3+
4+
name: tests
5+
6+
on:
7+
push:
8+
pull_request:
9+
types: [opened, synchronize]
10+
11+
jobs:
12+
lint:
13+
runs-on: ubuntu-latest
14+
name: lint
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- uses: JohnnyMorganz/stylua-action@v4
19+
with:
20+
token: ${{ secrets.GITHUB_TOKEN }}
21+
version: latest
22+
args: --check . -g '*.lua' -g '!deps/'
23+
24+
test:
25+
timeout-minutes: 4
26+
strategy:
27+
matrix:
28+
os: [ubuntu-latest]
29+
neovim_version: ["v0.10.3", "v0.11.4", "nightly"]
30+
include:
31+
- os: macos-latest
32+
neovim_version: v0.11.4
33+
runs-on: ${{ matrix.os }}
34+
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
- name: setup neovim
39+
uses: rhysd/action-setup-vim@v1
40+
with:
41+
neovim: true
42+
version: ${{ matrix.neovim_version }}
43+
44+
# only needed if testing in ssh but doesn't hurt
45+
- name: Add nvim to PATH
46+
run: echo "${{ steps.setup_nvim.outputs.executable }}" >> $GITHUB_PATH
47+
48+
- name: Install plenary
49+
run: |
50+
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim
51+
52+
- name: Run tests
53+
run: ./run_tests.sh
54+
55+
# # For sshing in to debug GH actions
56+
# - name: Setup tmate session
57+
# uses: mxschmitt/action-tmate@v3
58+
# with:
59+
# detached: true

.luarc.json

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

AGENTS.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
# AGENTS.md
22

33
## Build, Lint, and Test
4+
45
- **Run all tests:** `./run_tests.sh`
56
- **Minimal tests:**
67
`nvim --headless -u tests/minimal/init.lua -c "lua require('plenary.test_harness').test_directory('./tests/minimal', {minimal_init = './tests/minimal/init.lua', sequential = true})"`
78
- **Unit tests:**
89
`nvim --headless -u tests/minimal/init.lua -c "lua require('plenary.test_harness').test_directory('./tests/unit', {minimal_init = './tests/minimal/init.lua'})"`
910
- **Run a single test:** Replace the directory in the above command with the test file path, e.g.:
10-
`nvim --headless -u tests/minimal/init.lua -c "lua require('plenary.test_harness').test_directory('./tests/unit/job_spec.lua', {minimal_init = './tests/minimal/init.lua'})"`
11+
`nvim --headless -u tests/manual/init.lua -c "lua require('plenary.test_harness').test_directory('./tests/unit/job_spec.lua', {minimal_init = './tests/minimal/init.lua'})"`
12+
- **Manual/Visual tests:** `./tests/manual/run_replay.sh` - Replay captured event data for visual testing
13+
- **Debug rendering in headless mode:**
14+
`nvim --headless -u tests/manual/init_replay.lua "+ReplayHeadless" "+ReplayLoad tests/data/FILE.json" "+ReplayAll 0" "+qa"`
15+
This will replay events and dump the output buffer to stdout, useful for debugging rendering issues without a UI.
16+
You can also run to just a specific message # with (e.g. message # 12):
17+
`nvim --headless -u tests/manual/init_replay.lua "+ReplayHeadless" "+ReplayLoad tests/data/message-removal.json" "+ReplayNext 12" "+qa"`
1118
- **Lint:** No explicit lint command; follow Lua best practices.
1219

1320
## Code Style Guidelines
21+
1422
- **Imports:** `local mod = require('mod')` at the top. Group standard, then project imports.
1523
- **Formatting:** 2 spaces per indent. No trailing whitespace. Lines ≤ 100 chars.
1624
- **Types:** Use Lua annotations (`---@class`, `---@field`, etc.) for public APIs/config.
@@ -19,6 +27,6 @@
1927
- **Comments:** Only when necessary for clarity. Prefer self-explanatory code.
2028
- **Functions:** Prefer local functions. Use `M.func` for module exports.
2129
- **Config:** Centralize in `config.lua`. Use deep merge for user overrides.
22-
- **Tests:** Place in `tests/minimal/` or `tests/unit/`.
30+
- **Tests:** Place in `tests/minimal/` or `tests/unit/`. Manual/visual tests in `tests/manual/`.
2331

2432
_Agentic coding agents must follow these conventions strictly for consistency and reliability._

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ require('opencode').setup({
175175
tools = {
176176
show_output = true, -- Show tools output [diffs, cmd output, etc.] (default: true)
177177
},
178+
rendering = {
179+
markdown_debounce_ms = 250, -- Debounce time for markdown rendering on new data (default: 250ms)
180+
on_data_rendered = nil, -- Called when new data is rendered; set to false to disable default RenderMarkdown/Markview behavior
181+
},
178182
},
179183
input = {
180184
text = {
@@ -530,7 +534,7 @@ The plugin defines several highlight groups that can be customized to match your
530534
- `OpencodeAgentBuild`: Agent indicator in winbar for Build mode (default: #616161 background)
531535
- `OpencodeAgentCustom`: Agent indicator in winbar for custom modes (default: #3b4261 background)
532536
- `OpencodeContestualAction`: Highlight for contextual actions in the output window (default: #3b4261 background)
533-
- `OpencodeInpuutLegend`: Highlight for input window legend (default: #CCCCCC background)
537+
- `OpencodeInputLegend`: Highlight for input window legend (default: #CCCCCC background)
534538
- `OpencodeHint`: Highlight for hinting messages in input window and token info in output window footer (linked to `Comment`)
535539

536540
## 🔧 Setting up Opencode

0 commit comments

Comments
 (0)