return { { "lewis6991/gitsigns.nvim", config = function() local gitsigns = require("gitsigns") gitsigns.setup({ signs_staged_enable = true, signcolumn = true, numhl = true, linehl = false, word_diff = false, watch_gitdir = { follow_files = true }, auto_attach = true, attach_to_untracked = false, current_line_blame = false, current_line_blame_opts = { virt_text = true, virt_text_pos = "eol", delay = 1000, ignore_whitespace = false, virt_text_priority = 100, use_focus = true, }, current_line_blame_formatter = ", - ", sign_priority = 6, update_debounce = 100, status_formatter = nil, max_file_length = 40000, -- Disable if file is longer than this (in lines) preview_config = { border = "none", style = "minimal", relative = "cursor", row = 0, col = 1, }, on_attach = function(bufnr) local function map(mode, l, r, opts) opts = opts or {} opts.buffer = bufnr vim.keymap.set(mode, l, r, opts) end -- Navigation map("n", "]c", function() if vim.wo.diff then vim.cmd.normal({ "]c", bang = true }) else gitsigns.nav_hunk("next", { target = "all" }) end end, { desc = "Goto next change" }) map("n", "[c", function() if vim.wo.diff then vim.cmd.normal({ "[c", bang = true }) else gitsigns.nav_hunk("prev", { target = "all" }) end end, { desc = "Goto previous change" }) -- Actions map("n", "ga", gitsigns.stage_hunk, { desc = "stages the current block of changes to git" }) map("n", "gu", gitsigns.undo_stage_hunk, { desc = "undo the last (git) staged change" }) map("n", "gp", gitsigns.preview_hunk, { desc = "show the git diff for the current change block" }) map("n", "gb", gitsigns.blame, { desc = "git blame for the whole file" }) map("n", "gl", gitsigns.blame_line, { desc = "git blame for the current line" }) map("n", "gh", gitsigns.toggle_linehl, { desc = "toggle git diff highlight by line" }) map("n", "gw", gitsigns.toggle_word_diff, { desc = "toggle git diff highlight by word" }) -- Text object map({ "o", "x" }, "ih", ":Gitsigns select_hunk") end, }) end, }, }