turbo-editors/turbo-corepublic Fork 0
v0.9.0
Commits
Clone
git clone https://git.rickub.com/turbo-editors/turbo-core.git
git clone ssh://git@rickub.com/turbo-editors/turbo-core.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

conn.go · 44 lines · 1.5 KBGo Blame HistoryRaw
🛟 Updated. 28d5985 k33g 16h ago1package lsp
2
3import (
4 "io"
5
6 "codeberg.org/turbo-editors/turbo-core/jsonrpc"
7)
8
9// The JSON-RPC layer this client talks over is jsonrpc's, which the Agent
10// Client Protocol client shares. The names below are kept so that a language
11// server's error still reads as an lsp one at the call site.
12
13// Conn is a JSON-RPC 2.0 connection over an LSP-framed stream.
14type Conn = jsonrpc.Conn
15
16// ResponseError is the error object a response may carry.
17type ResponseError = jsonrpc.ResponseError
18
19// NotificationFunc handles a notification the server sent, such as a batch of
20// diagnostics. It is called from the connection's read loop, so it must not
21// block for long.
22type NotificationFunc = jsonrpc.NotificationFunc
23
24// ErrClosed is returned once the connection has been closed or its peer has
25// gone away.
26var ErrClosed = jsonrpc.ErrClosed
27
28// The JSON-RPC error codes this client uses.
29const (
30 CodeMethodNotFound = jsonrpc.CodeMethodNotFound
31 CodeInternalError = jsonrpc.CodeInternalError
32)
33
34// NewConn returns a connection to a language server over stream. Call Run in a
35// goroutine of its own to start reading.
36//
37// It is NewConn with this package's framing already chosen, which is the only
38// thing a language server connection adds to a plain JSON-RPC one.
39//
40// conn := lsp.NewConn(stream, client.handleNotification, client.answerRequest)
41// go conn.Run()
42func NewConn(stream io.ReadWriteCloser, onNotify jsonrpc.NotificationFunc, onRequest jsonrpc.RequestFunc) *Conn {
43 return jsonrpc.NewConn(stream, Framing{}, onNotify, onRequest)
44}