Skip to content

Latest commit

 

History

History
40 lines (32 loc) · 2.47 KB

File metadata and controls

40 lines (32 loc) · 2.47 KB

Diff Review

Project Overview

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.

Core Technologies

  • 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.

Key Features

  • Review specific branches: Review changes between the current state and a given Git reference (e.g., master).
  • Workspace-wide reviews: Support for repo managed workspaces.
  • Quickfix integration: Uses the standard Vim quickfix list for navigating changed files.
  • Automatic Diffing: Automatically triggers Gvdiffsplit when navigating to a file from the review list.

Usage and Commands

Primary Commands

  • :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 a repo managed workspace.
  • :GreviewStop: Ends the review session and clears the quickfix list.

Navigation

  • ]q: Move to the next changed file in the quickfix list (via :cnext).
  • [q: Move to the previous changed file in the quickfix list (via :cprev).

Development Conventions

  • Naming Conventions: Internal functions are prefixed with s: and use CamelCase (e.g., s:ReviewStart). Global variables for tracking review state are prefixed with g:Review (e.g., g:ReviewStarted).
  • Dependencies: The plugin is heavily dependent on vim-fugitive. Ensure it is installed and available.
  • Event Driven: Uses autocmd on BufEnter within an augroup AutoReview to trigger the diff view when navigating through files during a review session.
  • Review Logic: Uses git diff --name-status to populate the quickfix list and Gvdiffsplit to render the diffs. Diffs are automatically skipped for newly added files (status 'A') to avoid showing an empty reference side.

Installation

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.