Documentation
¶
Overview ¶
Package lsprpc implements a jsonrpc2.StreamServer that may be used to serve the LSP on a jsonrpc2 channel.
Index ¶
- func ConnectToRemote(ctx context.Context, addr string) (net.Conn, error)
- func ExecuteCommand(ctx context.Context, addr string, id string, request, result any) error
- func NewForwarder(rawAddr string, argFunc func(network, address string) []string) (jsonrpc2.StreamServer, error)
- func ParseAddr(listen string) (network string, address string)
- func QueryServerState(ctx context.Context, addr string) (any, error)
- type StreamServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecuteCommand ¶
ExecuteCommand connects to the named server, sends it a workspace/executeCommand request (with command 'id' and arguments JSON encoded in 'request'), and populates the result variable.
func NewForwarder ¶
func NewForwarder(rawAddr string, argFunc func(network, address string) []string) (jsonrpc2.StreamServer, error)
NewForwarder creates a new forwarder (a jsonrpc2.StreamServer), ready to forward connections to the remote server specified by rawAddr. If provided and rawAddr indicates an 'automatic' address (starting with 'auto;'), argFunc may be used to start a remote server for the auto-discovered address.
Types ¶
type StreamServer ¶ added in v0.20.0
type StreamServer struct {
// contains filtered or unexported fields
}
The streamServer type is a jsonrpc2.streamServer that handles incoming streams as a new LSP session, using a shared cache.
func NewStreamServer ¶
func NewStreamServer(cache *cache.Cache, daemon bool, optionsFunc func(*settings.Options)) *StreamServer
NewStreamServer creates a StreamServer using the shared cache. If withTelemetry is true, each session is instrumented with telemetry that records RPC statistics.
func (*StreamServer) FirstSession ¶ added in v0.20.0
func (s *StreamServer) FirstSession() (*cache.Session, protocol.Server)
FirstSession returns the first session by lexically sorted session ID, or (nil, nil).
func (*StreamServer) ServeStream ¶ added in v0.20.0
ServeStream implements the jsonrpc2.StreamServer interface, by handling incoming streams using a new lsp server.
func (*StreamServer) Session ¶ added in v0.20.0
Session returns the current active session for the given id, or (nil, nil) if none exists.
func (*StreamServer) SetSessionExitFunc ¶ added in v0.20.0
func (s *StreamServer) SetSessionExitFunc(f func(id string))
SetSessionExitFunc sets the function to call when sessions exit. It is not concurrency safe, and must only be called at most once, before the receiver is passed to jsonrpc2.Serve.