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/3 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

t()

A hover popup state.

Functions

Focus into the hover popup for scrolling.

Creates a new hover popup from LSP hover content.

Renders the hover popup as a list of display list draws.

Scroll content down (later lines visible).

Scroll content up.

Types

t()

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

A hover popup state.

Functions

focus(popup)

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

Focus into the hover popup for scrolling.

new(markdown_text, cursor_row, cursor_col)

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

Creates a new hover popup from LSP hover content.

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

render(popup, viewport, theme)

@spec render(t(), {pos_integer(), pos_integer()}, map()) :: [
  MingaEditor.DisplayList.draw()
]

Renders the hover popup as a list of display list draws.

Returns an empty list if the content is empty. The draws are absolute screen coordinates ready for an Overlay.

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.