local gitsigns = require('gitsigns') local line = vim.fn.line -- TODO(lewis6991): doesn't work properly vim.keymap.set('n', 'M', 'Gitsigns debug_messages') vim.keymap.set('n', 'm', 'Gitsigns dump_cache') local function on_attach(bufnr) local function map(mode, l, r, opts) opts = opts or {} opts.buffer = bufnr vim.keymap.set(mode, l, r, opts) end map('n', ']c', function() if vim.wo.diff then return ']c' end vim.schedule(gitsigns.next_hunk) return '' end, {expr=true}) map('n', '[c', function() if vim.wo.diff then return '[c' end vim.schedule(gitsigns.prev_hunk) return '' end, {expr=true}) map('n', 'hs', gitsigns.stage_hunk) map('n', 'hr', gitsigns.reset_hunk) map('v', 'hs', function() gitsigns.stage_hunk({line("."), line("v")}) end) map('v', 'hh', function() gitsigns.reset_hunk({line("."), line("v")}) end) map('n', 'hS', gitsigns.stage_buffer) map('n', 'hu', gitsigns.undo_stage_hunk) map('n', 'hR', gitsigns.reset_buffer) map('n', 'hp', gitsigns.preview_hunk) map('n', 'hb', function() gitsigns.blame_line{full=true} end) map('n', 'hd', gitsigns.diffthis) map('n', 'hD', function() gitsigns.diffthis('~') end) -- Toggles map('n', 'tb', gitsigns.toggle_current_line_blame) map('n', 'td', gitsigns.toggle_deleted) map('n', 'tw', gitsigns.toggle_word_diff) map('n', 'hQ', function() gitsigns.setqflist('all') end) map('n', 'hq', gitsigns.setqflist) map({'o', 'x'}, 'ih', ':Gitsigns select_hunk') end gitsigns.setup{ debug_mode = true, max_file_length = 1000000000, signs = { add = {show_count = false}, change = {show_count = false}, delete = {show_count = true }, topdelete = {show_count = true }, changedelete = {show_count = true }, }, on_attach = on_attach, preview_config = { border = 'rounded', }, current_line_blame = true, current_line_blame_formatter_opts = { relative_time = true }, current_line_blame_opts = { delay = 50 }, count_chars = { '⒈', '⒉', '⒊', '⒋', '⒌', '⒍', '⒎', '⒏', '⒐', '⒑', '⒒', '⒓', '⒔', '⒕', '⒖', '⒗', '⒘', '⒙', '⒚', '⒛', }, update_debounce = 50, _extmark_signs = true, _threaded_diff = true, word_diff = true, }