Documentation
¶
Overview ¶
Package lsp implements a minimal, synchronous Language Server Protocol client that speaks JSON-RPC 2.0 over a server process's stdio. It is stdlib-only and intended for read-only symbol resolution: enclosing definition ranges, go-to-definition and find-references.
Index ¶
- func PathToURI(path string) string
- func URIToPath(uri string) string
- type Client
- func (c *Client) Close() error
- func (c *Client) Definition(uri string, line, char int) ([]Location, error)
- func (c *Client) DidOpen(uri, languageID, text string) error
- func (c *Client) DocumentSymbol(uri string) ([]DocumentSymbol, error)
- func (c *Client) References(uri string, line, char int, includeDecl bool) ([]Location, error)
- type DocumentSymbol
- type Location
- type Position
- type Range
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a synchronous JSON-RPC 2.0 LSP client bound to a server process. A single background goroutine reads framed responses and demultiplexes them to per-request waiters keyed by id.
func Start ¶
Start launches the language server (argv[0] with argv[1:] args), performs the LSP initialize handshake rooted at rootDir, and returns a ready client. It returns an error rather than hanging if the binary is missing or the initialize request fails. The ctx bounds the whole client lifetime; every request also honours it and a per-request timeout.
func (*Client) Close ¶
Close performs a best-effort shutdown/exit handshake, then kills the process and closes the pipes. It is safe to call more than once.
func (*Client) Definition ¶
Definition resolves the definition(s) of the symbol at (line, char), handling Location, Location[] and LocationLink[] result shapes.
func (*Client) DidOpen ¶
DidOpen notifies the server that a document is open with the given contents.
func (*Client) DocumentSymbol ¶
func (c *Client) DocumentSymbol(uri string) ([]DocumentSymbol, error)
DocumentSymbol returns the document's symbols, supporting both the hierarchical DocumentSymbol[] shape and the flat SymbolInformation[] fallback.
type DocumentSymbol ¶
type DocumentSymbol struct {
Name string `json:"name"`
Kind int `json:"kind"`
Range Range `json:"range"`
SelectionRange Range `json:"selectionRange"`
Children []DocumentSymbol `json:"children,omitempty"`
}
DocumentSymbol is a hierarchical symbol with an enclosing Range and a narrower SelectionRange (typically the name).