Diff Review is a Vim plugin that integrates with the quickfix list and vim-fugitive to facilitate a seamless code review experience directly within Vim. It automatically identifies changes in a Git repository (or a repo workspace) and provides commands to navigate through files, showing a vertical diff for each one.
- Vimscript: The primary language used for the plugin's logic.
- Git: Relied upon for identifying changed files (
git diff). - vim-fugitive: A mandatory prerequisite for handling Git operations and diff views (
Gvdiffsplit). - Vim/Neovim: Compatible with Vim 8.0+ or Neovim.
- Review specific branches: Review changes between the current state and a given Git reference (e.g.,
master). - Workspace-wide reviews: Support for
repomanaged workspaces. - Quickfix integration: Uses the standard Vim
quickfixlist for navigating changed files. - Automatic Diffing: Automatically triggers
Gvdiffsplitwhen navigating to a file from the review list.
:Greview [ref]: Starts a review against the specified reference. If no reference is provided, it reviews changes in the current working directory.:GreviewRepo [ref]: Reviews changes in arepomanaged workspace.:GreviewStop: Ends the review session and clears thequickfixlist.
]q: Move to the next changed file in thequickfixlist (via:cnext).[q: Move to the previous changed file in thequickfixlist (via:cprev).
- Naming Conventions: Internal functions are prefixed with
s:and use CamelCase (e.g.,s:ReviewStart). Global variables for tracking review state are prefixed withg:Review(e.g.,g:ReviewStarted). - Dependencies: The plugin is heavily dependent on
vim-fugitive. Ensure it is installed and available. - Event Driven: Uses
autocmdonBufEnterwithin anaugroup AutoReviewto trigger the diff view when navigating through files during a review session. - Review Logic: Uses
git diff --name-statusto populate thequickfixlist andGvdiffsplitto render the diffs. Diffs are automatically skipped for newly added files (status 'A') to avoid showing an empty reference side.
Add the following to your .vimrc (using a plugin manager like vim-plug or Vundle):
Plugin 'codable/diffreview'Ensure tpope/vim-fugitive is also installed.