fix: Set buffer on gitsigns.nvim mappings

This commit is contained in:
punkfairie 2024-12-05 18:11:09 -08:00
parent d8949f0cee
commit c310916b13
Signed by: punkfairie
GPG key ID: A509E8F77FB9D696

View file

@ -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(
'<LEADER>ghs',
'<CMD>Gitsigns stage_hunk<CR>',
icons.git.staged,
{ mode = { 'n', 'v' }, desc = 'stage hunk' }
),
mkKey(
'<LEADER>ghs',
'<CMD>Gitsigns stage_hunk<CR>',
icons.git.staged,
{ mode = { 'n', 'v' }, desc = 'stage hunk' }
),
mkKey(
'<LEADER>ghr',
'<CMD>Gitsigns reset_hunk<CR>',
icons.git.unstaged,
{ mode = { 'n', 'v' }, desc = 'reset hunk' }
),
mkKey(
'<LEADER>ghr',
'<CMD>Gitsigns reset_hunk<CR>',
icons.git.unstaged,
{ mode = { 'n', 'v' }, desc = 'reset hunk' }
),
mkKey(
'<LEADER>ghS',
gitsigns.stage_buffer,
icons.git.staged,
{ desc = 'stage buffer' }
),
mkKey(
'<LEADER>ghS',
gitsigns.stage_buffer,
icons.git.staged,
{ desc = 'stage buffer' }
),
mkKey(
'<LEADER>ghu',
gitsigns.undo_stage_hunk,
icons.undo,
{ desc = 'undo stage hunk' }
),
mkKey(
'<LEADER>ghu',
gitsigns.undo_stage_hunk,
icons.undo,
{ desc = 'undo stage hunk' }
),
mkKey(
'<LEADER>ghR',
gitsigns.reset_buffer,
icons.git.unstaged,
{ desc = 'reset buffer' }
),
mkKey(
'<LEADER>ghR',
gitsigns.reset_buffer,
icons.git.unstaged,
{ desc = 'reset buffer' }
),
mkKey(
'<LEADER>ghp',
gitsigns.preview_hunk_inline,
'',
{ desc = 'preview hunk inline' }
),
mkKey(
'<LEADER>ghp',
gitsigns.preview_hunk_inline,
'',
{ desc = 'preview hunk inline' }
),
mkKey('<LEADER>ghb', function()
gitsigns.blame_line({ full = true })
end, { cat = 'filetype', name = 'git' }, {
desc = 'blame line',
}),
mkKey('<LEADER>ghb', function()
gitsigns.blame_line({ full = true })
end, { cat = 'filetype', name = 'git' }, {
desc = 'blame line',
}),
mkKey(
'<LEADER>ghB',
gitsigns.blame,
{ cat = 'filetype', name = 'git' },
{ desc = 'blame buffer' }
),
mkKey(
'<LEADER>ghB',
gitsigns.blame,
{ cat = 'filetype', name = 'git' },
{ desc = 'blame buffer' }
),
mkKey(
'<LEADER>ghd',
gitsigns.diffthis,
icons.git.diff,
{ desc = 'diff file' }
),
mkKey(
'<LEADER>ghd',
gitsigns.diffthis,
icons.git.diff,
{ desc = 'diff file' }
),
mkKey('<LEADER>ghD', function()
gitsigns.diffthis('~')
end, icons.git.diff, { desc = 'diff file from ~' }),
mkKey('<LEADER>ghD', function()
gitsigns.diffthis('~')
end, icons.git.diff, { desc = 'diff file from ~' }),
mkKey(
'ih',
'<CMD><C-u>Gitsigns select_hunk<CR>',
'󰿚',
{ mode = { 'o', 'x' }, desc = 'select hunk' }
),
mkKey(
'ih',
'<CMD><C-u>Gitsigns select_hunk<CR>',
'󰿚',
{ mode = { 'o', 'x' }, desc = 'select hunk' }
),
},
})
end,
})