From c310916b139e1d15e997b0110b0008da360ad200 Mon Sep 17 00:00:00 2001 From: punkfairie Date: Thu, 5 Dec 2024 18:11:09 -0800 Subject: [PATCH] fix: Set buffer on gitsigns.nvim mappings --- nvim/lua/plugins/editor/gitsigns-nvim.lua | 167 +++++++++++----------- 1 file changed, 85 insertions(+), 82 deletions(-) diff --git a/nvim/lua/plugins/editor/gitsigns-nvim.lua b/nvim/lua/plugins/editor/gitsigns-nvim.lua index b972bf1..ef13329 100644 --- a/nvim/lua/plugins/editor/gitsigns-nvim.lua +++ b/nvim/lua/plugins/editor/gitsigns-nvim.lua @@ -27,102 +27,105 @@ return { local icons = require('icons') local mkKey = MarleyVim.wkSpec(require('colors').git) require('which-key').add({ - mkKey(']h', function() - if vim.wo.diff then - vim.cmd.normal({ ']c', bang = true }) - else - gitsigns.nav_hunk('next') - end - end, icons.next, { desc = 'next hunk' }), + { + buffer = buf, + mkKey(']h', function() + if vim.wo.diff then + vim.cmd.normal({ ']c', bang = true }) + else + gitsigns.nav_hunk('next') + end + end, icons.next, { desc = 'next hunk' }), - mkKey('[h', function() - if vim.wo.diff then - vim.cmd.normal({ '[c', bang = true }) - else - gitsigns.nav_hunk('prev') - end - end, icons.prev, { desc = 'previous hunk' }), + mkKey('[h', function() + if vim.wo.diff then + vim.cmd.normal({ '[c', bang = true }) + else + gitsigns.nav_hunk('prev') + end + end, icons.prev, { desc = 'previous hunk' }), - mkKey(']H', function() - gitsigns.nav_hunk('last') - end, icons.last, { desc = 'last hunk' }), + mkKey(']H', function() + gitsigns.nav_hunk('last') + end, icons.last, { desc = 'last hunk' }), - mkKey('[H', function() - gitsigns.nav_hunk('first') - end, icons.first, { desc = 'first hunk' }), + mkKey('[H', function() + gitsigns.nav_hunk('first') + end, icons.first, { desc = 'first hunk' }), - mkKey( - 'ghs', - 'Gitsigns stage_hunk', - icons.git.staged, - { mode = { 'n', 'v' }, desc = 'stage hunk' } - ), + mkKey( + 'ghs', + 'Gitsigns stage_hunk', + icons.git.staged, + { mode = { 'n', 'v' }, desc = 'stage hunk' } + ), - mkKey( - 'ghr', - 'Gitsigns reset_hunk', - icons.git.unstaged, - { mode = { 'n', 'v' }, desc = 'reset hunk' } - ), + mkKey( + 'ghr', + 'Gitsigns reset_hunk', + icons.git.unstaged, + { mode = { 'n', 'v' }, desc = 'reset hunk' } + ), - mkKey( - 'ghS', - gitsigns.stage_buffer, - icons.git.staged, - { desc = 'stage buffer' } - ), + mkKey( + 'ghS', + gitsigns.stage_buffer, + icons.git.staged, + { desc = 'stage buffer' } + ), - mkKey( - 'ghu', - gitsigns.undo_stage_hunk, - icons.undo, - { desc = 'undo stage hunk' } - ), + mkKey( + 'ghu', + gitsigns.undo_stage_hunk, + icons.undo, + { desc = 'undo stage hunk' } + ), - mkKey( - 'ghR', - gitsigns.reset_buffer, - icons.git.unstaged, - { desc = 'reset buffer' } - ), + mkKey( + 'ghR', + gitsigns.reset_buffer, + icons.git.unstaged, + { desc = 'reset buffer' } + ), - mkKey( - 'ghp', - gitsigns.preview_hunk_inline, - '', - { desc = 'preview hunk inline' } - ), + mkKey( + 'ghp', + gitsigns.preview_hunk_inline, + '', + { desc = 'preview hunk inline' } + ), - mkKey('ghb', function() - gitsigns.blame_line({ full = true }) - end, { cat = 'filetype', name = 'git' }, { - desc = 'blame line', - }), + mkKey('ghb', function() + gitsigns.blame_line({ full = true }) + end, { cat = 'filetype', name = 'git' }, { + desc = 'blame line', + }), - mkKey( - 'ghB', - gitsigns.blame, - { cat = 'filetype', name = 'git' }, - { desc = 'blame buffer' } - ), + mkKey( + 'ghB', + gitsigns.blame, + { cat = 'filetype', name = 'git' }, + { desc = 'blame buffer' } + ), - mkKey( - 'ghd', - gitsigns.diffthis, - icons.git.diff, - { desc = 'diff file' } - ), + mkKey( + 'ghd', + gitsigns.diffthis, + icons.git.diff, + { desc = 'diff file' } + ), - mkKey('ghD', function() - gitsigns.diffthis('~') - end, icons.git.diff, { desc = 'diff file from ~' }), + mkKey('ghD', function() + gitsigns.diffthis('~') + end, icons.git.diff, { desc = 'diff file from ~' }), - mkKey( - 'ih', - 'Gitsigns select_hunk', - '󰿚', - { mode = { 'o', 'x' }, desc = 'select hunk' } - ), + mkKey( + 'ih', + 'Gitsigns select_hunk', + '󰿚', + { mode = { 'o', 'x' }, desc = 'select hunk' } + ), + }, }) end, })