summaryrefslogtreecommitdiff
path: root/lua/plugins/git.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/plugins/git.lua')
-rw-r--r--lua/plugins/git.lua31
1 files changed, 31 insertions, 0 deletions
diff --git a/lua/plugins/git.lua b/lua/plugins/git.lua
new file mode 100644
index 0000000..a40a3dc
--- /dev/null
+++ b/lua/plugins/git.lua
@@ -0,0 +1,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,
+ },
+}