diff --git a/README.md b/README.md index 883f34f..d39d1a6 100644 --- a/README.md +++ b/README.md @@ -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, diff --git a/lua/outline/config.lua b/lua/outline/config.lua index d2c1c24..e681294 100644 --- a/lua/outline/config.lua +++ b/lua/outline/config.lua @@ -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, diff --git a/lua/outline/init.lua b/lua/outline/init.lua index 56acc54..f9fff1b 100644 --- a/lua/outline/init.lua +++ b/lua/outline/init.lua @@ -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' })