2024-12-04 21:35:35 -08:00
|
|
|
return {
|
|
|
|
'gitsigns.nvim',
|
|
|
|
event = { 'BufReadPost', 'BufWritePost', 'BufNewFile' },
|
|
|
|
before = function()
|
|
|
|
require('lz.n').trigger_load('which-key.nvim')
|
|
|
|
end,
|
|
|
|
after = function()
|
|
|
|
require('gitsigns').setup({
|
|
|
|
signs = {
|
|
|
|
add = { text = '▎' },
|
|
|
|
change = { text = '▎' },
|
|
|
|
delete = { text = '' },
|
|
|
|
topdelete = { text = '' },
|
|
|
|
changedelete = { text = '▎' },
|
|
|
|
untracked = { text = '▎' },
|
|
|
|
},
|
|
|
|
signs_staged = {
|
|
|
|
add = { text = '▎' },
|
|
|
|
change = { text = '▎' },
|
|
|
|
delete = { text = '' },
|
|
|
|
topdelete = { text = '' },
|
|
|
|
changedelete = { text = '▎' },
|
|
|
|
},
|
|
|
|
on_attach = function(buf)
|
|
|
|
local gitsigns = package.loaded.gitsigns
|
|
|
|
|
|
|
|
local icons = require('icons')
|
2024-12-04 21:41:30 -08:00
|
|
|
local mkKey = MarleyVim.wkSpec(require('colors').git)
|
2024-12-04 21:35:35 -08:00
|
|
|
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' }),
|
2024-12-04 21:41:30 -08:00
|
|
|
|
2024-12-04 21:35:35 -08:00
|
|
|
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' }),
|
2024-12-04 21:41:30 -08:00
|
|
|
|
2024-12-04 21:35:35 -08:00
|
|
|
mkKey(']H', function()
|
|
|
|
gitsigns.nav_hunk('last')
|
|
|
|
end, icons.last, { desc = 'last hunk' }),
|
2024-12-04 21:41:30 -08:00
|
|
|
|
2024-12-04 21:35:35 -08:00
|
|
|
mkKey('[H', function()
|
|
|
|
gitsigns.nav_hunk('first')
|
|
|
|
end, icons.first, { desc = 'first hunk' }),
|
2024-12-04 21:41:30 -08:00
|
|
|
|
2024-12-04 21:35:35 -08:00
|
|
|
mkKey(
|
|
|
|
'<LEADER>ghs',
|
|
|
|
'<CMD>Gitsigns stage_hunk<CR>',
|
|
|
|
icons.git.staged,
|
|
|
|
{ mode = { 'n', 'v' }, desc = 'stage hunk' }
|
|
|
|
),
|
2024-12-04 21:41:30 -08:00
|
|
|
|
2024-12-04 21:35:35 -08:00
|
|
|
mkKey(
|
|
|
|
'<LEADER>ghr',
|
|
|
|
'<CMD>Gitsigns reset_hunk<CR>',
|
|
|
|
icons.git.unstaged,
|
|
|
|
{ mode = { 'n', 'v' }, desc = 'reset hunk' }
|
|
|
|
),
|
2024-12-04 21:41:30 -08:00
|
|
|
|
2024-12-04 21:35:35 -08:00
|
|
|
mkKey(
|
|
|
|
'<LEADER>ghS',
|
|
|
|
gitsigns.stage_buffer,
|
|
|
|
icons.git.staged,
|
|
|
|
{ desc = 'stage buffer' }
|
|
|
|
),
|
2024-12-04 21:41:30 -08:00
|
|
|
|
2024-12-04 21:35:35 -08:00
|
|
|
mkKey(
|
|
|
|
'<LEADER>ghu',
|
|
|
|
gitsigns.undo_stage_hunk,
|
|
|
|
icons.undo,
|
|
|
|
{ desc = 'undo stage hunk' }
|
|
|
|
),
|
2024-12-04 21:41:30 -08:00
|
|
|
|
2024-12-04 21:35:35 -08:00
|
|
|
mkKey(
|
|
|
|
'<LEADER>ghR',
|
|
|
|
gitsigns.reset_buffer,
|
|
|
|
icons.git.unstaged,
|
|
|
|
{ desc = 'reset buffer' }
|
|
|
|
),
|
2024-12-04 21:41:30 -08:00
|
|
|
|
2024-12-04 21:35:35 -08:00
|
|
|
mkKey(
|
|
|
|
'<LEADER>ghp',
|
|
|
|
gitsigns.preview_hunk_inline,
|
|
|
|
'',
|
|
|
|
{ desc = 'preview hunk inline' }
|
|
|
|
),
|
2024-12-04 21:41:30 -08:00
|
|
|
|
2024-12-04 21:35:35 -08:00
|
|
|
mkKey('<LEADER>ghb', function()
|
|
|
|
gitsigns.blame_line({ full = true })
|
|
|
|
end, { cat = 'filetype', name = 'git' }, {
|
|
|
|
desc = 'blame line',
|
|
|
|
}),
|
2024-12-04 21:41:30 -08:00
|
|
|
|
2024-12-04 21:35:35 -08:00
|
|
|
mkKey(
|
|
|
|
'<LEADER>ghB',
|
|
|
|
gitsigns.blame,
|
|
|
|
{ cat = 'filetype', name = 'git' },
|
|
|
|
{ desc = 'blame buffer' }
|
|
|
|
),
|
2024-12-04 21:41:30 -08:00
|
|
|
|
2024-12-04 21:35:35 -08:00
|
|
|
mkKey(
|
|
|
|
'<LEADER>ghd',
|
|
|
|
gitsigns.diffthis,
|
|
|
|
icons.git.diff,
|
|
|
|
{ desc = 'diff file' }
|
|
|
|
),
|
2024-12-04 21:41:30 -08:00
|
|
|
|
2024-12-04 21:35:35 -08:00
|
|
|
mkKey('<LEADER>ghD', function()
|
|
|
|
gitsigns.diffthis('~')
|
|
|
|
end, icons.git.diff, { desc = 'diff file from ~' }),
|
2024-12-04 21:41:30 -08:00
|
|
|
|
2024-12-04 21:35:35 -08:00
|
|
|
mkKey(
|
|
|
|
'ih',
|
|
|
|
'<CMD><C-u>Gitsigns select_hunk<CR>',
|
|
|
|
'',
|
|
|
|
{ mode = { 'o', 'x' }, desc = 'select hunk' }
|
|
|
|
),
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
}
|