aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/home/.config
diff options
context:
space:
mode:
authorLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2024-06-27 14:26:39 +0100
committerLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2024-06-27 14:26:39 +0100
commitff10782d4347979edc2231410c04d09ecd8fe9f7 (patch)
tree55634be8c5f2c16e60fee8d0d8ecafba2edcebe8 /home/.config
parent45cd07ed6542fc8cf231c920d7e670d38fe2a997 (diff)
downloaddotfiles-ff10782d4347979edc2231410c04d09ecd8fe9f7.tar.gz
dotfiles-ff10782d4347979edc2231410c04d09ecd8fe9f7.tar.bz2
dotfiles-ff10782d4347979edc2231410c04d09ecd8fe9f7.zip
[nvim] Update gitsigns config
Diffstat (limited to 'home/.config')
-rw-r--r--home/.config/nvim/lua/custom/plugins/git.lua31
1 files changed, 18 insertions, 13 deletions
diff --git a/home/.config/nvim/lua/custom/plugins/git.lua b/home/.config/nvim/lua/custom/plugins/git.lua
index e161029..077cfd4 100644
--- a/home/.config/nvim/lua/custom/plugins/git.lua
+++ b/home/.config/nvim/lua/custom/plugins/git.lua
@@ -74,28 +74,33 @@ return {
changedelete = { show_count = true },
},
numhl = true,
- _extmark_signs = true,
_threaded_diff = true,
- _signs_staged_enable = true,
+ _refresh_staged_on_update = true,
on_attach = function(bufnr)
- local gs = package.loaded.gitsigns
+ local gs = require('gitsigns')
-- Navigation
map.n(']c', function()
- if vim.wo.diff then return ']c' end
- vim.schedule(function() gs.next_hunk() end)
- return '<Ignore>'
- end, { expr = true }, bufnr)
+ if vim.wo.diff then
+ vim.cmd.normal({ ']c', bang = true })
+ else
+ gs.nav_hunk('next')
+ end
+ end, nil, bufnr)
map.n('[c', function()
- if vim.wo.diff then return '[c' end
- vim.schedule(function() gs.prev_hunk() end)
- return '<Ignore>'
- end, { expr = true }, bufnr)
+ if vim.wo.diff then
+ vim.cmd.normal({ '[c', bang = true })
+ else
+ gs.nav_hunk('prev')
+ end
+ end, nil, bufnr)
-- Actions
- map.nvcmd('<leader>hs', "Gitsigns stage_hunk", nil, bufnr)
- map.nvcmd('<leader>hr', "Gitsigns reset_hunk", nil, bufnr)
+ map.n('<leader>hs', gs.stage_hunk, nil, bufnr)
+ map.n('<leader>hr', gs.reset_hunk, nil, bufnr)
+ map.v('<leader>hs', function() gs.stage_hunk { vim.fn.line('.'), vim.fn.line('v') } end, nil, bufnr)
+ map.v('<leader>hr', function() gs.reset_hunk { vim.fn.line('.'), vim.fn.line('v') } end, nil, bufnr)
map.n('<leader>hS', gs.stage_buffer, nil, bufnr)
map.n('<leader>hu', gs.undo_stage_hunk, nil, bufnr)
map.n('<leader>hR', gs.reset_buffer, nil, bufnr)