Skip to content

Commit

Permalink
outline: add new option close_after_jump close #993
Browse files Browse the repository at this point in the history
  • Loading branch information
glepnir committed Apr 3, 2023
1 parent 2640c4b commit 32d8848
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions lua/lspsaga/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ local default_config = {
auto_close = true,
custom_sort = nil,
preview_width = 0.4,
close_after_jump = false,
keys = {
expand_or_jump = 'o',
quit = 'q',
Expand Down
13 changes: 11 additions & 2 deletions lua/lspsaga/outline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ function ot:apply_map()
end
local width = #api.nvim_get_current_line()
libs.jump_beacon({ range.start.line, range.start.character }, width)
if outline_conf.close_after_jump then
self:close_and_clean()
end
end

keymap.set('n', maps.expand_or_jump, function()
Expand Down Expand Up @@ -545,11 +548,17 @@ function ot:register_events()
self.registerd = true
end

function ot:close_and_clean()
if self.winid and api.nvim_win_is_valid(self.winid) then
api.nvim_win_close(self.winid, true)
clean_ctx()
end
end

function ot:outline(buf, non_close)
non_close = non_close or false
if self.winid and api.nvim_win_is_valid(self.winid) and not non_close then
api.nvim_win_close(self.winid, true)
clean_ctx()
self:close_and_clean()
return
end

Expand Down

0 comments on commit 32d8848

Please sign in to comment.