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
25 changes: 25 additions & 0 deletions .github/workflows/demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: demo

# Renders demo/demo.tape and uploads demo.gif as a workflow artifact.
on:
workflow_dispatch:
pull_request:
paths:
- demo/**

jobs:
vhs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: rhysd/action-setup-vim@v1
with:
neovim: true
version: stable
- uses: charmbracelet/vhs-action@v2
with:
path: demo/demo.tape
- uses: actions/upload-artifact@v4
with:
name: demo
path: demo/demo.gif
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Leave annotations on exact pieces of code, then hand them to an AI agent as one
- Works in [gh-review.nvim](https://github.com/gh-tui-tools/gh-review.nvim) diff buffers: the source becomes a GitHub link at the PR commit
- No dependencies. Neovim 0.9+.

![demo](demo/demo.gif)

## Export format

````markdown
Expand Down Expand Up @@ -173,3 +175,14 @@ If an annotation's text can't be found when the buffer opens, it stays where it
```sh
nvim --headless -u NONE -c "luafile tests/run.lua"
```

## Demo

The GIF above is recorded with [VHS](https://github.com/charmbracelet/vhs) from `demo/demo.tape`.
It runs Neovim with `demo/init.lua` on a copy of `demo/reconcile.go` in a throwaway git repo, so your own annotations are not touched:

```sh
vhs demo/demo.tape
```

The `demo` workflow renders it too (on demand, and on pull requests that change `demo/`) and uploads `demo.gif` as an artifact.
79 changes: 79 additions & 0 deletions demo/demo.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Render with `vhs demo/demo.tape` from the repository root.
# Needs vhs (https://github.com/charmbracelet/vhs), nvim 0.10+ and git.

Output demo/demo.gif

Require nvim
Require git

Set Shell "bash"
Set FontSize 18
Set Width 1200
Set Height 720
Set Padding 20
Set Theme "Catppuccin Mocha"
Set TypingSpeed 60ms

# Throwaway git project, so the source paths are relative to its root.
Hide
Type `R=$PWD D=$(mktemp -d) && mkdir -p $D/pkg/controller && cp demo/reconcile.go $D/pkg/controller/ && cd $D && git init -q && stty -ixon && clear`
Enter
Type "nvim -u $R/demo/init.lua pkg/controller/reconcile.go"
Enter
Sleep 1.5s
Show

Sleep 1s

# 1. Annotate a character selection.
Type "/r.Client"
Enter
Sleep 500ms
Type "vf)"
Sleep 800ms
Space
Type "aa"
Sleep 600ms
Type "Should be a Patch: Update conflicts with the status writer."
Sleep 500ms
Ctrl+S
Sleep 1.5s

# 2. Annotate a whole line.
Type "/30"
Enter
Sleep 500ms
Type "V"
Sleep 600ms
Space
Type "aa"
Sleep 600ms
Type "Make the requeue interval configurable?"
Sleep 500ms
Ctrl+S
Sleep 1.5s

# 3. Jump between annotations.
Type "[a"
Sleep 1s
Type "]a"
Sleep 1s

# 4. Annotations follow edits: add an import above them.
Type "gg3j"
Sleep 300ms
Type `o"fmt"`
Escape
Sleep 1.5s

# 5. Preview what the agent gets.
Space
Type "ap"
Sleep 4s
Type "q"
Sleep 300ms

# Clean up.
Hide
Type ":qa!"
Enter
22 changes: 22 additions & 0 deletions demo/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- Minimal config for the VHS demo: `vhs demo/demo.tape` from the repo root.
local repo = vim.fs.dirname(vim.fs.dirname(debug.getinfo(1, "S").source:sub(2)))
vim.opt.runtimepath:prepend(repo)

vim.g.mapleader = " "
vim.opt.number = true
vim.opt.signcolumn = "yes"
vim.opt.termguicolors = true
vim.opt.swapfile = false
vim.opt.shortmess:append("I")
vim.opt.laststatus = 3

require("annotate").setup({
-- Throwaway store, so the demo never touches real annotations.
data_dir = vim.fn.tempname(),
})

local a = require("annotate")
vim.keymap.set({ "n", "x" }, "<leader>aa", a.add, { desc = "Annotate" })
vim.keymap.set("n", "<leader>ap", a.preview, { desc = "Annotate: preview" })
vim.keymap.set("n", "]a", function() a.jump(1) end, { desc = "Next annotation" })
vim.keymap.set("n", "[a", function() a.jump(-1) end, { desc = "Previous annotation" })
17 changes: 17 additions & 0 deletions demo/reconcile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package controller

import (
"context"
"time"
)

// Reconcile brings the cluster state in line with obj.
func (r *Reconciler) Reconcile(ctx context.Context, obj *Object) error {
obj.Status.LastSync = time.Now()

if err := r.Client.Update(ctx, obj); err != nil {
return err
}

return r.requeue(ctx, obj, 30*time.Second)
}
2 changes: 2 additions & 0 deletions lua/annotate/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ function M.jump(dir)
if not src then
return
end
-- Positions in the store are stale until synced from the buffer's extmarks.
render.sync(vim.api.nvim_get_current_buf())
local cur = vim.api.nvim_win_get_cursor(0)
local list = store.for_key(src.root, src.key)
table.sort(list, function(x, y)
Expand Down
16 changes: 16 additions & 0 deletions tests/run.lua
Original file line number Diff line number Diff line change
Expand Up @@ -538,5 +538,21 @@ test("list.picker = quickfix skips installed pickers", function()
eq(vim.fn.getqflist({ size = 0 }).size, 1)
end)

test("jump follows unsaved edits", function()
vim.fn.delete(tmp .. "/data", "rf")
open_go()
vim.fn.cursor(4, 12)
table.insert(answers, { text = "x" })
vim.cmd("normal! vf)\27")
vim.cmd("'<,'>Annotate add")
vim.api.nvim_buf_set_lines(0, 1, 1, false, { "// added", "// lines" })
vim.fn.cursor(1, 1)
annotate.jump(1)
eq(vim.api.nvim_win_get_cursor(0), { 6, 11 })
vim.fn.cursor(10, 1)
annotate.jump(-1)
eq(vim.api.nvim_win_get_cursor(0), { 6, 11 })
end)

print(string.format("\n%d passed, %d failed", passed, failures))
vim.cmd(failures == 0 and "qa!" or "cq!")
Loading