Documentation
¶
Overview ¶
Package lsp implements a tiny Language Server Protocol server for MX Script. It speaks JSON-RPC 2.0 over stdio and exposes:
- textDocument/didOpen, didChange, didClose, didSave — track buffers
- textDocument/publishDiagnostics — parse errors as squiggles
- textDocument/formatting — invoke mx fmt
- textDocument/hover — minimal "did you mean ___" for builtins
Usage from VS Code (or any LSP client):
{
"command": "mx",
"args": ["lsp"],
"filetypes": ["mxscript"]
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllDocNames ¶ added in v0.84.0
func AllDocNames() []string
AllDocNames returns every name in the curated docs table, sorted. Used by `mx help` listing mode and `mx help <topic>`'s "did you mean" hint when the topic isn't found exactly.
func LookupDoc ¶ added in v0.84.0
LookupDoc returns the signature and summary for a known builtin or namespace key (e.g. "json_stringify", "ai.complete"). Returns "", "", false when the name isn't in the curated docs table — callers can then decide whether to suggest something close or to print a generic "no docs" message.
func Run ¶
Run reads JSON-RPC messages from r, replies on w, and only returns when the client closes stdin (or sends `shutdown` + `exit`).
func UserSymbolDoc ¶ added in v1.33.0
findDefinition scans the source for a top-level binding of `name` — any of `let name = ...`, `fn name(...) { ... }`, or `middleware name`. Returns line / column of the *name* itself (not the keyword) so the editor's go-to-def lands on the binding's identifier. UserSymbolDoc is the public version of userSymbolDoc — same behaviour, callable from other packages (notably `mx docs <topic>` in main.go).
Types ¶
type UserSymbol ¶ added in v1.5.0
UserSymbol is one declaration extracted from an open document. Surfaces in completion results so editors offer the user's own names alongside builtins.