Improve hunk navigation with auto-centering behavior
Added a delay to center the cursor after moving to the next or previous hunk, enhancing the navigation experience.
This commit is contained in:
parent
b9ddeee54e
commit
ee01977e76
|
|
@ -25,16 +25,27 @@ return {
|
|||
vim.keymap.set(mode, l, r, opts)
|
||||
end
|
||||
|
||||
-- Hunk navigation
|
||||
-- Hunk navigation (includes zt to center after movement)
|
||||
-- Note: gs.next_hunk/prev_hunk are async, so zt needs a delay to center after cursor moves
|
||||
map('n', ']h', function()
|
||||
if vim.wo.diff then return ']c' end
|
||||
vim.schedule(function() gs.next_hunk() end)
|
||||
if vim.wo.diff then return ']czt' end
|
||||
vim.schedule(function()
|
||||
gs.next_hunk()
|
||||
end)
|
||||
vim.defer_fn(function()
|
||||
vim.cmd('normal! zt')
|
||||
end, 50)
|
||||
return '<Ignore>'
|
||||
end, { expr = true, desc = 'Gitsigns: Next hunk' })
|
||||
|
||||
map('n', '[h', function()
|
||||
if vim.wo.diff then return '[c' end
|
||||
vim.schedule(function() gs.prev_hunk() end)
|
||||
if vim.wo.diff then return '[czt' end
|
||||
vim.schedule(function()
|
||||
gs.prev_hunk()
|
||||
end)
|
||||
vim.defer_fn(function()
|
||||
vim.cmd('normal! zt')
|
||||
end, 50)
|
||||
return '<Ignore>'
|
||||
end, { expr = true, desc = 'Gitsigns: Previous hunk' })
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue