lsp

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 37 Imported by: 0

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

type Position struct {
	Line      int `json:"line"`
	Character int `json:"character"`
}

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 Range

type Range struct {
	Start Position `json:"start"`
	End   Position `json:"end"`
}

Range covers a span between two Positions; End is exclusive.

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 New

func New(opts Options) *Server

New constructs a Server. The Server does not run until Run() is called.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

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.

Jump to

Keyboard shortcuts

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