feat: Center view on jump/goto

This commit is contained in:
hedy
2023-11-17 12:34:14 +08:00
parent 62dea5bff9
commit a1aa652fb2
3 changed files with 7 additions and 0 deletions

View File

@@ -181,6 +181,9 @@ Pass a table to the setup call with your configuration options.
-- boolean or integer for milliseconds duration to apply a temporary highlight
-- when jumping. false to disable.
jump_highlight_duration = 300,
-- Whether to center the cursor line vertically in the screen when
-- jumping/focusing. Runs zz.
center_on_jump = true,
-- Vim options for the outline window
show_numbers = false,

View File

@@ -35,6 +35,7 @@ M.defaults = {
hide_cursor = false,
winhl = 'OutlineDetails:Comment,OutlineLineno:LineNr',
jump_highlight_duration = 500,
center_on_jump = true,
},
preview_window = {
auto_preview = false,

View File

@@ -102,6 +102,9 @@ end
function M.__goto_location(change_focus)
local node = M._current_node()
vim.api.nvim_win_set_cursor(M.state.code_win, { node.line + 1, node.character })
if cfg.o.outline_window.center_on_jump then
vim.fn.win_execute(M.state.code_win, "normal! zz")
end
if vim.fn.hlexists('OutlineJumpHighlight') == 0 then
vim.api.nvim_set_hl(0, 'OutlineJumpHighlight', { link = 'Visual' })