From 78b4f20b393574f71c15b825a3385bd200315ff8 Mon Sep 17 00:00:00 2001 From: Omar Zeghouani Date: Sat, 21 Aug 2021 10:17:12 +0100 Subject: [PATCH] Simplify preview toggle --- lua/symbols-outline.lua | 2 +- lua/symbols-outline/preview.lua | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lua/symbols-outline.lua b/lua/symbols-outline.lua index 8b19609..cd8bb58 100644 --- a/lua/symbols-outline.lua +++ b/lua/symbols-outline.lua @@ -32,7 +32,7 @@ end local function setup_buffer_autocmd() if config.options.auto_preview then vim.cmd( - "au CursorHold lua require'symbols-outline.preview'.show(true)") + "au CursorHold lua require'symbols-outline.preview'.show()") else vim.cmd( "au CursorMoved lua require'symbols-outline.preview'.close()") diff --git a/lua/symbols-outline/preview.lua b/lua/symbols-outline/preview.lua index 084fb86..33f9ab9 100644 --- a/lua/symbols-outline/preview.lua +++ b/lua/symbols-outline/preview.lua @@ -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