Skip to content

jfahrer/code-review.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

code-review.nvim

A Neovim plugin for collecting structured, file/line-referenced review comments and copying them as context into a coding agent (e.g. an LLM chat).

Note

This code was written entirely by an AI coding agent. I have not read it. Use at your own risk.

Install (lazy.nvim)

{
  'jfahrer/code-review.nvim',
  opts = {},
  cmd = { 'ReviewStart', 'ReviewAdd', 'ReviewOpen', 'ReviewCopy', 'ReviewClose',
          'ReviewFinish', 'ReviewNext', 'ReviewPrev' },
  keys = {
    { '<leader>rs', '<cmd>ReviewStart<cr>',   desc = 'Review: Start' },
    { '<leader>ra', function() require('code-review').add() end, desc = 'Review: Add', mode = { 'n', 'v' } },
    { '<leader>ro', '<cmd>ReviewOpen<cr>',    desc = 'Review: Open' },
    { '<leader>rv', '<cmd>ReviewOpen v<cr>',  desc = 'Review: Open (vertical)' },
    { '<leader>rh', '<cmd>ReviewOpen h<cr>',  desc = 'Review: Open (horizontal)' },
    { '<leader>ry', '<cmd>ReviewCopy<cr>',    desc = 'Review: Copy' },
    { '<leader>rq', '<cmd>ReviewClose<cr>',   desc = 'Review: Close window' },
    { '<leader>rf', '<cmd>ReviewFinish<cr>',  desc = 'Review: Finish' },
    { '<leader>rn', '<cmd>ReviewNext<cr>',    desc = 'Review: Next' },
    { '<leader>rp', '<cmd>ReviewPrev<cr>',    desc = 'Review: Previous' },
  },
}

require('code-review').setup(opts) registers commands, keymaps and autocmds.

Commands

Command Description
:ReviewStart Start or reset a review session.
:ReviewAdd Add a comment at the cursor (normal) or visual selection.
:ReviewOpen [v|h] Open the review buffer in a split.
:ReviewCopy Yank the rendered review into the clipboard (no window needed).
:ReviewClose Close the review window (keeps the session).
:ReviewFinish Copy the review to the clipboard, then end the session, clear signs, close the buffer.
:ReviewNext / :ReviewPrev Jump between reviewed positions.

Workflow

  1. :ReviewStart (or just :ReviewAdd, which auto-starts a session).
  2. Put the cursor on a line — or visually select a range — and :ReviewAdd. A floating window opens for the comment. <C-s>/<CR> confirms, <Esc>/<C-c> cancels.
  3. :ReviewOpen renders all entries with file:line references. Inside that buffer: <CR> jumps to the position, e edits a comment, d deletes one.
  4. :ReviewCopy puts the whole review on the clipboard for pasting into a chat.
  5. :ReviewFinish copies the review to the clipboard, then ends the session and clears the gutter signs.

Persistence (opt-in)

Reviews are in-memory by default. Enable persistence to keep a review across Neovim restarts:

opts = {
  persist = {
    enabled = true,
    file = '.code-review', -- path relative to the cwd
  },
}

When enabled:

  • Adding, editing, or removing a comment auto-saves the file (JSON).
  • The first time you start reviewing in a session — and no review has happened yet — if a persisted file exists you're asked whether to restore it. Decline and the stale file is deleted so you start clean.
  • :ReviewFinish deletes the persisted file (the review is done and has just been copied to your clipboard). A restart mid-review still restores.

Add .code-review to your .gitignore (or commit it to share reviews).

See design.md for the full design and configuration defaults.

Development

make test

About

Review text in nvim for easy copy/paste into your favorite coding agent.

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors