nvim: Add git conflict resolution mappings

Added simple merge conflict highlighting and resolution through
git-conflict.nvim plugin.

Allows moving to the next/prev conflict with ]x or [x respectively,
then resolving the conflict currently hovered by using ours/theirs/
both/or neither of the offered options (with `ho/hO/hm/hM`
respectively).
This commit is contained in:
Marty Oehme 2023-08-07 11:30:09 +02:00
parent 596962c4d1
commit 0a3ca9f2b1
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
2 changed files with 20 additions and 2 deletions

View file

@ -27,6 +27,7 @@
"fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" },
"friendly-snippets": { "branch": "main", "commit": "ea84a710262cb2c286d439070bad37d36fd3db25" },
"fwatch.nvim": { "branch": "main", "commit": "a691f7349dc66285cd75a1a698dd28bca45f2bf8" },
"git-conflict.nvim": { "branch": "main", "commit": "8d962d83cae924a314965f738ed1e05a4000d682" },
"gitsigns.nvim": { "branch": "main", "commit": "bb808fc7376ed7bac0fbe8f47b83d4bf01738167" },
"headlines.nvim": { "branch": "master", "commit": "ddef41b2664f0ce25fe76520d708e2dc9dfebd70" },
"jupyter-kernel.nvim": { "branch": "main", "commit": "5b409598033884a3d819e2a3bcd1fe340bc8d783" },

View file

@ -1,4 +1,21 @@
return {
{
"akinsho/git-conflict.nvim",
event = "VeryLazy",
config = function()
require("git-conflict").setup({
default_mappings = false,
disable_diagnostics = true,
})
vim.keymap.set("n", "<localleader>ho", "<Plug>(git-conflict-ours)", { desc = "Conflict use ours" })
vim.keymap.set("n", "<localleader>hO", "<Plug>(git-conflict-theirs)", { desc = "Conflict use theirs" })
vim.keymap.set("n", "<localleader>hm", "<Plug>(git-conflict-both)", { desc = "Conflict use both" })
vim.keymap.set("n", "<localleader>hM", "<Plug>(git-conflict-none)", { desc = "Conflict use none" })
vim.keymap.set("n", "[x", "<Plug>(git-conflict-prev-conflict)", { desc = "Prev git conflict" })
vim.keymap.set("n", "]x", "<Plug>(git-conflict-next-conflict)", { desc = "Next git conflict" })
end,
lazy = false, -- TODO needs to be force refreshed in lazy loaded mode unfortunately
},
{
"lewis6991/gitsigns.nvim", -- show vcs changes on left-hand gutter
event = "VeryLazy",
@ -24,7 +41,7 @@ return {
gs.next_hunk()
end)
return "<Ignore>"
end, { expr = true })
end, { expr = true, desc = "Next git hunk" })
map("n", "[h", function()
if vim.wo.diff then
@ -34,7 +51,7 @@ return {
gs.prev_hunk()
end)
return "<Ignore>"
end, { expr = true })
end, { expr = true, desc = "Previous git hunk" })
-- Actions
require("which-key").register({ ["<localleader>h"] = { name = "+git" } })