lspclient

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package lspclient implements Wirecmd's narrow, server-neutral LSP client.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStart                    = errors.New("LSP process could not be started")
	ErrCapabilityUnavailable    = errors.New("LSP server does not advertise the requested capability")
	ErrEncodingUnsupported      = errors.New("LSP server selected an unsupported position encoding")
	ErrResultUnsupported        = errors.New("LSP server returned an unsupported location result")
	ErrServerRequestUnsupported = errors.New("LSP server made an unsupported client request")
)

Functions

This section is empty.

Types

type Capabilities

type Capabilities struct {
	Declaration      bool   `json:"declaration"`
	Definition       bool   `json:"definition"`
	TypeDefinition   bool   `json:"type_definition"`
	Implementation   bool   `json:"implementation"`
	References       bool   `json:"references"`
	Hover            bool   `json:"hover"`
	DocumentSymbols  bool   `json:"document_symbols"`
	WorkspaceSymbols bool   `json:"workspace_symbols"`
	PositionEncoding string `json:"position_encoding"`
	TextDocumentSync string `json:"text_document_sync"`
	OpenClose        bool   `json:"open_close"`
}

Capabilities is the SDK-independent subset of the initialize result that Wirecmd uses for navigation and document synchronization.

type Command

type Command struct {
	Path   string
	Args   []string
	Env    []string
	Dir    string
	Stderr io.Writer
}

Command describes a configured LSP child. Wirecmd never infers its contents.

type DefinitionTarget

type DefinitionTarget struct {
	// contains filtered or unexported fields
}

DefinitionTarget is a validated snapshot of a definition request. Preparing it before process acquisition prevents invalid local input from starting an LSP server.

func PrepareDocument

func PrepareDocument(path, languageID string) (*DefinitionTarget, error)

PrepareDocument validates and snapshots a disk document without requiring a position. It is used by document-level LSP requests such as document symbols.

func PrepareTarget

func PrepareTarget(path string, line, column uint32, languageID string) (*DefinitionTarget, error)

PrepareTarget validates and snapshots a one-based disk position without starting or consulting an LSP process.

type Hover

type Hover struct {
	Range   *Range       `json:"range,omitempty"`
	Content []HoverBlock `json:"content"`
}

Hover is the SDK-independent representation of one non-null hover result.

type HoverBlock

type HoverBlock struct {
	Kind     string `json:"kind"`
	Text     string `json:"text"`
	Language string `json:"language,omitempty"`
}

HoverBlock is one normalized piece of hover content. Code blocks retain the language supplied by the server; markdown is intentionally kept literal so the caller can choose how to render it.

type Location

type Location struct {
	Path  string `json:"path"`
	Range Range  `json:"range"`
}

type Point

type Point struct {
	Line   uint32 `json:"line"`
	Column uint32 `json:"column"`
}

Point and Range are Wirecmd's normalized one-based output coordinates.

type PositionError

type PositionError struct{ Message string }

PositionError reports a caller coordinate that cannot address the document.

func (*PositionError) Error

func (e *PositionError) Error() string

type Range

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

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session is one initialized LSP process and its disk-document mirror.

func Start

func Start(ctx context.Context, command Command, workspace, version string) (*Session, error)

Start launches and initializes exactly the configured LSP command.

func (*Session) Broken

func (s *Session) Broken() error

Broken reports whether the protocol connection terminated unexpectedly.

func (*Session) Capabilities

func (s *Session) Capabilities() Capabilities

Capabilities returns the negotiated SDK-independent capability summary.

func (*Session) Close

func (s *Session) Close() error

Close performs the LSP shutdown sequence and reaps the child.

func (*Session) Declaration

func (s *Session) Declaration(ctx context.Context, target *DefinitionTarget) ([]Location, error)

Declaration resolves a declaration for a previously validated disk snapshot.

func (*Session) Definition

func (s *Session) Definition(ctx context.Context, target *DefinitionTarget) ([]Location, error)

Definition resolves a previously validated disk snapshot.

func (*Session) DocumentSymbols

func (s *Session) DocumentSymbols(ctx context.Context, target *DefinitionTarget) ([]Symbol, error)

DocumentSymbols returns normalized symbols for a previously validated disk snapshot. It preserves hierarchical and flat protocol response forms.

func (*Session) Hover

func (s *Session) Hover(ctx context.Context, target *DefinitionTarget) ([]Hover, error)

Hover returns the normalized hover result for a previously validated disk snapshot. A null protocol hover is represented by an empty, non-nil slice.

func (*Session) Implementation

func (s *Session) Implementation(ctx context.Context, target *DefinitionTarget) ([]Location, error)

Implementation resolves an implementation for a previously validated disk snapshot.

func (*Session) References

func (s *Session) References(ctx context.Context, target *DefinitionTarget, includeDeclaration bool) ([]Location, error)

References resolves references for a previously validated disk snapshot.

func (*Session) Status

func (s *Session) Status() Status

Status returns the negotiated server identity and capabilities. It does not contact the server.

func (*Session) TypeDefinition

func (s *Session) TypeDefinition(ctx context.Context, target *DefinitionTarget) ([]Location, error)

TypeDefinition resolves a type definition for a previously validated disk snapshot.

func (*Session) WorkspaceSymbols

func (s *Session) WorkspaceSymbols(ctx context.Context, query string) ([]Symbol, error)

WorkspaceSymbols searches the server's current workspace index. It does not open or synchronize a document and passes query through unchanged.

type Status

type Status struct {
	ServerName    string       `json:"server_name,omitempty"`
	ServerVersion string       `json:"server_version,omitempty"`
	Capabilities  Capabilities `json:"capabilities"`
}

Status is the observed, SDK-independent identity and capability state of a connected server. Empty identity fields mean the server omitted them.

type Symbol

type Symbol struct {
	Name           string   `json:"name"`
	Kind           uint32   `json:"kind"`
	KindName       string   `json:"kind_name"`
	Path           string   `json:"path"`
	Range          Range    `json:"range"`
	SelectionRange *Range   `json:"selection_range,omitempty"`
	Detail         *string  `json:"detail,omitempty"`
	ContainerName  *string  `json:"container_name,omitempty"`
	Deprecated     bool     `json:"deprecated,omitempty"`
	Children       []Symbol `json:"children,omitempty"`
}

Symbol is a normalized LSP symbol. Children preserve hierarchical document symbol responses; flat SymbolInformation responses remain flat.

Jump to

Keyboard shortcuts

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