Skip to content

feat(commands): add :Greview for unified diff review with qflist/loclist#202

Merged
barrettruth merged 8 commits intomainfrom
feat/greview
Mar 23, 2026
Merged

feat(commands): add :Greview for unified diff review with qflist/loclist#202
barrettruth merged 8 commits intomainfrom
feat/greview

Conversation

@barrettruth
Copy link
Owner

Problem

diffs.nvim provides :Gdiff for single-file diffs and gdiff_section() for staged/unstaged sections, but has no way to view a full unified diff against an arbitrary git ref (e.g. origin/main) with structured file and hunk navigation.

Solution

Add M.greview(base, opts) to commands.lua, which creates a unified diff buffer named diffs://review:{base}, parses diff --git and @@ positions, and populates the qflist (files with +N/-M stats) and loclist (hunks with filename, hunk number, and @@ header). All list entries point into the diff buffer so cnext/lnext navigate naturally within it.

Also adds:

  • M.review_file_at_line(bufnr, lnum) utility for finding the filename at any line in a review buffer
  • read_buffer() review label case for :e refresh
  • :Greview command with git ref tab completion
  • Vimdoc section
  • 6 new tests

@barrettruth barrettruth force-pushed the feat/greview branch 2 times, most recently from d43e905 to 16d3d04 Compare March 23, 2026 20:18
…clist

Problem: diffs.nvim provides `:Gdiff` for single-file diffs and
`gdiff_section()` for staged/unstaged sections, but has no way to
view a full unified diff against an arbitrary git ref with structured
navigation.

Solution: add `M.greview(base, opts)` which creates a unified diff
buffer (`diffs://review:{base}`), parses file/hunk positions, and
populates the qflist (files with `+N`/`-M` stats) and loclist (hunks
with filename and `@@` header). Add `M.review_file_at_line()` utility,
`read_buffer()` review label case, and `:Greview` command with git
ref tab completion.
Problem: three CI jobs failing — stylua format, lua type check
(`param-type-mismatch` on `get_repo_root`), and vimdoc unresolved tags
for vim builtins and external plugin references.

Solution: fix `get_repo_root` param annotation to `string?`, use
`nix develop .#ci` in all workflow commands, wrap
`vimdoc-language-server` with `--runtime-tags` in the ci devShell, and
fix external tag references (`:Git` → backtick, `winhighlight` →
option syntax).
Problem: `:Greview` required a base ref argument, making it cumbersome
for the common case of reviewing against the default branch.

Solution: make the base argument optional. When omitted, auto-detect
the remote default branch via `git symbolic-ref refs/remotes/origin/HEAD`.
Also fix pre-existing stylua formatting issues and update vimdoc/README.
Problem: `setloclist` was called before the diffs split, so the loclist
landed on the source window instead of the review buffer window.
Qflist entries also had trailing whitespace when a file had no adds or
no deletes.

Solution: move `setloclist` after the window switch. Trim trailing
whitespace from qflist text entries.
Problem: loclist entries included the `@@` hunk header which has
variable-width line ranges, making alignment impossible.

Solution: show only aligned filename + `(hunk N)`, matching the
qflist format style.
Problem: quickfix and loclist from `:Greview` had no line numbers and
inconsistent formats. The custom `quickfixtextfunc` was set globally,
affecting unrelated quickfix lists.

Solution: define `_diffs_qftf` and set it per-list via the
`quickfixtextfunc` property on `setqflist`/`setloclist`. Both lists
now show aligned `lnum  text`, giving consistent structure. Restore
the `@@` hunk header in loclist entries for context.
@barrettruth barrettruth merged commit 5d4b244 into main Mar 23, 2026
8 checks passed
@barrettruth barrettruth deleted the feat/greview branch March 23, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant