Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

feat: instant_preview #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 |
Expand Down
10 changes: 10 additions & 0 deletions doc/symbols-outline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -162,6 +163,15 @@ auto_preview

Type: boolean

-----------------------------------------------------------------------------
instant_preview

Instantly activates |auto_preview| without any delay.

Default: false ~

Type: boolean

-----------------------------------------------------------------------------
show_numbers

Expand Down
8 changes: 6 additions & 2 deletions lua/symbols-outline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ end

local function setup_buffer_autocmd()
if config.options.auto_preview then
vim.cmd "au CursorHold <buffer> lua require'symbols-outline.preview'.show()"
local event = "CursorHold"
if config.options.instant_preview then
event = event .. ",CursorMoved"
end
vim.cmd("au " .. event .. " <buffer> lua require'symbols-outline.preview'.show()")
else
vim.cmd "au CursorMoved <buffer> lua require'symbols-outline.preview'.close()"
vim.cmd("au CursorMoved <buffer> lua require'symbols-outline.preview'.close()")
end
end

Expand Down