---@type LazyPluginSpec[] return { "tpope/vim-fugitive", { "TimUntersberger/neogit", dependencies = { "nvim-lua/plenary.nvim", "sindrets/diffview.nvim", }, opts = { integrations = { diffview = true, }, }, }, { "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({ on_attach = function(_) -- Gitsigns wk.register({ ["h"] = { name = "+Gitsigns", s = { "Gitsigns stage_hunk", "Stage Hunk" }, r = { "Gitsigns reset_hunk", "Reset Hunk" }, }, }, { mode = { "n", "v" } }) wk.register({ ["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({ ["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 return "[c" end vim.schedule(function() gs.prev_hunk() end) return "" end, "Go to previous hunk", }, ["]c"] = { function() if vim.wo.diff then return "]c" end vim.schedule(function() gs.next_hunk() end) return "" end, "Go to next hunk", }, }, { expr = true }) -- Text object wk.register({ ["ih"] = { ":Gitsigns select_hunk", "Select inside Hunk" }, }, { mode = { "o", "x" } }) end, current_line_blame = true, current_line_blame_formatter = ", - | ", }) end, }, }