Builtin Library
README.md
docBrowser
Three-pane API doc browser: namespace tree (left), method list
(middle), describe pane (right). State carries the current selection
plus a search query; the widget itself is stateless — the owning app
prefetches lsp.namespaces() / lsp.methods(ns) / lsp.describe(path)
and threads them through. Drives the LSP UI's "Docs" tab.
Exports
docBrowser(state: State?, opts: Opts?) -> any— build the three-pane split widget. Returned directly by the module.
Types:
State = { namespaces?, selectedNamespace?, methods?, selectedMethod?, describe?, searchQuery?, searchResults?, kindFilter? }Opts = { id?: string, onSelect?: string, sizes?: { number } }
Usage
local docBrowser = require("@builtin::modules.zui.widget.lsp.docBrowser")
local widget = docBrowser(state, { onSelect = "lsp-docs" })
app:on("^lsp%-docs%-ns%-(.+)$", function(_v, _id, ns) state.selectedNamespace = ns end)
app:on("^lsp%-docs%-method%-(.+)$", function(_v, _id, path) state.selectedMethod = path:gsub("%.", "/") end)
app:on("lsp-docs-search", function(v) state.searchQuery = v end)
app:on("^lsp%-docs%-kind%-(.+)$", function(_v, _id, k) state.kindFilter = k end)
Notes
- Callback ids can't contain
/, so the widget substitutes.for/in method paths on emit. The receiving handler must undo it. - The fetch logic (calling
lsp.*) lives in the parent app, not in this widget — that keeps it cheap to test without an active LSP. - The split sizes default to 20% / 30% / 50%. Override via
opts.sizesfor inspector layouts that need different widths.