local function on_attach(bufnr) local gs = require "gitsigns" local function map(mode, lhs, rhs, desc) vim.keymap.set(mode, lhs, rhs, { buffer = bufnr, desc = desc }) end map("n", "]g", function() if vim.wo.diff then return "]g" end vim.schedule(function() gs.next_hunk() end) return "" end, "Next hunk") map("n", "[g", function() if vim.wo.diff then return "[g" end vim.schedule(function() gs.prev_hunk() end) return "" end, "Prev hunk") map("n", "hs", gs.stage_hunk, "Stage hunk") map("n", "hr", gs.reset_hunk, "Reset hunk") map("n", "hp", gs.preview_hunk, "Preview hunk") map("n", "hb", gs.blame_line, "Blame line") map("n", "hd", gs.diffthis, "Diff this") map("n", "hD", function() gs.diffthis "~" end, "Diff against ~") map("n", "htb", gs.toggle_current_line_blame, "Toggle line blame") map("n", "htd", gs.toggle_deleted, "Toggle deleted") end require("gitsigns").setup { on_attach = on_attach, signs = { add = { text = "┃" }, change = { text = "┃" }, delete = { text = "_" }, topdelete = { text = "‾" }, changedelete = { text = "~" }, untracked = { text = "┆" }, }, signs_staged = { add = { text = "┃" }, change = { text = "┃" }, delete = { text = "_" }, topdelete = { text = "‾" }, changedelete = { text = "~" }, untracked = { text = "┆" }, }, signs_staged_enable = true, signcolumn = true, numhl = false, linehl = false, word_diff = false, watch_gitdir = { follow_files = true, }, auto_attach = true, attach_to_untracked = false, current_line_blame = true, current_line_blame_opts = { virt_text = true, virt_text_pos = "eol", delay = 500, ignore_whitespace = false, virt_text_priority = 100, use_focus = true, }, current_line_blame_formatter = ", - ", blame_formatter = nil, sign_priority = 6, update_debounce = 100, status_formatter = nil, max_file_length = 40000, preview_config = { style = "minimal", relative = "cursor", row = 0, col = 1, }, }