gitsigns-conf.lua 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. require('gitsigns').setup({
  2. signs = {
  3. add = { text = '+' },
  4. change = { text = '~' },
  5. delete = { text = '_' },
  6. topdelete = { text = '‾' },
  7. changedelete = { text = '~' },
  8. untracked = { text = '┆' },
  9. },
  10. -- Enable highlighting for the sign column and line numbers
  11. signcolumn = true,
  12. numhl = true,
  13. linehl = false,
  14. word_diff = false,
  15. on_attach = function(bufnr)
  16. local gs = package.loaded.gitsigns
  17. local function map(mode, l, r, opts)
  18. opts = opts or {}
  19. opts.buffer = bufnr
  20. vim.keymap.set(mode, l, r, opts)
  21. end
  22. -- Navigation
  23. map('n', ']h', function()
  24. if vim.wo.diff then return ']h' end
  25. vim.schedule(function() gs.next_hunk() end)
  26. return '<Ignore>'
  27. end, {expr=true})
  28. map('n', '[h', function()
  29. if vim.wo.diff then return '[h' end
  30. vim.schedule(function() gs.prev_hunk() end)
  31. return '<Ignore>'
  32. end, {expr=true})
  33. -- Actions
  34. map('n', '<leader>hs', gs.stage_hunk)
  35. map('n', '<leader>hr', gs.reset_hunk)
  36. map('n', '<leader>hp', gs.preview_hunk)
  37. map('n', '<leader>hb', function() gs.blame_line{full=true} end)
  38. end
  39. })