Documentation
¶
Overview ¶
Package lsp provides session-owned language servers and normalized code queries.
Index ¶
- type Adapter
- type Config
- type Dependencies
- type DiagnosticCheck
- type DiagnosticQuery
- type Error
- type InspectQuery
- type Inspection
- type Item
- type LaunchSpec
- type Manager
- func (m *Manager) Changed(path string)
- func (m *Manager) Close(ctx context.Context) error
- func (m *Manager) Config() Config
- func (m *Manager) Covers(path string) bool
- func (m *Manager) Diagnostics(ctx context.Context, q DiagnosticQuery) (Page, error)
- func (m *Manager) Handles(path string) bool
- func (m *Manager) Inspect(ctx context.Context, q InspectQuery) (Inspection, error)
- func (m *Manager) Navigate(ctx context.Context, q NavigateQuery) (Page, error)
- func (m *Manager) Outline(ctx context.Context, q OutlineQuery) (Page, error)
- func (m *Manager) References(ctx context.Context, q ReferenceQuery) (Page, error)
- func (m *Manager) Status(ctx context.Context, path string) (Status, error)
- func (m *Manager) Symbols(ctx context.Context, q SymbolQuery) (Page, error)
- type Metadata
- type NavigateQuery
- type OutlineQuery
- type Page
- type PageQuery
- type Position
- type Range
- type ReferenceQuery
- type ResolveRequest
- type ServerConfig
- type ServerStatus
- type Source
- type Status
- type SymbolQuery
- type Target
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter interface {
Resolve(context.Context, ResolveRequest) (LaunchSpec, error)
}
Adapter resolves setup only. Semantic operations are implemented by the client. Resolve may read files, but must not start processes or modify the workspace. Implementations must support concurrent calls and honor cancellation.
type Config ¶
type Config struct {
Dir string `json:"-"`
Servers []ServerConfig `json:"servers"`
StartTimeoutMS int `json:"start_timeout_ms,omitempty"`
RequestTimeoutMS int `json:"request_timeout_ms,omitempty"`
DiagnosticTimeoutMS int `json:"diagnostic_timeout_ms,omitempty"`
MaxServers int `json:"max_servers,omitempty"`
MaxFileBytes int `json:"max_file_bytes,omitempty"`
MaxMessageBytes int `json:"max_message_bytes,omitempty"`
MaxWorkspaceFiles int `json:"max_workspace_files,omitempty"`
MaxWorkspaceBytes int `json:"max_workspace_bytes,omitempty"`
MaxOpenDocuments int `json:"max_open_documents,omitempty"`
CacheBytes int `json:"cache_bytes,omitempty"`
}
Config is host policy. Dir is supplied by the harness, not by model arguments.
func BashConfig ¶
func BashConfig() Config
BashConfig handles shell scripts and common Bash startup files. ShellCheck is optional, but must be installed for its lint diagnostics. No scripts are run.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig enables the built-in server presets. Binaries must be installed separately; constructing the configuration neither discovers nor launches them. JavaScript and TypeScript share one server configuration and process per root.
func PythonConfig ¶
func PythonConfig() Config
PythonConfig uses Pyright. Interpreter and import-path settings can be supplied through Settings (python.pythonPath, python.analysis) or pyright project files.
func RustConfig ¶
func RustConfig() Config
RustConfig supports Cargo projects and rust-project.json workspaces. Set explicit Roots to share one instance across members of a Cargo workspace.
func TypeScriptConfig ¶
func TypeScriptConfig() Config
TypeScriptConfig handles both JavaScript and TypeScript, including JSX/TSX and CommonJS/ES module suffixes. Do not configure two overlapping instances for JavaScript and TypeScript files in the same project.
type Dependencies ¶
type DiagnosticCheck ¶
type DiagnosticQuery ¶
type DiagnosticQuery struct {
Paths []string
PageQuery
// Wait, when positive, replaces the configured diagnostic timeout for this
// query: how long to wait for the servers' analysis of the paths.
Wait time.Duration `json:"-"`
// Resync sends every requested open file to its server as a new version,
// even when its text is unchanged, so the server publishes diagnostics
// for it again. After a change elsewhere, a server that republishes only
// what changed would otherwise leave the file's diagnostics unconfirmed.
Resync bool `json:"-"`
}
type InspectQuery ¶
type Inspection ¶
type Item ¶
type Item struct {
Ref string `json:"ref,omitempty"`
Name string `json:"name,omitempty"`
Kind string `json:"kind,omitempty"`
Container string `json:"container,omitempty"`
Path string `json:"path"`
URI string `json:"uri,omitempty"`
Selection *Range `json:"selection,omitempty"`
Declaration *Range `json:"declaration,omitempty"`
SHA256 string `json:"sha256,omitempty"`
Excerpt string `json:"excerpt,omitempty"`
Depth int `json:"depth,omitempty"`
Severity string `json:"severity,omitempty"`
Code string `json:"code,omitempty"`
Message string `json:"message,omitempty"`
Source string `json:"source,omitempty"`
Freshness string `json:"freshness,omitempty"`
}
type LaunchSpec ¶
type LaunchSpec struct {
Root string
Dir string
Command []string
Env []string
InitializationOptions json.RawMessage
Settings json.RawMessage
}
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager serializes query/synchronization transactions. Protocol callbacks use separate client locks, so a server can ask for configuration during a query. The manager is shared by agents, but never by independently edited worktrees.
func (*Manager) Changed ¶
Changed is a nonblocking hint; file hooks must call it after releasing their mutation lock. Empty path means a shell/external writer may have changed anything.
func (*Manager) Covers ¶
Covers reports whether a configured server handles path, an absolute path inside the manager's directory.
func (*Manager) Diagnostics ¶
func (*Manager) Handles ¶
Handles reports whether a configured server handles path's language, wherever the file is.
func (*Manager) Inspect ¶
func (m *Manager) Inspect(ctx context.Context, q InspectQuery) (Inspection, error)
func (*Manager) References ¶
type NavigateQuery ¶
type NavigateQuery struct {
}
type OutlineQuery ¶
type Position ¶
Positions exposed by Strap are one-based Unicode code point offsets, not tabs' display width or the server's negotiated code units. Range ends are exclusive.
type ReferenceQuery ¶
type ResolveRequest ¶
type ResolveRequest struct {
SessionDir, Path string
Server ServerConfig
}
type ServerConfig ¶
type ServerConfig struct {
ID string `json:"id"`
Adapter string `json:"adapter,omitempty"`
Command []string `json:"command"`
Languages map[string]string `json:"languages"` // File suffix -> LSP language ID.
Roots []string `json:"roots,omitempty"` // Relative to Config.Dir.
RootMarkers []string `json:"root_markers,omitempty"`
FallbackToSession bool `json:"fallback_to_session,omitempty"` // Use Dir when no root marker is found.
Env map[string]string `json:"env,omitempty"`
InitializationOptions json.RawMessage `json:"initialization_options,omitempty"`
Settings json.RawMessage `json:"settings,omitempty"`
}
type ServerStatus ¶
type Status ¶
type Status struct {
Servers []ServerStatus `json:"servers"`
}