A Neovim plugin for performing partial diffs on selected code regions with advanced character-level diff highlighting powered by VSCode's diff algorithm.
https://github.com/user-attachments/assets/fcd3acfd-855b-4b54-a988-6bd2371344ba
{
"ryutaro-asada/partial-diff.nvim",
},
use {
'ryutaro-asada/partial-diff.nvim',
config = function()
require('partial-diff').setup()
end
}
require('partial-diff').setup({
-- Debug options
debug = false,
-- Highlight customization
highlights = {
-- Link to existing highlight groups
line_change = 'DiffChange',
line_add = 'DiffAdd',
line_delete = 'DiffDelete',
-- Specify custom colors
char_add = {
bg = '#2d5a2d', -- Background color
fg = '#a9dc76', -- Foreground color
bold = true, -- Bold
italic = false, -- Italic
underline = false -- Underline
},
char_delete = {
bg = '#5a2d2d',
fg = '#ff6188',
},
char_change = {
bg = '#4a4a0e',
fg = '#ffd866',
bold = true
}
}
})
For better character-level diff highlighting, install the VSCode diff algorithm:
:PartialDiffInstallVSCode in NeovimWithout this, the plugin will fall back to Neovim's built-in diff.
:PartialDiffFrom - Mark a range of lines as the source (what you're diffing from):PartialDiffTo - Mark a range of lines as the target (what you're diffing to) and display the diff:PartialDiffDelete - Close the current diff view:PartialDiffInstallVSCode - Install VSCode diff algorithm dependencies:PartialDiffA - Alias for :PartialDiffFrom:PartialDiffB - Alias for :PartialDiffTo:PartialDiffShowLog - Show the debug log file:PartialDiffClearLog - Clear the debug log file:PartialDiffFrom (or use your keymap):PartialDiffTo (or use your keymap)" Select lines 10-20 in visual mode
:'<,'>PartialDiffFrom
" Select lines 30-40 in visual mode
:'<,'>PartialDiffTo
" Close the diff when done
:PartialDiffDelete
If you have any suggestions or improvements, feel free to open an issue or submit a pull request.
This project is licensed under the MIT License.