Skip to content

About

A Neovim plugin for reviewing git diffs file by file using vim-fugitive

Resources

Stars

3 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

git-review.nvim

CI License: MIT

A Neovim plugin for reviewing git diffs file by file using vim-fugitive's diff view.

Features

  • Review changes against any branch with a side-by-side diff view
  • Navigate between changed files with configurable keymaps
  • Automatic file list from git diff --name-only
  • Completion for common branch names (origin/main, main, master, HEAD~1)

Requirements

Installation

lazy.nvim

{
  "LuccaRomanelli/git-review.nvim",
  dependencies = { "tpope/vim-fugitive" },
  config = function()
    require("git-review").setup()
  end,
}

packer.nvim

use {
  "LuccaRomanelli/git-review.nvim",
  requires = { "tpope/vim-fugitive" },
  config = function()
    require("git-review").setup()
  end,
}

vim-plug

Plug 'tpope/vim-fugitive'
Plug 'LuccaRomanelli/git-review.nvim'

" In your init.lua or after/plugin:
lua require("git-review").setup()

Configuration

require("git-review").setup({
  -- Default branch to diff against
  default_branch = "origin/main",

  -- Keymaps for navigation
  keymaps = {
    next = "]g",  -- Go to next changed file
    prev = "[g",  -- Go to previous changed file
  },

  -- Set to false to define your own keymaps
  keymaps_enabled = true,
})

Custom Keymaps

If you prefer to set up your own keymaps:

require("git-review").setup({
  keymaps_enabled = false,
})

local git_review = require("git-review")
vim.keymap.set("n", "<leader>gn", git_review.next, { desc = "Next file in git review" })
vim.keymap.set("n", "<leader>gp", git_review.prev, { desc = "Previous file in git review" })

Usage

Commands

Command Description
:GitReview [branch] Start reviewing changes against a branch (default: origin/main)
:GitReviewStop Stop the current review session

Default Keymaps

Keymap Description
]g Go to next changed file
[g Go to previous changed file

Example Workflow

  1. Start a review session:

    :GitReview origin/main
  2. Navigate through changed files:

    • Press ]g to go to the next file
    • Press [g to go to the previous file
  3. When you reach the last file and press ]g, you'll be prompted to quit or go back.

API

Functions

require("git-review").setup(opts)

Initialize the plugin with optional configuration.

require("git-review").start(branch)

Start a review session against the specified branch.

require("git-review").next()

Navigate to the next changed file.

require("git-review").prev()

Navigate to the previous changed file.

require("git-review").stop()

Stop the current review session.

require("git-review").is_active()

Returns true if a review session is currently active.

require("git-review").status()

Returns the current review status:

{
  current = 2,        -- Current file index
  total = 5,          -- Total number of changed files
  file = "foo.lua",   -- Current file name
  branch = "main",    -- Branch being diffed against
}

License

MIT

About

A Neovim plugin for reviewing git diffs file by file using vim-fugitive

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages