--[plugins/git.lua] return { { -- Adds git related signs to the gutter, as well as utilities for managing changes 'lewis6991/gitsigns.nvim', opts = { -- Basic options for the signs in the gutter signs = { add = { text = '+' }, change = { text = '~' }, delete = { text = '_' }, topdelete = { text = '‾' }, changedelete = { text = '~' }, }, -- All keymaps are now defined in the on_attach function on_attach = function(bufnr) local gs = package.loaded.gitsigns local function map(mode, l, r, desc) vim.keymap.set(mode, l, r, { buffer = bufnr, desc = desc }) end -- Navigation map('n', ']c', gs.next_hunk, 'Next Hunk') map('n', '[c', gs.prev_hunk, 'Prev Hunk') -- Actions map({ 'n', 'v' }, 'hs', gs.stage_hunk, 'Stage Hunk') map({ 'n', 'v' }, 'hr', gs.reset_hunk, 'Reset Hunk') map('n', 'hS', gs.stage_buffer, 'Stage Buffer') map('n', 'hu', gs.undo_stage_hunk, 'Undo Stage Hunk') map('n', 'hR', gs.reset_buffer, 'Reset Buffer') map('n', 'hp', gs.preview_hunk, 'Preview Hunk') map('n', 'hb', function() gs.blame_line { full = true } end, 'Blame Line') map('n', 'tb', gs.toggle_current_line_blame, 'Toggle Blame Line') map('n', 'hd', gs.diffthis, 'Diff This') map('n', 'hD', function() gs.diffthis '~' end, 'Diff This ~') map('n', 'td', gs.toggle_deleted, 'Toggle Deleted') -- Text object map({ 'o', 'x' }, 'ih', ':Gitsigns select_hunk', 'Select Hunk') end, }, }, { -- Git wrapper 'tpope/vim-fugitive', cmd = { "Git", "G" }, -- lazy load on :Git }, require('gitsigns').setup { current_line_blame = true, -- shows git blame at end of line current_line_blame_opts = { virt_text = true, virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align' delay = 500, ignore_whitespace = false, }, current_line_blame_formatter = ', - ', } }