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

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

Cycle to the next signature overload.

Cycle to the previous signature overload.

Renders the signature help as display list draws for an overlay.

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

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.

render(sh, viewport, theme)

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

Renders the signature help as display list draws for an overlay.

Shows the active signature label with the active parameter highlighted. If there are multiple signatures, shows a "1/3" counter.