Documentation
¶
Index ¶
- Variables
- func CreateConnectionOptions(debug bool, logger *zap.Logger) []jsonrpc2.ConnOpt
- func NewLSPContext(ctx context.Context, conn *jsonrpc2.Conn, request *jsonrpc2.Request) *common.LSPContext
- func NewStreamConnection(handler jsonrpc2.Handler, stream io.ReadWriteCloser, opts ...ConnOption) *jsonrpc2.Conn
- func NewWebSocketConnection(handler jsonrpc2.Handler, wsConn *websocket.Conn, opts ...ConnOption) *jsonrpc2.Conn
- func RunTCP(ctx context.Context, address string, server *Server, logger *zap.Logger) error
- func RunWebSocketServer(address string, server *Server, logger *zap.Logger, httpServer *http.Server) error
- type ConnOption
- type JSONRPCLogger
- type Server
- func (s *Server) GetReadTimeout() time.Duration
- func (s *Server) GetTimeout() time.Duration
- func (s *Server) GetWriteTimeout() time.Duration
- func (s *Server) NewHandler() jsonrpc2.Handler
- func (s *Server) Serve(optConn *jsonrpc2.Conn, connLogger *zap.Logger)
- func (s *Server) ServeWebSocket(conn *websocket.Conn, logger *zap.Logger)
- type ServerOption
- type Stdio
Constants ¶
This section is empty.
Variables ¶
var DefaultTimeout = time.Minute
DefaultTimeout is the default timeout used for a JSON-RPC 2.0 connection.
Functions ¶
func CreateConnectionOptions ¶
func NewLSPContext ¶
func NewLSPContext(ctx context.Context, conn *jsonrpc2.Conn, request *jsonrpc2.Request) *common.LSPContext
NewLSPContext creates a new LSP context from the given connection and request.
func NewStreamConnection ¶
func NewStreamConnection(handler jsonrpc2.Handler, stream io.ReadWriteCloser, opts ...ConnOption) *jsonrpc2.Conn
NewStreamConnection creates a new JSON-RPC 2.0 connection over a stream (io.ReadWriterCloser).
func NewWebSocketConnection ¶
func NewWebSocketConnection(handler jsonrpc2.Handler, wsConn *websocket.Conn, opts ...ConnOption) *jsonrpc2.Conn
NewWebSocketConnection creates a new JSON-RPC 2.0 connection over a WebSocket connection.
Types ¶
type ConnOption ¶
type ConnOption func(*connWrapper)
ConnOption is a function that configures a connection.
func WithJSONRPCConnOptions ¶
func WithJSONRPCConnOptions(opts ...jsonrpc2.ConnOpt) ConnOption
WithJSONRPCConnOptions configures the connection with JSON-RPC 2.0 connection options.
func WithReadTimeout ¶
func WithReadTimeout(timeout time.Duration) ConnOption
WithReadTimeout configures the connection with a read timeout.
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ConnOption
WithTimeout configures the connection with a timeout.
func WithWebSocket ¶
func WithWebSocket(wsConn *websocket.Conn) ConnOption
WithWebSocket configures the connection with a WebSocket connection.
func WithWriteTimeout ¶
func WithWriteTimeout(timeout time.Duration) ConnOption
WithWriteTimeout configures the connection with a write timeout.
type JSONRPCLogger ¶
type JSONRPCLogger struct {
// contains filtered or unexported fields
}
func (*JSONRPCLogger) Printf ¶
func (l *JSONRPCLogger) Printf(format string, v ...any)
Printf implements the jsonrpc2.Logger interface.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an LSP over JSON-RPC 2.0 server that works for all versions of LSP that ls-builder provides.
func NewServer ¶
func NewServer( handler common.Handler, debug bool, logger *zap.Logger, conn *jsonrpc2.Conn, opts ...ServerOption, ) *Server
NewServer creates a new LSP server over JSON-RPC 2.0.
func (*Server) GetReadTimeout ¶
GetReadTimeout returns the server's read timeout.
func (*Server) GetTimeout ¶
GetTimeout returns the server's timeout.
func (*Server) GetWriteTimeout ¶
GetWriteTimeout returns the server's write timeout.
func (*Server) NewHandler ¶
NewHandler creates a handler from the server to handle JSON-RPC requests.
type ServerOption ¶
type ServerOption func(*Server)
ServerOption is a function that configures a server.
func WithServerReadTimeout ¶
func WithServerReadTimeout(timeout time.Duration) ServerOption
WithServerReadTimeout configures the server with a read timeout.
func WithServerTimeout ¶
func WithServerTimeout(timeout time.Duration) ServerOption
WithServerTimeout configures the server with a timeout.
func WithServerWriteTimeout ¶
func WithServerWriteTimeout(timeout time.Duration) ServerOption
WithServerWriteTimeout configures the server with a write timeout.
type Stdio ¶
type Stdio struct{}
Stdio provides a ReadWriteCloser interface to os.Stdin and os.Stdout to be used as the transport layer for a language server over JSON-RPC 2.0.