Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commitdd348ac6c3

README.md

diagnosticDetail

Detail pane for a single LSP diagnostic. Renders a severity / code header, an optional file:line:col row (with optional copy-path button), the message and suggestion, and an optional source snippet around the offending line. Stateless builder — pass a diagnostic in, get a widget tree out.

Exports

  • diagnosticDetail(d: Diagnostic?, opts: DiagnosticDetailOpts?) -> WidgetNode — module returns the builder function directly. Also reachable via Z.lsp.diagnosticDetail.

Options:

  • id: string? — id forwarded to the outer panel.
  • source: string? — full file contents. Enables the snippet panel.
  • snippetContext: number? — lines of context around the focused line. Default 2.
  • onCopyPath: string? — callback prefix for the copy-path button. Emits <prefix>-copy when clicked. Omit to hide the button.

d shape (from lsp.check*): { severity, code?, path?, line?, col?, message?, suggestion? }.

Usage

local Z = require("@builtin::modules.zui")

Z.lsp.diagnosticDetail(diags[selected], {
    source     = source,
    onCopyPath = "lsp:path",
})

Notes

  • When d is nil, renders a placeholder panel ("Select a diagnostic to see details.") rather than crashing.
  • The widget never copies to the clipboard itself — it only emits a callback. The parent app decides what "copy" means in its host (some have ui.copy(text), others log to stdout).
  • The snippet renders only when both opts.source and d.line are provided.
  • Severity colours come from Theme.default (danger, warn, info, text_dim); unknown severities fall back to theme.text.