init
This commit is contained in:
75
nvim/lua/plugins/extras/editor/git/diffview.lua
Normal file
75
nvim/lua/plugins/extras/editor/git/diffview.lua
Normal file
@@ -0,0 +1,75 @@
|
||||
local prefix = "<leader>gC"
|
||||
local function toggle_diffview(cmd)
|
||||
if next(require("diffview.lib").views) == nil then
|
||||
vim.cmd(cmd)
|
||||
else
|
||||
vim.cmd("DiffviewClose")
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
{
|
||||
"sindrets/diffview.nvim",
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{ "<leader>gD", function() toggle_diffview("DiffviewFileHistory") end, desc = "Diff Repo" },
|
||||
{ "<leader>gd", function() toggle_diffview("DiffviewOpen") end, desc = "Diff View" },
|
||||
{ "<leader>gF", function() toggle_diffview("DiffviewFileHistory %") end, desc = "Diff Current File" },
|
||||
},
|
||||
opts = function(_, opts)
|
||||
local actions = require("diffview.actions")
|
||||
|
||||
opts.enhanced_diff_hl = true
|
||||
opts.view = {
|
||||
default = { winbar_info = true },
|
||||
file_history = { winbar_info = true },
|
||||
}
|
||||
opts.hooks = {
|
||||
diff_buf_read = function(bufnr)
|
||||
vim.b[bufnr].view_activated = false
|
||||
end,
|
||||
}
|
||||
|
||||
opts.keymaps = {
|
||||
--stylua: ignore
|
||||
view = {
|
||||
{ "n", prefix .. "o", actions.conflict_choose("ours"), { desc = "Choose the OURS version of a conflict" } },
|
||||
{ "n", prefix .. "t", actions.conflict_choose("theirs"), { desc = "Choose the THEIRS version of a conflict" } },
|
||||
{ "n", prefix .. "b", actions.conflict_choose("base"), { desc = "Choose the BASE version of a conflict" } },
|
||||
{ "n", prefix .. "a", actions.conflict_choose("all"), { desc = "Choose all the versions of a conflict" } },
|
||||
{ "n", prefix .. "x", actions.conflict_choose("none"), { desc = "Delete the conflict region" } },
|
||||
{ "n", prefix .. "O", actions.conflict_choose_all("ours"), { desc = "Choose the OURS version of a conflict for the whole file" } },
|
||||
{ "n", prefix .. "T", actions.conflict_choose_all("theirs"), { desc = "Choose the THEIRS version of a conflict for the whole file" } },
|
||||
{ "n", prefix .. "B", actions.conflict_choose_all("base"), { desc = "Choose the BASE version of a conflict for the whole file" } },
|
||||
{ "n", prefix .. "A", actions.conflict_choose_all("all"), { desc = "Choose all the versions of a conflict for the whole file" } },
|
||||
{ "n", prefix .. "X", actions.conflict_choose_all("none"), { desc = "Delete the conflict region for the whole file" } },
|
||||
},
|
||||
--stylua: ignore
|
||||
file_panel = {
|
||||
{ "n", prefix .. "O", actions.conflict_choose_all("ours"), { desc = "Choose the OURS version of a conflict for the whole file" } },
|
||||
{ "n", prefix .. "T", actions.conflict_choose_all("theirs"), { desc = "Choose the THEIRS version of a conflict for the whole file" } },
|
||||
{ "n", prefix .. "B", actions.conflict_choose_all("base"), { desc = "Choose the BASE version of a conflict for the whole file" } },
|
||||
{ "n", prefix .. "A", actions.conflict_choose_all("all"), { desc = "Choose all the versions of a conflict for the whole file" } },
|
||||
{ "n", prefix .. "X", actions.conflict_choose_all("none"), { desc = "Delete the conflict region for the whole file" } },
|
||||
},
|
||||
}
|
||||
end,
|
||||
},
|
||||
{
|
||||
"NeogitOrg/neogit",
|
||||
optional = true,
|
||||
opts = {
|
||||
integrations = {
|
||||
diffview = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"folke/which-key.nvim",
|
||||
opts = {
|
||||
spec = {
|
||||
{ prefix, group = "conflicts", icon = " " },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user