feat: Center view on jump/goto
This commit is contained in:
@@ -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
|
-- boolean or integer for milliseconds duration to apply a temporary highlight
|
||||||
-- when jumping. false to disable.
|
-- when jumping. false to disable.
|
||||||
jump_highlight_duration = 300,
|
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
|
-- Vim options for the outline window
|
||||||
show_numbers = false,
|
show_numbers = false,
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ M.defaults = {
|
|||||||
hide_cursor = false,
|
hide_cursor = false,
|
||||||
winhl = 'OutlineDetails:Comment,OutlineLineno:LineNr',
|
winhl = 'OutlineDetails:Comment,OutlineLineno:LineNr',
|
||||||
jump_highlight_duration = 500,
|
jump_highlight_duration = 500,
|
||||||
|
center_on_jump = true,
|
||||||
},
|
},
|
||||||
preview_window = {
|
preview_window = {
|
||||||
auto_preview = false,
|
auto_preview = false,
|
||||||
|
|||||||
@@ -102,6 +102,9 @@ end
|
|||||||
function M.__goto_location(change_focus)
|
function M.__goto_location(change_focus)
|
||||||
local node = M._current_node()
|
local node = M._current_node()
|
||||||
vim.api.nvim_win_set_cursor(M.state.code_win, { node.line + 1, node.character })
|
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
|
if vim.fn.hlexists('OutlineJumpHighlight') == 0 then
|
||||||
vim.api.nvim_set_hl(0, 'OutlineJumpHighlight', { link = 'Visual' })
|
vim.api.nvim_set_hl(0, 'OutlineJumpHighlight', { link = 'Visual' })
|
||||||
|
|||||||
Reference in New Issue
Block a user