diff --git a/lua/symbols-outline/config.lua b/lua/symbols-outline/config.lua index 6c5417d..98b4595 100644 --- a/lua/symbols-outline/config.lua +++ b/lua/symbols-outline/config.lua @@ -51,6 +51,7 @@ M.defaults = { close = { '', 'q' }, goto_location = '', peek_location = 'o', + goto_and_close = '', restore_location = "", hover_symbol = '', toggle_preview = 'K', diff --git a/lua/symbols-outline/init.lua b/lua/symbols-outline/init.lua index ae87260..b14ad86 100644 --- a/lua/symbols-outline/init.lua +++ b/lua/symbols-outline/init.lua @@ -115,6 +115,11 @@ function M._goto_location(change_focus) end end +function M._goto_and_close() + M.__goto_location(true) + M.close_outline() +end + function M._move_and_goto(direction) local move = direction == 'down' and 1 or -1 local cur = vim.api.nvim_win_get_cursor(0) @@ -298,9 +303,9 @@ local function setup_keymaps(bufnr) M._goto_location(false) end) -- Navigate to corresponding outline location for current code location - map(cfg.o.keymaps.restore_location, function() - M._map_follow_cursor() - end) + map(cfg.o.keymaps.restore_location, M._map_follow_cursor) + -- Navigate to corresponding outline location for current code location + map(cfg.o.keymaps.goto_and_close, M._goto_and_close) -- Move down/up in outline and peek that location in code map(cfg.o.keymaps.down_and_goto, function() M._move_and_goto('down')