2023-05-22 01:56:32 +00:00
|
|
|
return {
|
|
|
|
"lewis6991/gitsigns.nvim",
|
|
|
|
main = "gitsigns",
|
2023-12-14 09:45:05 +00:00
|
|
|
event = "VeryLazy",
|
2023-07-21 08:29:53 +00:00
|
|
|
enabled = custom.full_feature,
|
2023-05-22 01:56:32 +00:00
|
|
|
opts = {
|
|
|
|
on_attach = function(bufnr)
|
|
|
|
local gs = package.loaded.gitsigns
|
|
|
|
local function m(mode, l, r, opts)
|
|
|
|
opts = opts or {}
|
|
|
|
opts.buffer = bufnr
|
|
|
|
vim.keymap.set(mode, l, r, opts)
|
|
|
|
end
|
|
|
|
|
2023-12-15 04:53:14 +00:00
|
|
|
m("n", "<leader>hn", function()
|
2023-05-22 01:56:32 +00:00
|
|
|
if vim.wo.diff then return "]c" end
|
|
|
|
vim.schedule(function() gs.next_hunk() end)
|
|
|
|
return "<Ignore>"
|
|
|
|
end, {expr=true})
|
|
|
|
|
2023-12-15 04:53:14 +00:00
|
|
|
m("n", "<leader>hp", function()
|
2023-12-14 13:45:10 +00:00
|
|
|
if vim.wo.diff then return "[c" end
|
2023-05-22 01:56:32 +00:00
|
|
|
vim.schedule(function() gs.prev_hunk() end)
|
2023-12-14 13:45:10 +00:00
|
|
|
return "<Ignore>"
|
2023-05-22 01:56:32 +00:00
|
|
|
end, {expr=true})
|
|
|
|
|
2023-12-14 13:45:10 +00:00
|
|
|
m("n", "<leader>hs", gs.stage_hunk)
|
|
|
|
m("n", "<leader>hr", gs.reset_hunk)
|
|
|
|
m("v", "<leader>hs", function() gs.stage_hunk {vim.fn.line("."), vim.fn.line("v")} end)
|
|
|
|
m("v", "<leader>hr", function() gs.reset_hunk {vim.fn.line("."), vim.fn.line("v")} end)
|
|
|
|
m("n", "<leader>hS", gs.stage_buffer)
|
|
|
|
m("n", "<leader>hu", gs.undo_stage_hunk)
|
|
|
|
m("n", "<leader>hR", gs.reset_buffer)
|
2023-12-15 04:53:14 +00:00
|
|
|
m("n", "<leader>hv", gs.preview_hunk)
|
2023-12-14 13:45:10 +00:00
|
|
|
m("n", "<leader>hb", function() gs.blame_line{full=true} end)
|
2023-12-14 13:51:46 +00:00
|
|
|
m("n", "<leader>htb", gs.toggle_current_line_blame)
|
2023-12-14 13:45:10 +00:00
|
|
|
m("n", "<leader>hd", gs.diffthis)
|
|
|
|
m("n", "<leader>hD", function() gs.diffthis("~") end)
|
2023-12-14 13:51:46 +00:00
|
|
|
m("n", "<leader>htd", gs.toggle_deleted)
|
2023-05-22 01:56:32 +00:00
|
|
|
end,
|
|
|
|
},
|
|
|
|
config = function (lazyplug, opts)
|
|
|
|
require(lazyplug.main).setup(opts)
|
|
|
|
end,
|
|
|
|
}
|