Documentation
¶
Overview ¶
Package lsp implements a minimal Language Server Protocol client over stdio. LSP uses JSON-RPC 2.0 with Content-Length framed messages.
Index ¶
- Constants
- func DefaultConfig() config.LSPConfig
- func URIToPath(uri string) string
- type Client
- func (c *Client) Close() error
- func (c *Client) Connected() bool
- func (c *Client) Definition(ctx context.Context, file string, line, col int) ([]Location, error)
- func (c *Client) DocumentSymbols(ctx context.Context, file string) ([]SymbolInformation, error)
- func (c *Client) Hover(ctx context.Context, file string, line, col int) (Hover, error)
- func (c *Client) Language() string
- func (c *Client) LastError() error
- func (c *Client) References(ctx context.Context, file string, line, col int) ([]Location, error)
- func (c *Client) Start(ctx context.Context, rootDir string) error
- func (c *Client) WorkspaceSymbols(ctx context.Context, query string) ([]SymbolInformation, error)
- type Hover
- type Location
- type Manager
- type Position
- type Range
- type SymbolInformation
Constants ¶
const InitializeTimeout = 5 * time.Second
InitializeTimeout bounds readiness independently of the session lifetime.
Variables ¶
This section is empty.
Functions ¶
func DefaultConfig ¶
DefaultConfig returns a config that probes PATH for common language servers. Only servers whose binary exists are returned.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is one language-server stdio connection.
func (*Client) Close ¶
Close attempts the LSP shutdown/exit protocol within a fixed grace period, then cancels the owned process group and waits for process/reader reaping.
func (*Client) Definition ¶
Definition returns the definition site(s) for the symbol at file:line:col.
func (*Client) DocumentSymbols ¶
DocumentSymbols returns the outline for a single file.
func (*Client) References ¶
References returns usage sites of the symbol at file:line:col.
func (*Client) Start ¶
Start owns the server until ctx is canceled or Close is called. Concurrent starts share one initialize attempt; Close is terminal and waits for reaping.
func (*Client) WorkspaceSymbols ¶
WorkspaceSymbols searches across the workspace for matching symbols.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager holds one Client per language and routes calls by file extension.
func NewManager ¶
NewManager builds a manager. Use defaultLSPConfig() for sensible defaults.
func (*Manager) ClientForFile ¶
ClientForFile picks the right language client for a given path. Returns nil if no server handles that extension.
func (*Manager) ConnectedCount ¶
ConnectedCount returns how many language servers are live.
type SymbolInformation ¶
type SymbolInformation struct {
Name string `json:"name"`
Kind int `json:"kind"`
Location Location `json:"location"`
}
SymbolInformation is the legacy LSP workspace/document symbol shape — the subset we actually consume.