This is a generator plugin for go using https://github.com/microsoft/lsprotocol.
go get github.com/myleshyson/lsprotocol-go@latest
import "github.com/myleshyson/lsprotocol-go/protocol"
var request protocol.InitializeRequest
All lsprotocol types are in the protocol
package.
This package provides a limited number of utility functions for dealing with jsonrpc messages.
DecodeMessage This is a helper that takes in a full jsonrpc message and returns a message object.
var content = []byte("Content-Length: 20\r\n\r\n{...etc}")
message, err := protocol.DecodeMessage(content)
SplitMessage This is a helper that takes in a full jsonrpc message and returns information about the message.
var content = []byte("Content-Length: 20\r\n\r\n{...etc}")
messageLengthIncludingTheHeader, contentLength, content, err := protocol.SplitMessage(content)
Split This is a helper you can use with scanner to read jsonrpc messages from a stream.
var scanner = bufio.NewScanner(reader)
scanner.Split(protocol.Split)
for scanner.Scan() {
msg := scanner.Bytes()
// handle message
}
Error
This is a tiny helper that takes in an error coe and an error
instance, and returns a ResponseError
responseError := protocol.Error(someErrorCode, err)
The following interfaces are provided by this package:
Request
- represents a jsonrpc requestResponse
- represents a jsonrpc responseNotification
- represents a jsonrpc notificationMessage
- represents a jsonrpc messageIncomingMessage
- notification or request. not in the spec but super helpful.