The simple git conflict resolver for neovim
quick demo
2024-10-06.21-19-44.mp4
You can customize these colors, I just picked something at random :P
- it has to be simple (in fact whole plugin is under 300 lua loc)
- performance-first (finding conflicts does not load whole buf into extra memory)
- highlights
- resolving conflicts
- diff3 style
Conflict ours
: resolves the conflict under the cursor with our changesConflict theirs
: resolves the conflict under the cursor with their changesConflict both
: resolves the conflict under the cursor with both changes (removes markers)Conflict none
: resolves the conflict the best way possible, just removing it xd
Highlighting is enabled by default but can be disabled by setting highlights = false
in config
Note for nvimdiff
users !!!: if highlighting is enabled, the Diff*
hl groups are disabled in buffers which have a
conflict, because those groups interfere heavily with conflict-marker.nvim
highlighting
ConflictOurs
ConflictTheirs
require("conflict-marker").setup({
highlights = true,
on_attach = function(conflict) end,
})
require("conflict-marker").setup({
on_attach = function(conflict)
local MID = "^=======$"
vim.keymap.set("n", "[x", function()
vim.cmd("?" .. MID)
end, { buffer = conflict.bufnr })
vim.keymap.set("n", "]x", function()
vim.cmd("/" .. MID)
end, { buffer = conflict.bufnr })
end,
})
require("conflict-marker").setup({
on_attach = function(conflict)
local map = function(key, fn)
vim.keymap.set("n", key, fn, { buffer = conflict.bufnr })
end
-- or you can map these to <cmd>ChooseOurs<cr>
map("co", function()
conflict:choose_ours()
end)
map("ct", function()
conflict:choose_theirs()
end)
map("cb", function()
conflict:choose_both()
end)
map("cn", function()
conflict:choose_none()
end)
end,
})