2023-05-14 13:40:39 +02:00
|
|
|
---@type LazyPluginSpec[]
|
2023-03-12 02:43:24 +01:00
|
|
|
return {
|
|
|
|
"tpope/vim-fugitive",
|
2023-04-19 17:06:16 +02:00
|
|
|
{
|
|
|
|
"TimUntersberger/neogit",
|
|
|
|
dependencies = {
|
|
|
|
"nvim-lua/plenary.nvim",
|
|
|
|
"sindrets/diffview.nvim",
|
|
|
|
},
|
|
|
|
opts = {
|
|
|
|
integrations = {
|
|
|
|
diffview = true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2023-03-12 02:43:24 +01:00
|
|
|
{
|
|
|
|
"lewis6991/gitsigns.nvim",
|
|
|
|
config = function()
|
|
|
|
local present, wk = pcall(require, "which-key")
|
|
|
|
|
|
|
|
if not present then
|
|
|
|
vim.notify("which-key not found")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local gs = require("gitsigns")
|
|
|
|
|
|
|
|
gs.setup({
|
2023-05-14 13:40:39 +02:00
|
|
|
on_attach = function(_)
|
2023-03-12 02:43:24 +01:00
|
|
|
-- Gitsigns
|
|
|
|
wk.register({
|
|
|
|
["<leader>h"] = {
|
|
|
|
name = "+Gitsigns",
|
|
|
|
s = { "<cmd>Gitsigns stage_hunk<CR>", "Stage Hunk" },
|
|
|
|
r = { "<cmd>Gitsigns reset_hunk<CR>", "Reset Hunk" },
|
|
|
|
},
|
|
|
|
}, { mode = { "n", "v" } })
|
|
|
|
|
|
|
|
wk.register({
|
|
|
|
["<leader>h"] = {
|
|
|
|
name = "+Gitsigns",
|
|
|
|
s = { gs.stage_buffer, "Stage Buffer" },
|
|
|
|
u = { gs.undo_stage_hunk, "Undo Stage Hunk" },
|
|
|
|
R = { gs.reset_buffer, "Reset Buffer" },
|
|
|
|
p = { gs.preview_hunk, "Preview Hunk" },
|
|
|
|
b = {
|
|
|
|
function()
|
|
|
|
gs.blame_line({ full = true })
|
|
|
|
end,
|
|
|
|
"Blame line",
|
|
|
|
},
|
|
|
|
d = { gs.diffthis, "Diff current buffer" },
|
|
|
|
D = {
|
|
|
|
function()
|
|
|
|
gs.diffthis("~")
|
|
|
|
end,
|
|
|
|
"Diff against last commit",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
wk.register({
|
|
|
|
["<leader>t"] = {
|
|
|
|
name = "+Toggle settings",
|
|
|
|
b = { gs.toggle_current_line_blame, "Toggle blame lines" },
|
|
|
|
d = { gs.toggle_deleted, "Toggle deleted lines" },
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
wk.register({
|
|
|
|
["[c"] = {
|
|
|
|
function()
|
|
|
|
if vim.wo.diff then
|
2023-06-13 08:59:42 +02:00
|
|
|
return "[c"
|
2023-03-12 02:43:24 +01:00
|
|
|
end
|
|
|
|
vim.schedule(function()
|
2023-06-13 08:59:42 +02:00
|
|
|
gs.prev_hunk()
|
2023-03-12 02:43:24 +01:00
|
|
|
end)
|
|
|
|
return "<Ignore>"
|
|
|
|
end,
|
2023-06-13 08:59:42 +02:00
|
|
|
"Go to previous hunk",
|
2023-03-12 02:43:24 +01:00
|
|
|
},
|
|
|
|
["]c"] = {
|
|
|
|
function()
|
|
|
|
if vim.wo.diff then
|
2023-06-13 08:59:42 +02:00
|
|
|
return "]c"
|
2023-03-12 02:43:24 +01:00
|
|
|
end
|
|
|
|
vim.schedule(function()
|
2023-06-13 08:59:42 +02:00
|
|
|
gs.next_hunk()
|
2023-03-12 02:43:24 +01:00
|
|
|
end)
|
|
|
|
return "<Ignore>"
|
|
|
|
end,
|
2023-06-13 08:59:42 +02:00
|
|
|
"Go to next hunk",
|
2023-03-12 02:43:24 +01:00
|
|
|
},
|
|
|
|
}, { expr = true })
|
|
|
|
|
|
|
|
-- Text object
|
|
|
|
wk.register({
|
|
|
|
["ih"] = { ":<C-U>Gitsigns select_hunk<CR>", "Select inside Hunk" },
|
|
|
|
}, { mode = { "o", "x" } })
|
|
|
|
end,
|
2023-05-14 13:40:39 +02:00
|
|
|
current_line_blame = true,
|
2023-03-12 02:43:24 +01:00
|
|
|
current_line_blame_formatter = "<author>, <author_time:%R> - <summary> | <abbrev_sha>",
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
}
|