English | 中文
Want my Neovim configuration? See dotfiles
A VS Code-style two-column Git diff view with dedicated tab isolation and automatic folding of unchanged code- Git — required for status, diff, staging, commits, branches, remotes, and worktrees
- vv-utils.nvim — required for shared Git parsing, filesystem, and UI utilities
- vv-icons.nvim — required for panel, help, and worktree icons
{
'beixiyo/vv-git.nvim',
dependencies = { 'beixiyo/vv-utils.nvim', 'beixiyo/vv-icons.nvim' },
cmd = {
'VVGit', 'VVGitClose', 'VVGitToggle', 'VVGitTogglePanel', 'VVGitRefresh',
'VVGitCompare', 'VVGitCompareRef', 'VVGitCompareRefs', 'VVGitCompareFile',
'VVGitCompareStop', 'VVGitCommitShow', 'VVGitWorktree', 'VVGitPublish',
'VVGitShow', 'VVGitSubrepoDepth', 'VVGitLoad',
},
---@type VVGitOpts
opts = {
width = 30, -- Left panel width
parent_repository = 'prompt', -- Prompt when cwd belongs to a repository above it (always/never)
single_col_threshold = 120, -- Fall back to one column + inline diff below this width
keymap_toggle_panel = '<leader>b', -- Toggle the left panel, vv-git buffers only (false to disable)
keymap_select = '<Tab>', -- Toggle selection for the current file (multi-select)
keymap_next_file = '<C-j>', -- Open the next file from a diff buffer (false disables)
keymap_prev_file = '<C-k>', -- Open the previous file from a diff buffer (false disables)
fold_unchanged = true, -- Fold unchanged code
fold_staged = false, -- Fold only the Staged Changes section when opening the panel
diff_fill = ' ', -- Fill character for diff filler lines (Vim defaults to '-')
preview = true, -- Refresh the right-side diff when moving over a file row
directory_preview = true, -- Show change counts and status breakdown when moving over a directory row
inline_diff_max_lines = 10000, -- Maximum line count for inline diff in single-column mode
diff_ratio = { 4, 6 }, -- Width ratio of a_win:b_win in two-column mode (defaults to 50:50)
conflict_result_ratio = 0.5, -- Height ratio of the bottom result/worktree window in conflict view
},
}| Option | Type | Default | Description |
|---|---|---|---|
width |
integer |
30 |
Left-panel width; manual changes persist across sessions |
parent_repository |
'prompt' | 'always' | 'never' |
'prompt' |
How implicit opens handle a Git repository above the cwd/explorer directory; prompt remembers the choice per directory for the current Neovim session |
single_col_threshold |
integer |
120 |
Use a single-column diff below this window width |
keymap_toggle_panel |
string | false |
'<leader>b' |
Toggle the left panel; only active inside vv-git's panel and diff buffers; false disables it |
fold_unchanged |
boolean |
true |
Fold unchanged code by default |
fold_staged |
boolean |
false |
Fold the parent repository's Staged Changes on open |
diff_fill |
string |
' ' |
Diff filler character |
preview |
boolean |
true |
Refresh the diff while moving in the left panel |
directory_preview |
boolean |
true |
Preview directory change statistics; requires preview |
auto_refresh |
boolean |
true |
Refresh Git status on BufEnter / FocusGained |
preview_debounce_ms |
integer |
150 |
Preview debounce in milliseconds; 0 disables it |
inline_diff_max_lines |
integer |
10000 |
Maximum line count for single-column inline diff |
worktree_preview |
'buffer' | 'snapshot' | fun(ctx): ('buffer' | 'snapshot') |
'snapshot' |
Which buffer backs the right side when previewing a worktree file; see "Worktree preview" below |
snapshot_promote_ms |
integer | false |
400 |
Swap a snapshot preview for the real buffer after the cursor rests this many milliseconds, keeping focus in the left panel; false swaps only when entering the right window |
right_click |
string | false |
'toggle_stage' |
Right-click action; false disables it |
yank_notify |
boolean |
false |
Notify after Y (or a yank_abs_path right-click) copies a path; clipboard errors are always reported |
diff_ratio |
number[] |
{ 5, 5 } |
Width ratio of a_win:b_win |
conflict_result_ratio |
number |
0.5 |
Conflict result-window height ratio (0.1–0.9) |
diff_nowrap |
boolean |
false |
Force wrapping off in diff windows |
highlights |
table |
nil |
Override any VVGit* highlight group |
before_open |
fun(): fun()? |
nil |
Runs before opening and may return a close-time restore function |
keymap_select |
string |
'<Tab>' |
Toggle selection for the current row (multi-select); directory nodes are ignored |
keymap_next_file |
string | false |
'<C-j>' |
Open the next file from a diff buffer |
keymap_prev_file |
string | false |
'<C-k>' |
Open the previous file from a diff buffer |
select_move_down |
boolean |
true |
Move down after toggling selection |
mappings |
table<string, fun(state)> |
{} |
Add or override left-panel mappings |
revision_mappings |
table<string, fun(context)> |
{} |
Add or override mappings in revision/index scratch buffers; context contains bufnr, winid, and source_path |
binary.intercept |
boolean |
true |
Intercept binary files and open them with the system application |
binary.extensions |
table<string, boolean> |
Built-in list | Binary extension overrides; merged with defaults |
subrepo.depth |
integer |
0 |
Nested-repository scan depth; 0 disables scanning |
subrepo.respect_gitignore |
boolean |
false |
Whether discovery skips directories ignored by the parent repository's .gitignore |
subrepo.prune |
string[] |
Built-in list | Directory names excluded from scans; replaces the default list |
subrepo.scan_worktrees |
boolean |
false |
Treat linked worktrees as nested repositories |
worktree.path |
fun(root, branch): string |
<root>/.worktrees/<branch-short> |
Path policy for new worktrees |
opts = { subrepo = { depth = 1, -- Scan one level below cwd for nested repositories respect_gitignore = false, -- Default; required to find ignored projects under a HOME repository -- prune is an array with replacement semantics. Providing it replaces the defaults -- (which include node_modules, .cache, .local, .cargo, and other caches). -- To extend the defaults, list the default entries as well. prune = { 'node_modules', '.cache', '.local', '.cargo', 'my_huge_dir' }, }, binary = { extensions = { png = false, jpg = false, jpeg = false }, }, highlights = { VVGitDiffAdd = { bg = '#1a3a1a' }, VVGitDiffAddAsDelete = { bg = '#4a1a1a' }, }, worktree = { path = function(root, branch) return vim.fs.joinpath(root, '.worktrees', branch) end, }, }
subrepo.prune uses replacement semantics; binary.extensions and highlights use merge semantics.
'buffer': load the real file on the right; LSP works immediately, but every j/k triggers a full load'snapshot'(default): show a read-only snapshot while browsing, without LSP; swapped for the real buffer when the cursor enters the right window. Already loaded files and the conflict result window always use the real buffersnapshot_promote_ms(default400): swap to the real buffer after the cursor rests this long, so diagnostics show while browsing- A function decides per file:
worktree_preview = function(ctx) -- { root, path, abspath, section, xy, size? } return (ctx.size or 0) > 200 * 1024 and 'snapshot' or 'buffer' end
vv-scrollbar.nvim: shows staged/unstaged lanes in regular diffs; conflict views use oneUlane on the upper-right theirs diff and omit the duplicate Result scrollbar.vv-statuscol.nvim: hides duplicate Git tracks in diff/result windows.
When :VVGit is opened from a cwd that is not inside a Git repository, the panel opens an initialization state. If the cwd only belongs to a repository above the workspace boundary, the default parent_repository='prompt' shows both p to open that parent and i to initialize the current directory. The cursor defaults to i when the parent ignores the directory and to p otherwise. Use either key or <CR> to continue into the normal repository view in the same tab. Choosing p is remembered per cwd for the current Neovim session, so reopening vv-git does not prompt again; restarting Neovim resets the choice. Explicit invalid root/path arguments are still rejected.
These mappings are active inside the left panel:
| Key | Description |
|---|---|
i |
Initialize the current cwd as a Git repository (non-repository or parent-repository choice screen) |
p |
Open a Git repository above the workspace boundary (choice screen only; remains push in a normal repository) |
gf |
Jump to the file |
Y |
Copy the absolute file path |
<Tab> |
Toggle selection for the current file (multi-select; directories are ignored; configurable with keymap_select) |
<Esc> |
Clear a non-empty selection; otherwise close the panel |
j / k / ↓ / ↑ |
Jump to the next/previous selectable item (<C-n>/<C-p> are aliases; arrow keys match j/k) |
<CR> / l / → |
Choice screen: run the selected action; file: open its diff; directory/section heading: expand or collapse it (→ matches l) |
o |
Open with a system tool: files use the default application and directories use the file manager |
X |
Execute according to file type: resolve a runner, ask for confirmation, then run it in a bottom split terminal (file nodes only) |
h / ← |
Collapse the current node; a child file collapses to its parent directory; on a top-level file or section heading, collapse the entire section (Staged / Changes / Merge Conflicts) and return to its heading (← matches h) |
zR |
Keep focus in the left panel while toggling all folds in the current right-side diff |
- |
Single selection: toggle stage/unstage; multi-selection: batch stage/unstage |
d |
Single selection—staged: unstage; unstaged: discard after confirmation; multi-selection: batch the corresponding single-selection behavior |
c |
Commit |
p |
Push |
P |
Pull |
u |
Publish the current branch: use origin when present, the only existing remote when unambiguous, select among multiple remotes, or ask only for an origin URL when none exists |
<C-e> |
Scroll the diff down |
<C-y> |
Scroll the diff up |
]c / [c |
Jump to and center the next/previous chunk in the right-side diff while remaining in the left panel |
gc |
Inspect a commit's own diff: select a branch, then a commit, and show the changes introduced by that commit (commit^..commit) |
gw |
Manage worktrees: create, switch, remove, and refresh them in a floating window (equivalent to :VVGitWorktree) |
H |
Compare with HEAD: select a branch, then a commit, and show the commit..HEAD difference |
g? |
Show help |
These mappings are active inside the right-hand diff windows (regular diff, ours, theirs, and Result):
| Key | Description |
|---|---|
q / <Esc> |
Close the right-hand view |
gf |
Jump to the file |
- |
Toggle stage/unstage for the current file |
]c / [c |
Jump to the next/previous chunk and center it |
<C-j> / <C-k> |
Move to the next/previous file in the left panel (keymap_next_file / keymap_prev_file) |
z* |
Native fold commands pass through (za, zR, zM, ...) |
< / > |
Conflict view: in the Result window, accept the block under the cursor, or move the cursor to the nearest block first when it is outside one; in the ours / theirs windows, accept the block nearest to the Result cursor. Every accept writes the file, and resolving the last block runs git add automatically |
= |
Conflict view: keep both sides, ours first then theirs, equivalent to git merge-file --union. Good when both sides appended independent content; when both changed the same statement it leaves duplicate lines to clean up by hand |
g? |
Show the keymaps of the current buffer; the Conflict category comes first in a conflict view |
In a conflict view, < / > in the left panel accept the whole file. The bottom Result window is the real worktree file and can be edited directly and saved with :w. The narrow single-column conflict view does not offer hunk-level < / >; use the whole-file accept in the left panel instead.
| Category | Commands |
|---|---|
| Panel | :VVGit, :VVGitClose, :VVGitToggle, :VVGitTogglePanel, :VVGitRefresh |
| Pickers | :VVGitCompare, :VVGitCommitShow, :VVGitWorktree |
| Revisions | :VVGitShow <ref>, :VVGitCompareRef <ref>, :VVGitCompareRefs <from> <to>, :VVGitCompareFile <ref>, :VVGitCompareStop |
| Git operation | :VVGitPublish |
| Configuration / loading | :VVGitSubrepoDepth [n], :VVGitLoad (lazy-load hook only) |
local git = require('vv-git') git.setup(opts, deps?) -- deps.state: optional panel-width state handle; defaults to `vv-git/panel` git.get_config() -- returns a copy of the resolved configuration git.open({ root?, path?, on_ready?, on_error?, on_close? }) git.close() git.toggle() git.toggle_panel() git.refresh() git.is_open() git.get_context() git.show_commit(ref, opts?) git.compare_with_head(ref, opts?) git.compare_refs(from_ref, to_ref, opts?) git.compare_file(ref, opts?) git.stop_compare() git.get_subrepo_depth() git.set_subrepo_depth(n) git.get_node_path() git.get_target_paths() git.get_node_dir()
open and the panel revision APIs accept:
{
root = '/path/to/repo', -- repository or a directory inside it; defaults to cwd
path = 'src/main.lua', -- repository-relative or absolute path
on_ready = function(context) end, -- panel / revision data is ready
on_error = function(message) end,
on_close = function(context) end, -- the entire vv-git tab has closed
on_goto_file = function(context) end, -- optional: override gf; by default vv-git closes and edits the file
}get_context() and callbacks return stable snapshots. When on_goto_file is provided, the caller owns file opening; compare_file also accepts bufnr.
Fields and methods whose names start with _ are internal implementation details and are not part of the public API.
vim.api.nvim_create_autocmd('User', { pattern = 'VVGitStatusChanged', callback = function(args) local root = args.data.root end, })
User VVGitStatusChanged is emitted after repository index refresh. Diff buffers declare their Git source through vv-utils.git.set_diff_source, so gutter plugins can compute line markers for them. vv-git also listens for User VVExplorerRootChanged:
vim.api.nvim_exec_autocmds('User', { pattern = 'VVExplorerRootChanged', data = { root = '/path/to/dir' }, })
./tests/run.sh [literal-filter]
Requires Unix-like OS, Neovim 0.12+, Git, POSIX shell and existing vv-utils.nvim source. VV_UTILS and NVIM_BIN can override discovery and the executable. The full suite needs existing vv-icons.nvim source (VV_ICONS override), also a required production dependency. Git writes and publish fixtures use only isolated local repositories.
The shared runner uses isolated children without personal configuration. Dependency discovery, CI checkouts and isolation are documented in the shared test guide. Headless tests do not replace TUI verification; CI needs an outer job timeout.