protocol

package
v1.0.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestInitialize           = "initialize"
	RequestShutdown             = "shutdown"
	MethodSetTrace              = "$/setTrace" // set trace notification: 'off' | 'messages' | 'verbose'
	MethodTextDocumentDidChange = "textDocument/didChange"
	MethodTextDocumentDidClose  = "textDocument/didClose"
	MethodTextDocumentDidSave   = "textDocument/didSave"
	MethodTextDocumentHover     = "textDocument/hover"
)
View Source
const (
	NotificationInitialized = "initialized"
	NotificationExit        = "exit"
)
View Source
const (
	ErrorCodeParseError     = -32700
	ErrorCodeInvalidRequest = -32600
	ErrorCodeMethodNotFound = -32601
	ErrorCodeInvalidParams  = -32602
	ErrorCodeInternalError  = -32603
)
View Source
const (
	TextDocumentSyncKindNone = iota
	TextDocumentSyncKindFull
	TextDocumentSyncKindIncremental
)

Variables

This section is empty.

Functions

func BaseMessage

func BaseMessage(r any) ([]byte, error)

raw base message with MIME header

func DecodeParams

func DecodeParams[T any](r Request) (*T, error)

Types

type CancelRequest

type CancelRequest struct {
	Id int `json:"id"` // vscode uses int, but the spec says it can be int or string
}

type ClientCapabilities

type ClientCapabilities struct{}

type DiagnosticOptions

type DiagnosticOptions struct {
	Identifier            string `json:"identifier"`
	InterFileDependencies bool   `json:"interFileDependencies"`
	WorkspaceDiagnostics  bool   `json:"workspaceDiagnostics"`
}

type InitializeRequest

type InitializeRequest struct {
	Capabilities ClientCapabilities `json:"capabilities"`
	RootPath     string             `json:"rootPath"`
}

Initialize request

type InitializeResponse

type InitializeResponse struct {
	Capabilities ServerCapabilities `json:"capabilities"`
}

Initialize response

type MarkupContent

type MarkupContent struct {
	Kind  string `json:"kind"`
	Value string `json:"value"`
}

type Position

type Position struct {
	Line      int `json:"line"`
	Character int `json:"character"`
}

type Range

type Range struct {
	Start Position `json:"start"`
	End   Position `json:"end"`
}

type Request

type Request struct {
	Version string           `json:"jsonrpc"`
	Id      int              `json:"id"` // vscode uses int, but the spec says it can be int or string
	Method  string           `json:"method"`
	Params  *json.RawMessage `json:"params"`
}

type Response

type Response struct {
	Version string           `json:"jsonrpc"`
	Id      int              `json:"id"` // vscode uses int, but the spec says it can be int or string or null
	Result  *json.RawMessage `json:"result"`
	Error   *ResponseError   `json:"error"`
}

func NewEmptyResponse

func NewEmptyResponse[T any](id int, r T) Response

func NewResponse

func NewResponse(id int, result json.RawMessage) Response

func NewResponseError

func NewResponseError(id int, err ResponseError) Response

type ResponseError

type ResponseError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type ServerCapabilities

type ServerCapabilities struct {
	TextDocumentSync   TextDocumentSyncKind `json:"textDocumentSync"`
	HoverProvider      bool                 `json:"hoverProvider"`
	DiagnosticProvider DiagnosticOptions    `json:"diagnosticProvider"`
}

type TextDocument

type TextDocument struct {
	Path string `json:"uri"`
	Text string `json:"text"`
}

type TextDocumentSyncKind

type TextDocumentSyncKind int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL