github nacro90/numb.nvim v1.3.0
v1.3.0: peek API and float peek

3 hours ago

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 with update(), accept(), cancel() and is_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.range highlights a range with NumbRange. The display
    options apply as usual, while disable_for_buftype and
    disable_for_filetype do 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 does disable(). Bad
    arguments, a non-integer or infinite line or window included, raise an
    error, as does a NumbUnpeek listener that keeps reopening a peek. Public
    from this release on, so a breaking change needs a major version; see
    :h numb.peek().
  • User NumbPeek and User NumbUnpeek autocommands. NumbPeek fires when a
    peek opens and on every update, NumbUnpeek once when it ends, whether
    accepted, cancelled, taken over, disabled or closed with its window.
    The event data carries win, line and range, plus accepted on
    NumbUnpeek. Command line peeks fire them too, so a statusline or another
    plugin can follow any preview without polling. For a confirmed command line
    NumbUnpeek fires 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 new float option 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_config function that has the last word on the nvim_open_win
    configuration. The border follows win_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() takes opts.style to pick the style for one peek, the
    NumbPeek event data carries the float as float_win, and
    :checkhealth numb reports 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.

Don't miss a new numb.nvim release

NewReleases is sending notifications on new releases.