diff --git a/README.md b/README.md index c2b3a85..eed62e5 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ vim.g.symbols_outline = { highlight_hovered_item = true, show_guides = true, auto_preview = true, + instant_preview = false, position = 'right', relative_width = true, width = 25, @@ -90,6 +91,7 @@ vim.g.symbols_outline = { | width | Width of window (as a % or columns based on `relative_width`) | int | 25 | | auto_close | Whether to automatically close the window after selection | boolean | false | | auto_preview | Show a preview of the code on hover | boolean | true | +| instant_preview | Instantly activates `auto_preview` without any delay | boolean | false | | show_numbers | Shows numbers with the outline | boolean | false | | show_relative_numbers | Shows relative numbers with the outline | boolean | false | | show_symbol_details | Shows extra details with the symbols (lsp dependent) | boolean | true | diff --git a/doc/symbols-outline.txt b/doc/symbols-outline.txt index 0748963..1d280ad 100644 --- a/doc/symbols-outline.txt +++ b/doc/symbols-outline.txt @@ -47,6 +47,7 @@ or skip this section entirely if you want to roll with the defaults. highlight_hovered_item = true, show_guides = true, auto_preview = true, + instant_preview = false, position = 'right', width = 25, auto_close = false, @@ -162,6 +163,15 @@ auto_preview Type: boolean +----------------------------------------------------------------------------- +instant_preview + + Instantly activates |auto_preview| without any delay. + + Default: false ~ + + Type: boolean + ----------------------------------------------------------------------------- show_numbers diff --git a/lua/symbols-outline.lua b/lua/symbols-outline.lua index bf253d1..160c4a2 100644 --- a/lua/symbols-outline.lua +++ b/lua/symbols-outline.lua @@ -18,9 +18,13 @@ end local function setup_buffer_autocmd() if config.options.auto_preview then - vim.cmd "au CursorHold lua require'symbols-outline.preview'.show()" + local event = "CursorHold" + if config.options.instant_preview then + event = event .. ",CursorMoved" + end + vim.cmd("au " .. event .. " lua require'symbols-outline.preview'.show()") else - vim.cmd "au CursorMoved lua require'symbols-outline.preview'.close()" + vim.cmd("au CursorMoved lua require'symbols-outline.preview'.close()") end end