summaryrefslogtreecommitdiff
path: root/lua/plugins/git.lua
blob: a40a3dc4c78adba691c9538ffbf1d0c5a62dec16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
return {
  'lewis6991/gitsigns.nvim',
  opts = {
    signs      = {
      add = { text = '+' },
      change = { text = '~' },
      delete = { text = '_' },
      topdelete = { text = '‾' },
      changedelete = { text = '~' },
    },
    signcolumn = true,  -- Toggle with `:Gitsigns toggle_signs`
    numhl      = true,  -- Toggle with `:Gitsigns toggle_numhl`
    linehl     = false, -- Toggle with `:Gitsigns toggle_linehl`
    word_diff  = false, -- Toggle with `:Gitsigns toggle_word_diff`
    on_attach  = function(bufnr)
      local gs = require('gitsigns')

      -- TODO: use this function for most of the keymaps across plugins?
      local function map(mode, l, r, opts)
        opts = opts or {}
        opts.buffer = bufnr
        vim.keymap.set(mode, l, r, opts)
      end

      map('n', '<leader>gp', gs.prev_hunk, { desc = '[g]it: [p]revious hunk' })
      map('n', '<leader>gn', gs.next_hunk, { desc = '[g]it: [n]ext hunk' })
      map('n', '<leader>gv', gs.preview_hunk, { desc = '[g]it: [v]iew hunk' })
      map('n', '<leader>gb', gs.toggle_current_line_blame, { desc = '[g]it: [b]lame toggle' })
    end,
  },
}