From ff10782d4347979edc2231410c04d09ecd8fe9f7 Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Thu, 27 Jun 2024 14:26:39 +0100 Subject: [nvim] Update gitsigns config --- home/.config/nvim/lua/custom/plugins/git.lua | 31 ++++++++++++++++------------ 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'home/.config/nvim/lua/custom/plugins/git.lua') 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 '' - 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 '' - 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('hs', "Gitsigns stage_hunk", nil, bufnr) - map.nvcmd('hr', "Gitsigns reset_hunk", nil, bufnr) + map.n('hs', gs.stage_hunk, nil, bufnr) + map.n('hr', gs.reset_hunk, nil, bufnr) + map.v('hs', function() gs.stage_hunk { vim.fn.line('.'), vim.fn.line('v') } end, nil, bufnr) + map.v('hr', function() gs.reset_hunk { vim.fn.line('.'), vim.fn.line('v') } end, nil, bufnr) map.n('hS', gs.stage_buffer, nil, bufnr) map.n('hu', gs.undo_stage_hunk, nil, bufnr) map.n('hR', gs.reset_buffer, nil, bufnr) -- cgit v1.2.3-70-g09d2