aboutsummaryrefslogtreecommitdiff
path: root/store/home/config/nvim/lua/setup/plugins/gitsigns.lua
diff options
context:
space:
mode:
Diffstat (limited to 'store/home/config/nvim/lua/setup/plugins/gitsigns.lua')
-rw-r--r--store/home/config/nvim/lua/setup/plugins/gitsigns.lua40
1 files changed, 40 insertions, 0 deletions
diff --git a/store/home/config/nvim/lua/setup/plugins/gitsigns.lua b/store/home/config/nvim/lua/setup/plugins/gitsigns.lua
new file mode 100644
index 0000000..957c661
--- /dev/null
+++ b/store/home/config/nvim/lua/setup/plugins/gitsigns.lua
@@ -0,0 +1,40 @@
+local function setup()
+ local gitsigns = require('gitsigns')
+
+ gitsigns.setup {
+ on_attach = function(bufnr)
+ local function map(mode, l, r, opts)
+ opts = opts or {}
+ opts.buffer = bufnr
+ vim.keymap.set(mode, l, r, opts)
+ end
+
+ -- Navigation
+ map('n', ']c', function()
+ if vim.wo.diff then
+ vim.cmd.normal({ ']c', bang = true })
+ else
+ gitsigns.nav_hunk('next')
+ end
+ end)
+
+ map('n', '[c', function()
+ if vim.wo.diff then
+ vim.cmd.normal({ '[c', bang = true })
+ else
+ gitsigns.nav_hunk('prev')
+ end
+ end)
+
+ -- Actions
+ map('n', '<leader>gc', gitsigns.preview_hunk)
+ map('n', '<leader>gt', gitsigns.toggle_deleted)
+ map('n', '<leader>gd', gitsigns.diffthis)
+ map('n', '<leader>gb', function() gitsigns.blame_line { full = true } end)
+ end
+ }
+end
+
+return {
+ setup = setup
+}