Note: This is an actively maintained fork of sindrets/diffview.nvim with bug fixes and improvements applied. The original repository has not been updated since June 2024. See
doc/diffview_changelog.txt(:h diffview.changelog) for breaking changes and notable additions.
Single tabpage interface for easily cycling through diffs for all modified files for any git rev. Review all changed files, resolve merge conflicts, and browse file history from a unified view.
- Neovim ≥ 0.10.0 (with LuaJIT)
- nvim-web-devicons or mini.icons (optional) for file icons
Supported VCS (at least one required):
- Git ≥ 2.31.0
- Mercurial ≥ 5.4.0
- Sapling (any version; detected automatically via the Mercurial adapter)
- Jujutsu ≥ 0.38.0
- Perforce ≥ 2019.1 with the
p4CLI (experimental)
-- Lazy
{
"dlyongemallo/diffview.nvim",
version = "*",
-- optional: lazy-load on command
-- cmd = {
-- "DiffviewOpen",
-- "DiffviewToggle",
-- "DiffviewFileHistory",
-- "DiffviewDiffFiles",
-- "DiffviewLog",
-- },
}" Plug
Plug 'dlyongemallo/diffview.nvim':DiffviewOpen " Diff working tree against index
:DiffviewFileHistory % " History for the current file
:DiffviewFileHistory " History for the whole repo
:DiffviewDiffFiles a b " Diff two arbitrary files
:DiffviewClose " Close the current diffviewPress g? in any diffview buffer to see all available keymaps.
See USAGE.md for detailed guides on PR review, stash inspection, and committing workflows.
-
Diff View — Browse all changed files in a single tabpage. Stage individual hunks by editing index buffers directly.

-
File History — List all commits affecting a file, directory, or line range. Filter by author, message, date range, and more.

-
Merge Tool — 3-way and 4-way diff layouts for resolving conflicts, with mappings for choosing OURS/THEIRS/BASE versions.

-
Staging — Stage and unstage individual files or all changes from the file panel (
-/s/S/U). You can stage individual hunks by editing any buffer that represents the index (after running:DiffviewOpenwith no[rev]the entries under "Changes" will have the index buffer on the left side, and the entries under "Staged changes" will have it on the right side). Once you write to an index buffer the index will be updated. (Note: Staging is a Git concept. These actions are no-ops on Jujutsu.) -
Unified Inline Diff —
diff1_inlinelayout renders adds/deletes in a single window via extmark overlays, with tree-sitter highlights preserved on both added and deleted lines. Configurable viaview.inline.style("unified"/"overleaf"). -
Multi-file Selection — Select multiple files in the file panel (
wto toggle,Cto clear) for batch stage / unstage / restore. Selections persist across Neovim restarts. -
Pin Local in File History — Run
:DiffviewFileHistory --pin-localto keep the working tree on one side while cycling commits on the other (Git only).
| Command | Description |
|---|---|
:DiffviewOpen [rev] [options] [ -- {paths...}] |
Open a diff view |
:DiffviewFileHistory [paths] [options] |
Browse file/commit history |
:DiffviewDiffFiles {file1} {file2} |
Diff two arbitrary files |
:DiffviewMergeFiles {output} [{base}] {left} {right} |
3-way / 4-way merge editor (no VCS required) |
:DiffviewDiffDirs {left} {right} [{output}] |
Compare two on-disk directories (no VCS required) |
:DiffviewClose |
Close the current diffview. You can also use :tabclose. |
:DiffviewToggleFiles |
Toggle the file panel |
:DiffviewFocusFiles |
Bring focus to the file panel |
:DiffviewRefresh[!] |
Update stats and entries in the file list (with !, also force-reload stage diff buffers) |
Examples:
:DiffviewOpen " Working tree changes
:DiffviewOpen HEAD~2 " Changes since HEAD~2
:DiffviewOpen origin/main...HEAD " Symmetric diff (PR-style)
:DiffviewOpen -- lua/diffview " Limit to specific paths
:DiffviewFileHistory % " Current file history
:'<,'>DiffviewFileHistory " History for selected lines- Jujutsu supports
:DiffviewOpen,:DiffviewFileHistory, and works as jj's external merge tool (:DiffviewMergeFiles) and diff editor (:DiffviewDiffDirs); see:h :DiffviewMergeFilesand:h :DiffviewDiffDirsfor~/.config/jj/config.tomlwiring. The options--cached,--staged,--imply-local, the--pin-localflag, and line-range history (:'<,'>DiffviewFileHistory) are not supported; staging actions are no-ops (jj has no staging index). In colocated repos, setpreferred_adapter = "jj"to use the Jujutsu adapter. - Sapling is detected automatically through the Mercurial adapter. Use
hg_cmdto configure the executable (e.g.hg_cmd = { "sl" }). - Perforce support is experimental. Requires the
p4CLI ≥ 2019.1 and the environment variablesP4PORT,P4USER,P4CLIENT.
For full command documentation, see :h diffview-commands.
Important
This plugin builds on nvim's built-in diff mode. Make sure you're familiar
with jumping between hunks (:h jumpto-diffs) and applying diff changes
(:h copy-diffs).
A minimal configuration showing commonly customised options:
require("diffview").setup({
enhanced_diff_hl = true,
use_icons = true,
view = {
default = { layout = "diff2_horizontal" },
merge_tool = { layout = "diff3_horizontal" },
},
file_panel = {
listing_style = "tree",
win_config = { position = "left", width = 35 }, -- Use "auto" to fit content
},
hooks = {}, -- See :h diffview-config-hooks
keymaps = {}, -- See :h diffview-config-keymaps
})For the full list of options with defaults, see
doc/diffview_defaults.txt or run
:h diffview.defaults in Neovim.
See RECIPES.md for ready-to-use configuration snippets covering PR review, merge conflicts, file history, and more.
- diffchar.vim — VSCode-style character/word-level diff highlighting. Works out of the box.
- Telescope — Select branches or commits interactively. See RECIPES.md for setup.
- gitsigns.nvim — When
installed and
watch_indexis enabled (the default), the file panel refreshes instantly after staging or unstaging hunks via gitsigns. - Neogit — Git porcelain with
built-in diffview integration (
integrations = { diffview = true }).
See TIPS.md for setup details and known compatibility issues.
See TIPS.md for common usage patterns, revision argument guide, LSP diagnostics in diffs, platform notes, and plugin compatibility.
| Resource | Description |
|---|---|
| USAGE.md | PR review, stash inspection, committing guides |
| RECIPES.md | Configuration snippets and recommended keymaps |
| TIPS.md | Tips, FAQ, and known compatibility issues |
:h diffview |
Full plugin documentation |
:h diffview.defaults |
Complete default configuration |