Added
- Public peek API for other plugins.
require('numb').peek(winnr, line, opts?)
previews a line in any window, exactly as the command line does, and returns
a handle withupdate(),accept(),cancel()andis_active(), so a
picker or a symbol list can preview its selection and jump only on confirm.
accept()jumps immediately and pushes the jumplist entry, so<C-o>
returns;opts.rangehighlights a range withNumbRange. The display
options apply as usual, whiledisable_for_buftypeand
disable_for_filetypedo not, since the caller asked explicitly. One peek is
live at a time: a new one, or a command line that addresses a line, takes
over and the old handle goes inactive, and so doesdisable(). Bad
arguments, a non-integer or infinite line or window included, raise an
error, as does aNumbUnpeeklistener that keeps reopening a peek. Public
from this release on, so a breaking change needs a major version; see
:h numb.peek(). User NumbPeekandUser NumbUnpeekautocommands.NumbPeekfires when a
peek opens and on every update,NumbUnpeekonce when it ends, whether
accepted, cancelled, taken over, disabled or closed with its window.
The event data carrieswin,lineandrange, plusacceptedon
NumbUnpeek. Command line peeks fire them too, so a statusline or another
plugin can follow any preview without polling. For a confirmed command line
NumbUnpeekfires once the command has run and the cursor has landed.- Float peek.
peek_style = "float"shows the target in a float over the
window instead of scrolling the window to it, so the cursor, the scroll
position and the window options stay exactly where they were while you look
elsewhere; confirming still lands on the target, jumplist entry included.
peek_style = "auto"peeks in place when the target is already on screen and
in a float when it is not, deciding again on every keystroke. The default
stays"window". The newfloatoption sets the height (a fraction of the
window or a number of rows, at least 3), the edge it sits on ("bottom",
"top", or"auto", which avoids covering the cursor line) and an optional
win_configfunction that has the last word on thenvim_open_win
configuration. The border followswin_config, then'winborder'on
Neovim 0.11 and later, then a top edge titled with the line and the buffer's
length. The float never takes focus, and opens and moves without window
autocommands. A window too small for a float, border included, peeks in
place instead. Closing the float leaves no trace in the buffer: a new window
on it opens where the peeked window's cursor is, with that window's options.
numb.peek()takesopts.styleto pick the style for one peek, the
NumbPeekevent data carries the float asfloat_win, and
:checkhealth numbreports a float left open by a peek that already ended.
See:h numb-float.
Fixed
- A confirmed command that switches the window to another buffer, such as
:2b, no longer moves the cursor to that line of the new buffer afterwards.