Skip to content

bbuchanan/vscode-diff.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vscode-diff.nvim

A Neovim plugin aiming to replicate the smooth, sexy, and visual diff experience of VS Code.

Goals

  • Visual Fidelity: Match VS Code's diff colors and highlighting style.
  • Smart Diffing: Use Neovim's linematch for precise intra-line comparisons.
  • Git Integration: Seamlessly compare working files against HEAD or other commits.
  • Side-by-Side: Classic split view with synchronized scrolling.

Features

  • Jump Between Changes: Press n for next change, N for previous change
  • Quick Close: Press Esc or q to close the diff view
  • Git Blame: Press b to show git blame info for the current line
  • Copy from Git: Press g to copy the current hunk from the git version to your working copy
  • Custom Colors: Override the default VS Code colors with your own palette
  • Diff Against Buffer: Compare your current file with any other open buffer
  • Gutter Signs: Visual indicators (+/-/~) show additions, deletions, and changes in the gutter
  • Hunk Actions: Apply or revert hunks with a (apply from git) and r (revert to git)
  • Current Hunk Highlight: Automatically highlights the hunk under your cursor
  • Diff Two Commits: Compare any two commits interactively with :VscodeDiffCommits

Usage

Basic Diff

Run :VscodeDiff to diff the current file against HEAD.

Compare Against Specific Commit

Run :VscodeDiff <commit_hash> to compare against a specific commit.

Interactive Commit Selection

Run :VscodeDiffPick to select a commit from an interactive menu.

Compare Against Buffer

Run :VscodeDiffBuffer to compare the current file against another open buffer.

Git Blame

Run :VscodeDiffBlame to show git blame info for the current line (also works with b key in diff mode).

Copy from Git

Run :VscodeDiffCopy to copy the current hunk from git version to working copy (also works with g key in diff mode).

Diff Two Commits

Run :VscodeDiffCommits to interactively select two commits and compare them. First select the older commit, then select the newer commit.

Apply Hunk

Run :VscodeDiffApply to apply the current hunk from the git version to your working copy (also works with a key in diff mode).

Revert Hunk

Run :VscodeDiffRevert to revert the current hunk to the git version (also works with r key in diff mode).

Keybindings (in diff mode)

  • n - Jump to next change
  • N - Jump to previous change
  • Esc / q - Close diff view
  • b - Show git blame for current line
  • g - Copy hunk from git to working copy
  • a - Apply current hunk from git version to working copy
  • r - Revert current hunk to git version

Configuration

Customize colors with the setup() function:

require("vscode-diff").setup({
    colors = {
        DiffAdd    = { bg = "#your_color" },
        DiffDelete = { bg = "#your_color" },
        DiffChange = { bg = "#your_color" },
        DiffText   = { bg = "#your_color" },
    }
})

Installation

lazy.nvim

{
    "bbuchanan/vscode-diff.nvim",
    config = function()
        require("vscode-diff").setup()
    end,
}

vim-plug

Plug 'bbuchanan/vscode-diff.nvim'

packer.nvim

use 'bbuchanan/vscode-diff.nvim'

Installation (Dev)

If you are developing this plugin locally, point your plugin manager to the local directory.

lazy.nvim

{
    "vscode-diff",
    dir = "~/projects/vscode-diff-nvim", -- Adjust path if needed
    config = function()
        require("vscode-diff").setup()
    end,
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages