Documentation
¶
Overview ¶
Package lsp implements a minimal Language Server Protocol surface for mdsmith. It speaks JSON-RPC 2.0 over stdio and handles only the methods the VS Code extension needs: lifecycle, document sync, diagnostics, code actions, and watched-file notifications.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Diagnostic ¶
type Diagnostic struct {
Range Range `json:"range"`
Severity DiagnosticSeverity `json:"severity,omitempty"`
Code string `json:"code,omitempty"`
Source string `json:"source,omitempty"`
Message string `json:"message"`
Data *diagnosticData `json:"data,omitempty"`
}
Diagnostic is the LSP wire shape produced by the server.
type DiagnosticSeverity ¶
type DiagnosticSeverity int
DiagnosticSeverity values mirror the LSP enum.
type Options ¶
type Options struct {
// Rules is the registered rule set. Pass rule.All() in production.
Rules []rule.Rule
// Reader is the LSP input stream (typically stdin).
Reader io.Reader
// Writer is the LSP output stream (typically stdout).
Writer io.Writer
// Debounce is the per-document quiet period before re-linting.
// Zero defers to the default (200 ms). Negative disables debouncing.
Debounce time.Duration
// Logger receives server-side trace messages. May be nil.
Logger *vlog.Logger
}
Options configures a new Server.
type Position ¶
Position is a 0-based location within a text document. Line and Character are zero-indexed; Character counts UTF-16 code units, per the LSP spec.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server runs the LSP loop over a transport pair. One Server instance serves one client.
func (*Server) Run ¶
Run drives the server until the input stream returns io.EOF, the client sends `exit`, the supplied context is canceled, or a transport-level write fails (typically EPIPE when the client drops its stdout pipe).
On any exit path Run sets the shutdown flag and cancels every pending debounce timer so a callback armed milliseconds before teardown does not race the parent goroutine and write publishDiagnostics into a half-closed pipe.