Documentation
¶
Overview ¶
Decorator-arg/name LSP completions: dispatcher, context detection, error categories.
Import path + package-decl LSP completions.
Token-level helpers: duration/size unit completions + keyword list + extend-service context.
Type/decl LSP completions: project-wide decls + service/middleware/security/enum-value lookups.
Package lsp implements the CraftGo Language Server Protocol surface.
The server speaks LSP over stdio (a jsonrpc2.Stream wrapped around the caller's io.Reader / io.Writer) and forwards each open document through the existing parser + semantic analyser. Diagnostics published by the server are exactly the diagnostics the CLI would emit for the same source, so editor and CLI behaviour stay aligned by construction.
Currently supported:
- initialize / initialized / shutdown / exit lifecycle
- textDocument/didOpen / didChange / didSave / didClose
- textDocument/publishDiagnostics on every successful parse pass
- textDocument/hover (decorator, type ref, builtin docs)
- textDocument/completion (decorators, types, fields)
- textDocument/definition (cross-file decl resolution)
- textDocument/references (find all uses)
- textDocument/documentSymbol (outline)
- textDocument/formatting (canonical re-print via internal/format)
- textDocument/rename (declarations + every reference)
Any other request returns jsonrpc2.ErrMethodNotFound, which clients treat as "feature unsupported".
UTF-16 ↔ internal position conversion. The LSP protocol measures Position.Character in UTF-16 code units, whereas craftgo's lexer counts runes (Position.Column) and bytes (Position.Offset). A character in the Basic Multilingual Plane (<= U+FFFF) is one UTF-16 unit; a supplementary character (emoji, rare CJK, ...) is a surrogate PAIR — two units. Every crossing between an editor position and an internal position therefore has to go through these helpers, or columns drift on any line that carries multi-byte UTF-8 (byte ≠ rune) or supplementary runes (rune ≠ UTF-16).
Index ¶
Constants ¶
const Version = "1.3.5"
Version is the server's reported version, surfaced via Initialize so clients can include it in trace logs.
Variables ¶
This section is empty.