From a52a496e5b0adf1bddc4e70ec3cf18c3040420fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Sun, 19 Nov 2023 02:55:18 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(nvim):=20diffview?= =?UTF-8?q?=20bindings=20changed=20as=20well=20as=20fixed=20git=20conflict?= =?UTF-8?q?=20not=20working=20correctly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/extras/editor/git/diffview.lua | 45 +++++++++++++++++-- .../extras/editor/git/git-conflict.lua | 23 +++++----- 2 files changed, 53 insertions(+), 15 deletions(-) diff --git a/.config/nvim/lua/plugins/extras/editor/git/diffview.lua b/.config/nvim/lua/plugins/extras/editor/git/diffview.lua index 5e08d373..919fdaed 100644 --- a/.config/nvim/lua/plugins/extras/editor/git/diffview.lua +++ b/.config/nvim/lua/plugins/extras/editor/git/diffview.lua @@ -1,7 +1,44 @@ return { - "sindrets/diffview.nvim", - keys = { - { "gd", "DiffviewFileHistory", desc = "Diff File History" }, + { + "sindrets/diffview.nvim", + keys = { + { "gd", "DiffviewFileHistory", desc = "Diff File History" }, + { "gD", "DiffviewOpen", desc = "Diff View Open" }, + }, + opts = function(_, opts) + local actions = require("diffview.actions") + + opts.keymaps = { + --stylua: ignore + view = { + { "n", "gCo", actions.conflict_choose("ours"), { desc = "Choose the OURS version of a conflict" } }, + { "n", "gCt", actions.conflict_choose("theirs"), { desc = "Choose the THEIRS version of a conflict" } }, + { "n", "gCb", actions.conflict_choose("base"), { desc = "Choose the BASE version of a conflict" } }, + { "n", "gCa", actions.conflict_choose("all"), { desc = "Choose all the versions of a conflict" } }, + { "n", "gCx", actions.conflict_choose("none"), { desc = "Delete the conflict region" } }, + { "n", "gCO", actions.conflict_choose_all("ours"), { desc = "Choose the OURS version of a conflict for the whole file" } }, + { "n", "gCT", actions.conflict_choose_all("theirs"), { desc = "Choose the THEIRS version of a conflict for the whole file" } }, + { "n", "gCB", actions.conflict_choose_all("base"), { desc = "Choose the BASE version of a conflict for the whole file" } }, + { "n", "gCA", actions.conflict_choose_all("all"), { desc = "Choose all the versions of a conflict for the whole file" } }, + { "n", "gCX", actions.conflict_choose_all("none"), { desc = "Delete the conflict region for the whole file" } }, + }, + --stylua: ignore + file_panel = { + { "n", "gCO", actions.conflict_choose_all("ours"), { desc = "Choose the OURS version of a conflict for the whole file" } }, + { "n", "gCT", actions.conflict_choose_all("theirs"), { desc = "Choose the THEIRS version of a conflict for the whole file" } }, + { "n", "gCB", actions.conflict_choose_all("base"), { desc = "Choose the BASE version of a conflict for the whole file" } }, + { "n", "gCA", actions.conflict_choose_all("all"), { desc = "Choose all the versions of a conflict for the whole file" } }, + { "n", "gCX", actions.conflict_choose_all("none"), { desc = "Delete the conflict region for the whole file" } }, + }, + } + end, + }, + { + "folke/which-key.nvim", + opts = { + defaults = { + ["gC"] = { name = "+conflicts" }, + }, + }, }, - opts = {}, } diff --git a/.config/nvim/lua/plugins/extras/editor/git/git-conflict.lua b/.config/nvim/lua/plugins/extras/editor/git/git-conflict.lua index 81eb4ed0..00c1c075 100644 --- a/.config/nvim/lua/plugins/extras/editor/git/git-conflict.lua +++ b/.config/nvim/lua/plugins/extras/editor/git/git-conflict.lua @@ -4,21 +4,22 @@ return { opts = { default_mappings = false, }, + version = "v1.0.0", + cmd = { "GitConflictChooseTheirs", "GitConflictChooseOurs", "GitConflictChooseBoth", "GitConflictListQf" }, keys = { - { "gct", "GitConflictChooseTheirs", desc = "Choose Their Changes" }, - { "gco", "GitConflictChooseOurs", desc = "Choose Our Changes" }, - { "gcb", "GitConflictChooseBoth", desc = "Choose Both changes" }, - { "gcl", "GitConflictListQf", desc = "Git Conflict Quicklist" }, + { "gCt", "GitConflictChooseTheirs", desc = "Choose Their Changes" }, + { "gCo", "GitConflictChooseOurs", desc = "Choose Our Changes" }, + { "gCb", "GitConflictChooseBoth", desc = "Choose Both changes" }, + { "gCl", "GitConflictListQf", desc = "Git Conflict Quicklist" }, { "[g", "GitConflictPrevConflict", desc = "Prev Git Conflict" }, { "]g", "GitConflictPrevConflict", desc = "Next Git Conflict" }, }, - - { - "folke/which-key.nvim", - opts = { - defaults = { - ["gc"] = { name = "+conflicts" }, - }, + }, + { + "folke/which-key.nvim", + opts = { + defaults = { + ["gC"] = { name = "+conflicts" }, }, }, },