MingaEditor.SignatureHelp (Minga v0.1.0)

Copy Markdown View Source

State and rendering for LSP signature help tooltips.

When the user types ( or , inside a function call, a floating window appears above the cursor showing the function signature with the active parameter highlighted. Supports multiple overloaded signatures with cycling via C-j/C-k.

Lifecycle

  1. User types ( or , in insert mode
  2. CompletionHandling.maybe_handle/4 detects the trigger character
  3. textDocument/signatureHelp request sent to LSP
  4. Response parsed into SignatureHelp state
  5. Rendered as an overlay in the Chrome stage
  6. Dismissed on ), Escape, or cursor movement outside the call

Summary

Types

A parsed parameter.

A parsed signature.

t()

Signature help state.

Functions

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

Creates a new signature help state from an LSP SignatureHelp response.

Cycle to the next signature overload.

Cycle to the previous signature overload.

Types

parameter()

@type parameter() :: %{label: String.t(), documentation: String.t()}

A parsed parameter.

signature()

@type signature() :: %{
  label: String.t(),
  documentation: String.t(),
  parameters: [parameter()]
}

A parsed signature.

t()

@type t() :: %MingaEditor.SignatureHelp{
  active_parameter: non_neg_integer(),
  active_signature: non_neg_integer(),
  anchor_col: non_neg_integer(),
  anchor_row: non_neg_integer(),
  signatures: [signature()]
}

Signature help state.

Functions

box(sh, viewport, theme)

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

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

Same box render/3 paints into (border, anchor placement, viewport clamping included), so the SurfaceRegistry registers the signature-help surface's rect from the BEAM's own geometry. Returns nil when there is no signature to place.

from_response(response, cursor_row, cursor_col)

@spec from_response(map(), non_neg_integer(), non_neg_integer()) :: t() | nil

Creates a new signature help state from an LSP SignatureHelp response.

next_signature(sh)

@spec next_signature(t()) :: t()

Cycle to the next signature overload.

prev_signature(sh)

@spec prev_signature(t()) :: t()

Cycle to the previous signature overload.