Simplify preview toggle
This commit is contained in:
@@ -32,7 +32,7 @@ end
|
||||
local function setup_buffer_autocmd()
|
||||
if config.options.auto_preview then
|
||||
vim.cmd(
|
||||
"au CursorHold <buffer> lua require'symbols-outline.preview'.show(true)")
|
||||
"au CursorHold <buffer> lua require'symbols-outline.preview'.show()")
|
||||
else
|
||||
vim.cmd(
|
||||
"au CursorMoved <buffer> lua require'symbols-outline.preview'.close()")
|
||||
|
||||
@@ -186,16 +186,12 @@ local function show_hover()
|
||||
end
|
||||
end
|
||||
|
||||
function M.show(force)
|
||||
function M.show()
|
||||
if not is_current_win_outline() or
|
||||
#vim.api.nvim_list_wins() < 2 then
|
||||
return
|
||||
end
|
||||
|
||||
if force ~= true and state.preview_win ~= nil then
|
||||
return 1
|
||||
end
|
||||
|
||||
show_preview()
|
||||
show_hover()
|
||||
end
|
||||
@@ -214,9 +210,10 @@ function M.close()
|
||||
end
|
||||
|
||||
function M.toggle()
|
||||
local code = M.show()
|
||||
if code == 1 then
|
||||
if state.preview_win ~= nil then
|
||||
M.close()
|
||||
else
|
||||
M.show()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user