feat(commands): add :Greview for unified diff review with qflist/loclist#202
Merged
barrettruth merged 8 commits intomainfrom Mar 23, 2026
Merged
feat(commands): add :Greview for unified diff review with qflist/loclist#202barrettruth merged 8 commits intomainfrom
:Greview for unified diff review with qflist/loclist#202barrettruth merged 8 commits intomainfrom
Conversation
d43e905 to
16d3d04
Compare
…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.
16d3d04 to
eddeae7
Compare
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
diffs.nvim provides
:Gdifffor single-file diffs andgdiff_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)tocommands.lua, which creates a unified diff buffer nameddiffs://review:{base}, parsesdiff --gitand@@positions, and populates the qflist (files with+N/-Mstats) and loclist (hunks with filename, hunk number, and@@header). All list entries point into the diff buffer socnext/lnextnavigate naturally within it.Also adds:
M.review_file_at_line(bufnr, lnum)utility for finding the filename at any line in a review bufferread_buffer()reviewlabel case for:erefresh:Greviewcommand with git ref tab completion