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