Documentation
¶
Overview ¶
Package lsp is a minimal Language Server Protocol client: it spawns a language server per language on demand, syncs queried documents from disk, and adapts a few read-only capabilities (definition, references, hover, diagnostics) to the tool.Tool interface. Servers are not bundled — they resolve on PATH and a clear install hint is returned when one is missing.
Index ¶
- func DefaultSpecs() map[string]ServerSpec
- func Tools(m *Manager) []tool.Tool
- type Diagnostic
- type Location
- type Manager
- func (m *Manager) Close()
- func (m *Manager) Definition(ctx context.Context, file string, line int, symbol string) (string, error)
- func (m *Manager) Diagnostics(ctx context.Context, file string) (string, error)
- func (m *Manager) Hover(ctx context.Context, file string, line int, symbol string) (string, error)
- func (m *Manager) Implementation(ctx context.Context, file string, line int, symbol string) (string, error)
- func (m *Manager) References(ctx context.Context, file string, line int, symbol string) (string, error)
- func (m *Manager) WorkspaceSymbol(ctx context.Context, query string) (string, error)
- type Position
- type Range
- type ServerSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultSpecs ¶
func DefaultSpecs() map[string]ServerSpec
DefaultSpecs maps a language key to its conventional server. Commands are tried on PATH; nothing here ships with fairpeer. Extensions drive file routing, so a user can override any entry or add a new language entirely from config.
Types ¶
type Diagnostic ¶
type Diagnostic struct {
Range Range `json:"range"`
Severity int `json:"severity"`
Message string `json:"message"`
Source string `json:"source"`
}
Diagnostic is one published problem for a document.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns the lazily-spawned language servers for a session. Servers start on first query for their language and are reused; the session-scoped context (cancelled by Close) bounds their lifetime, not a single turn.
func NewManager ¶
func NewManager(wsRoot string, specs map[string]ServerSpec) *Manager
func (*Manager) Definition ¶
func (*Manager) Diagnostics ¶
func (*Manager) Implementation ¶
func (m *Manager) Implementation(ctx context.Context, file string, line int, symbol string) (string, error)
Implementation finds the concrete implementations of an interface method (or interface type). Uses the same file+line+symbol pattern as Definition.
func (*Manager) References ¶
func (*Manager) WorkspaceSymbol ¶
WorkspaceSymbol searches for symbols across the whole workspace by name (partial match). Unlike definition/references it doesn't need a file+line — just a query string. Returns matching symbols with their location and kind.
type Position ¶
Position is a zero-based LSP position. Character is counted in the encoding the server negotiated at initialize (utf-16 by default, utf-8 when both sides agree).
type ServerSpec ¶
type ServerSpec struct {
Command string
Args []string
Env map[string]string
LanguageID string
Extensions []string
InstallHint string
}
ServerSpec declares how to launch one language server. Command resolves on PATH (the binary is never bundled); InstallHint is surfaced when it is missing. Extensions are the file suffixes (".go", ".rs") this server handles — they drive file → language routing, so a config-only entry can add a new language without any code change.