lsp

package
v0.0.0-...-c5fe4b7 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package lsp implements the sqletch language server (docs/design/10-lsp.md): JSON-RPC 2.0 over stdio, a subset of the Language Server Protocol (diagnostics + go-to-definition), backed by an injected Workspace checker so the protocol layer never touches dialect drivers or the pipeline directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve(in io.Reader, out io.Writer, ws Workspace, initErr string, logW io.Writer) int

Serve runs the language server until the client's exit notification or a transport failure, returning the process exit code (0 after an orderly shutdown, 1 otherwise). ws == nil serves the degraded mode of docs/design/10-lsp.md §6: initErr is reported once via window/showMessage and every request answers empty.

Types

type ContentChange

type ContentChange struct {
	Text string `json:"text"`
}

type DefinitionParams

type DefinitionParams struct {
	TextDocument TextDocumentIdentifier `json:"textDocument"`
	Position     Position               `json:"position"`
}

type Diagnostic

type Diagnostic struct {
	Range    Range  `json:"range"`
	Severity int    `json:"severity,omitempty"`
	Code     string `json:"code,omitempty"`
	Source   string `json:"source,omitempty"`
	Message  string `json:"message"`
}

type DidChangeParams

type DidChangeParams struct {
	TextDocument TextDocumentIdentifier `json:"textDocument"`
	// Full sync: the last element carries the complete new content.
	ContentChanges []ContentChange `json:"contentChanges"`
}

type DidCloseParams

type DidCloseParams struct {
	TextDocument TextDocumentIdentifier `json:"textDocument"`
}

type DidOpenParams

type DidOpenParams struct {
	TextDocument TextDocumentItem `json:"textDocument"`
}

type DidSaveParams

type DidSaveParams struct {
	TextDocument TextDocumentIdentifier `json:"textDocument"`
}

type InitializeResult

type InitializeResult struct {
	Capabilities ServerCapabilities `json:"capabilities"`
	ServerInfo   ServerInfo         `json:"serverInfo"`
}

type Location

type Location struct {
	URI   string `json:"uri"`
	Range Range  `json:"range"`
}

type Message

type Message struct {
	JSONRPC string           `json:"jsonrpc"`
	ID      *json.RawMessage `json:"id,omitempty"`
	Method  string           `json:"method,omitempty"`
	Params  json.RawMessage  `json:"params,omitempty"`
	Result  json.RawMessage  `json:"result,omitempty"`
	Error   *ResponseError   `json:"error,omitempty"`
}

Message is a JSON-RPC 2.0 request, notification, or response; unset members are omitted on the wire.

type Position

type Position struct {
	Line      uint32 `json:"line"`
	Character uint32 `json:"character"` // UTF-16 code units (negotiated encoding)
}

type PublishDiagnosticsParams

type PublishDiagnosticsParams struct {
	URI         string       `json:"uri"`
	Diagnostics []Diagnostic `json:"diagnostics"`
}

type Range

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

type ResponseError

type ResponseError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type ServerCapabilities

type ServerCapabilities struct {
	PositionEncoding   string `json:"positionEncoding"`
	TextDocumentSync   int    `json:"textDocumentSync"`
	DefinitionProvider bool   `json:"definitionProvider"`
}

type ServerInfo

type ServerInfo struct {
	Name    string `json:"name"`
	Version string `json:"version,omitempty"`
}

type ShowMessageParams

type ShowMessageParams struct {
	Type    int    `json:"type"`
	Message string `json:"message"`
}

type TextDocumentIdentifier

type TextDocumentIdentifier struct {
	URI string `json:"uri"`
}

type TextDocumentItem

type TextDocumentItem struct {
	URI        string `json:"uri"`
	LanguageID string `json:"languageId"`
	Version    int    `json:"version"`
	Text       string `json:"text"`
}

type Workspace

type Workspace interface {
	Check(overlay map[string][]byte) (WorkspaceResult, error)
}

Workspace is the analysis seam: internal/cli injects its OfflineChecker so the protocol layer stays free of dialect drivers. Check runs one consistent offline snapshot with overlay (open buffer) contents replacing disk.

type WorkspaceResult

type WorkspaceResult struct {
	Diags   map[string][]diagnostics.Diagnostic
	Files   map[string]*template.QueryFile
	Sources map[string][]byte
}

WorkspaceResult mirrors cli.WorkspaceCheck, keyed by absolute path.

Jump to

Keyboard shortcuts

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