MingaEditor.HoverPopup (Minga v0.1.0)

Copy Markdown View Source

State and rendering for LSP hover tooltips.

Parses LSP hover markdown content into styled display list draws and renders them in a cursor-anchored floating window. Supports scrolling for long content (j/k when focused) and the LazyVim pattern of pressing K once to show, K again to focus into the hover for scrolling.

Lifecycle

  1. LSP hover response arrives with markdown content
  2. new/4 creates the popup state with parsed content
  3. The render pipeline renders it as an overlay via render/3
  4. Any keypress (except K/j/k when focused) dismisses the popup

Summary

Types

Action available from a focused hover popup.

t()

A hover popup state.

Functions

Returns the popup's outer rect {row, col, width, height} in screen cells.

Focus into the hover popup for scrolling.

Creates a new hover popup from LSP hover content.

Returns true when the popup exposes an Open action.

Returns a stable action name for native frontend metadata.

Scroll content down (later lines visible).

Scroll content up.

Sets the action to execute when the popup's Open action is accepted.

Types

open_action()

@type open_action() ::
  atom() | {:goto_location, String.t(), non_neg_integer(), non_neg_integer()}

Action available from a focused hover popup.

t()

@type t() :: %MingaEditor.HoverPopup{
  anchor_col: non_neg_integer(),
  anchor_row: non_neg_integer(),
  content_lines: [MingaAgent.Markdown.parsed_line()],
  focused: boolean(),
  open_action: open_action() | nil,
  scroll_offset: non_neg_integer()
}

A hover popup state.

Functions

box(popup, viewport, theme)

@spec box(t(), {pos_integer(), pos_integer()}, map()) ::
  MingaEditor.Layout.rect() | nil

Returns the popup's outer rect {row, col, width, height} in screen cells.

This is the same box render/3 paints into (border, anchor placement, and viewport clamping included), so the SurfaceRegistry can register the hover surface's rect from the BEAM's own geometry instead of inventing one. Returns nil when there is no content to place.

focus(popup)

@spec focus(t()) :: t()

Focus into the hover popup for scrolling.

new(markdown_text, cursor_row, cursor_col, opts \\ [])

@spec new(String.t(), non_neg_integer(), non_neg_integer(), keyword()) :: t()

Creates a new hover popup from LSP hover content.

Parses the markdown content and anchors the popup at the given cursor position.

open_action?(hover_popup)

@spec open_action?(t()) :: boolean()

Returns true when the popup exposes an Open action.

open_action_name(action)

@spec open_action_name(open_action() | nil) :: String.t()

Returns a stable action name for native frontend metadata.

scroll_down(popup)

@spec scroll_down(t()) :: t()

Scroll content down (later lines visible).

scroll_up(popup)

@spec scroll_up(t()) :: t()

Scroll content up.

with_open_action(popup, action)

@spec with_open_action(t(), open_action()) :: t()

Sets the action to execute when the popup's Open action is accepted.