Requirements • Installation • Usage
A Neovim plugin for resolving merge conflicts.
Make resolving merge conflicts in Neovim a breeze.
- Neovim 0.10+
- Git 2.25+ (for
git mergetoolsupport) - Jujutsu v0.18+ (optional, for
jj resolvesupport)
Use your favorite plugin manager to install diffconflicts.nvim.
For example, with Lazy:
{
"mistweaverco/diffconflicts.nvim",
opts = {
-- Optional configuration
commands = {
-- Command to open the diff conflicts view, default is "DiffConflicts"
-- set to nil to disable the command
diff_conflicts = "DiffConflicts",
-- Command to show the history of conflicts, default is "DiffConflictsShowHistory"
-- set to nil to disable the command
show_history = "DiffConflictsShowHistory",
-- Command to resolve conflicts with history, default is "DiffConflictsWithHistory"
-- set to nil to disable the command
with_history = "DiffConflictsWithHistory",
},
-- Quality-of-life options
qol = {
-- After saving (:w), automatically close the diff view and jump to the next
-- conflict in the file (if any).
advance_on_save = true,
-- If no conflicts remain after saving, quit Neovim (:qa). This is useful
-- when running from `git mergetool` / `jj resolve`.
quit_on_done = true,
},
}
}Configure Git to use this plugin as a merge-tool:
git config --global merge.tool diffconflicts
git config --global mergetool.diffconflicts.cmd 'nvim -c DiffConflicts "$MERGED" "$BASE" "$LOCAL" "$REMOTE"'
git config --global mergetool.diffconflicts.trustExitCode true
git config --global mergetool.keepBackup falseConfigure Jujutsu to use this plugin as a merge tool
(requires the default "diff" conflict marker style):
[merge-tools.diffconflicts]
program = "nvim"
merge-args = [
"-c", "let g:jj_diffconflicts_marker_length=$marker_length",
"-c", "DiffConflictsWithHistory", "$output", "$base", "$left", "$right",
]
merge-tool-edits-conflict-markers = trueTo resolve merge conflicts, run:
git mergetoolOr for Jujutsu:
jj resolve --tool diffconflictsThis will open the conflicting file in Neovim with the diffconflicts.nvim plugin enabled.
You can also manually open a file and then run the command:
:DiffConflictsThis will open the current file in diff mode with the conflicts highlighted.
The left side shows the resolution, the right side shows the differences between the branches.
So all you need to do is edit the left side to resolve the conflicts.
By default, saving the file (:w) will automatically advance to the next conflict in the file, and if there are no conflicts left it will quit Neovim (so your merge tool can continue). You can customize this behavior via qol.advance_on_save and qol.quit_on_done.
To abort the merge, simply :cquit.
You can also use the Lua API to open the diff conflicts view:
require("diffconflicts").show()
require("diffconflicts").show_history()
require("diffconflicts").show_with_history()