A powerful Neovim plugin for handling diffs and resolving git conflicts with an intuitive UI.
- 🔀 Git Conflict Resolution: Easily resolve merge conflicts with intuitive keybindings
- 📊 Diff Overlay: View and apply changes with inline or split diff views
- 🤝 CodeCompanion Integration: Seamlessly integrates with CodeCompanion.nvim
- ⚡ Fast and Lightweight: Built with performance in mind
- 🎨 Customizable: Flexible configuration and theming
Using lazy.nvim
{
"painfire/diffui.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
},
config = function()
require("diffui").setup({
-- Your configuration here
})
end,
}Using packer.nvim
use {
"painfire/diffui.nvim",
requires = { "nvim-lua/plenary.nvim" },
config = function()
require("diffui").setup()
end
}Default configuration:
require("diffui").setup({
-- Git conflict resolution
conflict = {
enabled = true,
keymaps = {
choose_ours = "co",
choose_theirs = "ct",
choose_both = "cb",
choose_none = "c0",
next_conflict = "]x",
prev_conflict = "[x",
},
highlights = {
current = "DiffAdd",
incoming = "DiffChange",
ancestor = "DiffDelete",
},
},
-- Diff viewing and editing
diff = {
enabled = true,
provider = "internal",
keymaps = {
apply = "<leader>da",
reject = "<leader>dr",
next_hunk = "]c",
prev_hunk = "[c",
toggle_overlay = "<leader>do",
},
overlay = {
style = "inline", -- "inline" or "split"
position = "right",
},
},
-- CodeCompanion integration
codecompanion = {
enabled = true,
auto_attach = true,
show_diff_on_apply = true,
},
-- UI settings
ui = {
border = "rounded",
winblend = 0,
signs = {
add = "│",
change = "│",
delete = "_",
topdelete = "‾",
changedelete = "~",
},
},
})When you open a file with git conflicts, DiffUI will automatically detect and highlight them:
co- Choose ours (current branch)ct- Choose theirs (incoming branch)cb- Choose both versionsc0- Choose none (delete conflict)]x- Jump to next conflict[x- Jump to previous conflict
Toggle diff overlay:
:DiffUiToggleOr use the keymap: <leader>do
Apply/reject hunks:
<leader>da- Apply current hunk<leader>dr- Reject current hunk
When CodeCompanion makes changes to your buffer, DiffUI automatically tracks the original content and shows a diff overlay when done (if show_diff_on_apply is enabled).
:DiffUiConflictChooseOurs- Choose our version in conflict:DiffUiConflictChooseTheirs- Choose their version in conflict:DiffUiConflictChooseBoth- Choose both versions:DiffUiConflictNext- Jump to next conflict:DiffUiConflictPrev- Jump to previous conflict:DiffUiToggle- Toggle diff overlay:DiffUiApply- Apply current hunk:DiffUiReject- Reject current hunk
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE file for details