Git integration

Kvim's Git integration is editor-owned. The Explorer workspace includes a read-only Git tab for navigating changed files, while focused buffers retain Git signs and hunk review actions. Kvim does not delegate to an external Git client and the Git tab never mutates the repository.

Kvim home

For GitHub and GitHub Enterprise PR threads, draft comments, and explicit review submission, use the separate PR Review workspace with :review or Open PR Review in the command palette. Local Git navigation and hunk staging do not require a PR or GitHub authentication.

Changed-file navigation

Open Explorer and select Git with 2, Tab, or Shift-Tab. Kvim discovers the repository from Commander's focused directory and asynchronously builds a collapsible tree containing staged, unstaged, conflicted, untracked, deleted, renamed, and copied paths. Ignored files are omitted.

Each row begins with three status columns:

Status letters are A added, M modified, D deleted, R renamed, C copied, and U conflicted. Directories aggregate the status of their descendants. File and directory icons follow the configured glyph profile; file icons use their filetype colors, while path labels and each status column use Git colors for added, modified, removed, and conflicted changes. The tree keeps a dim vertical scrollbar track even when its rows fit or the tree is empty. A proportional thumb appears when scrolling is needed; with a preview open, the track uses the existing tree/preview divider. The track is an indicator, not a file-selection target.

Navigation uses:

Opening a path reuses an existing buffer, preserving unsaved contents. Deleted paths remain visible but cannot be opened. Symlinks, reparse points, submodules, special files, and paths resolving outside the repository are not opened as ordinary files.

The last successful status snapshot is reused within the current Kvim session when switching tabs or reopening Explorer in the same repository. This keeps large repositories immediately navigable; press r when an external tool changes the index or worktree. Unsaved Kvim buffer markers continue to update while the tab is open.

The Git tab deliberately has no staging, unstaging, discard, stash, commit, pull, push, or remote-management actions. Its status scan uses gix, runs off the editor thread, is cancellable and bounded, and rejects stale results.

Change preview

Selecting a changed file automatically shows a read-only unified diff on the right. Each comparison shows the complete file, with removed and added lines interleaved and all unchanged code available by scrolling, without @@ headers. The preview keeps Staged changes (HEAD to index) separate from Unstaged changes (index to current text), showing one comparison at a time. It opens Unstaged when available, otherwise Staged; c switches comparisons when both exist, preserving their independent scroll and hunk positions. Current text comes from an existing editor buffer when available, including unsaved edits, or from disk otherwise. The header identifies the active source as [index], [buffer], [unsaved buffer], or [disk]. A deleted file's clean, previously opened buffer does not hide its on-disk deletion.

Added and removed lines use colored backgrounds rather than +/- prefixes. Syntax colors follow the active theme, including Kterm's terminal palette, and remain visible over line and inline-change backgrounds. Added lines receive stronger within-line highlights only when paired with removed text. New files, addition-only hunks, and extra inserted lines in mixed hunks retain syntax colors and the subtle added-line background without an extra full-text overlay. When resolved theme colors would make comments hard to read, their color is lightened or darkened just enough for contrast against the final diff background, including selection. Other syntax colors are preserved.

The tree starts at approximately 35% of the available width. Use the existing window.resize_left/window.resize_right bindings (Ctrl-Shift-H/L by default) to resize the divider. Its Git-specific ratio is persisted independently from Commander and other previews. Terminals narrower than 65 columns show only the tree, preserving usable minimum widths for both panes.

Additions, untracked files, deletions, renames, and copies can be previewed. Rename/copy headers identify the active comparison's source path, without carrying rename information across baselines. Rename-only and mode-only changes show the complete file with a no-textual-changes header. Directories show a selection hint; conflicts, binary/non-UTF-8 content, submodules, symlinks, reparse points, and unsupported objects show an explanation rather than an empty diff. Sparse-checkout index entries also show an explanation instead of appearing as on-disk deletions.

Preview work uses gix off the editor thread, with a single shared worker, cancellation, and stale-result rejection. Each input is limited to 4 MiB, 50,000 lines, and 16 KiB per line; exceeding a limit shows an explanation. Filesystem reads retain no-follow and repository-confinement checks. Browsing the preview never changes buffers, the index, or the worktree. Built-in Git line-ending and encoding conversions are honored, but external filter drivers are never executed by passive previews; affected files show an explanation.

Git signs

For a path-backed buffer inside a Git worktree, Kvim compares the current buffer text with the file at HEAD and renders added, modified, and removed line indicators in the gutter. Work runs asynchronously and stale results are discarded when the buffer changes.

Files outside a worktree simply have no Git signs. Symlinks, reparse points, special files, binary files, submodules, and unsupported index states are rejected rather than followed or treated as ordinary editable files.

Hunk review

Open the focused buffer's hunk view with <space>h or :hunks.

The hunk view compares the in-memory buffer against the Git index, so it can show unstaged edits before they are saved. Navigation supports j/k, arrow keys, Ctrl-d/Ctrl-u, Ctrl-f/Ctrl-b, g/G, and Home/End.

Enter leaves the view open with an explanation if hunks are still loading, a save or hunk transaction is in progress, the view is stale, or no source location is selected. Unlike Enter, q and Esc do not reposition the editor cursor.

Stage and discard operations revalidate the repository, index, file identity, and buffer revision before mutation. They preserve unrelated index and worktree content, run away from the editor loop, support cancellation, and report stale or indeterminate outcomes instead of hiding them behind a success-shaped result.

Discard updates the worktree through the verified file handle and reloads the shared buffer only after the operation succeeds. Multiple windows showing the same buffer remain synchronized.