lsp

package
v1.74.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2026 License: MIT Imports: 12 Imported by: 0

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

func LookupDoc(name string) (sig, summary string, ok bool)

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

func Run(r io.Reader, w io.Writer) error

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

func UserSymbolDoc(text, name string) (sig, doc string, ok bool)

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

type UserSymbol struct {
	Name   string
	Kind   int
	Detail string
}

UserSymbol is one declaration extracted from an open document. Surfaces in completion results so editors offer the user's own names alongside builtins.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL