package protocol¶
Constants¶
const (
ErrorCodeParseError = -32700
ErrorCodeInvalidRequest = -32600
ErrorCodeMethodNotFound = -32601
ErrorCodeInvalidParams = -32602
ErrorCodeInternalError = -32603
ErrorCodeRequestCancel = -32800
)
Functions¶
func ReadMessage¶
ReadMessage reads one Content-Length-framed JSON-RPC message body.
func WriteMessage¶
WriteMessage writes one Content-Length-framed JSON-RPC message body.
Types¶
type ClientCapabilities¶
ClientCapabilities is present for initialize compatibility.
type CompletionItem¶
type CompletionItem struct {
Label string `json:"label"`
Kind CompletionItemKind `json:"kind,omitempty"`
FilterText string `json:"filterText,omitempty"`
TextEdit *TextEdit `json:"textEdit,omitempty"`
}
CompletionItem is one completion candidate.
type CompletionItemKind¶
CompletionItemKind is an LSP completion item kind.
type CompletionList¶
type CompletionList struct {
IsIncomplete bool `json:"isIncomplete"`
Items []CompletionItem `json:"items"`
}
CompletionList is an LSP completion response.
type CompletionOptions¶
CompletionOptions configures completion requests.
type CompletionParams¶
type CompletionParams struct {
TextDocument TextDocumentIdentifier `json:"textDocument"`
Position Position `json:"position"`
}
CompletionParams is a completion request.
type DefinitionParams¶
type DefinitionParams struct {
TextDocument TextDocumentIdentifier `json:"textDocument"`
Position Position `json:"position"`
}
DefinitionParams is a go-to-definition request.
type Diagnostic¶
type Diagnostic struct {
Range Range `json:"range"`
Severity DiagnosticSeverity `json:"severity,omitempty"`
Source string `json:"source,omitempty"`
Message string `json:"message"`
}
Diagnostic is an LSP diagnostic.
type DiagnosticSeverity¶
DiagnosticSeverity is an LSP diagnostic severity.
type DidChangeTextDocumentParams¶
type DidChangeTextDocumentParams struct {
TextDocument VersionedTextDocumentIdentifier `json:"textDocument"`
ContentChanges []TextDocumentContentChangeEvent `json:"contentChanges"`
}
DidChangeTextDocumentParams is sent when a text document changes.
type DidChangeWatchedFilesParams¶
DidChangeWatchedFilesParams is sent when watched files change.
type DidCloseTextDocumentParams¶
type DidCloseTextDocumentParams struct {
TextDocument TextDocumentIdentifier `json:"textDocument"`
}
DidCloseTextDocumentParams is sent when a text document closes.
type DidOpenTextDocumentParams¶
DidOpenTextDocumentParams is sent when a text document opens.
type DidSaveTextDocumentParams¶
type DidSaveTextDocumentParams struct {
TextDocument TextDocumentIdentifier `json:"textDocument"`
Text string `json:"text,omitempty"`
}
DidSaveTextDocumentParams is sent when a text document is saved.
type DocumentFormattingParams¶
type DocumentFormattingParams struct {
TextDocument TextDocumentIdentifier `json:"textDocument"`
Options FormattingOptions `json:"options"`
}
DocumentFormattingParams is a whole-document formatting request.
type DocumentSymbol¶
type DocumentSymbol struct {
Name string `json:"name"`
Kind SymbolKind `json:"kind"`
Range Range `json:"range"`
SelectionRange Range `json:"selectionRange"`
Children []DocumentSymbol `json:"children,omitempty"`
}
DocumentSymbol is a document-local symbol.
type DocumentSymbolParams¶
DocumentSymbolParams is a document symbol request.
type FileChangeType¶
FileChangeType is an LSP watched-file change kind.
type FileEvent¶
FileEvent is one watched-file change.
type FormattingOptions¶
type FormattingOptions struct {
TabSize uint32 `json:"tabSize"`
InsertSpaces bool `json:"insertSpaces"`
}
FormattingOptions is present for LSP formatting compatibility.
type Handler¶
Handler serves JSON-RPC requests.
type HandlerFunc¶
HandlerFunc adapts a function to Handler.
func (HandlerFunc) HandleRequest¶
HandleRequest calls f.
type Hover¶
type Hover struct {
Contents MarkupContent `json:"contents"`
Range *Range `json:"range,omitempty"`
}
Hover is an LSP hover response.
type HoverParams¶
type HoverParams struct {
TextDocument TextDocumentIdentifier `json:"textDocument"`
Position Position `json:"position"`
}
HoverParams is a hover request.
type ID¶
ID is a JSON-RPC request id.
func NewNumberID¶
NewNumberID returns a numeric JSON-RPC request id.
func NewStringID¶
NewStringID returns a string JSON-RPC request id.
func (ID) MarshalJSON¶
func (ID) Number¶
Number returns the id as a number when it was encoded as a number.
func (ID) String¶
String returns the id as a string when it was encoded as a string.
func (*ID) UnmarshalJSON¶
type InitializeParams¶
type InitializeParams struct {
ProcessID *int32 `json:"processId,omitempty"`
RootURI string `json:"rootUri,omitempty"`
Capabilities ClientCapabilities `json:"capabilities"`
WorkspaceFolders []WorkspaceFolder `json:"workspaceFolders,omitempty"`
}
InitializeParams is the subset of LSP initialize params used by Unobin.
type InitializeResult¶
type InitializeResult struct {
Capabilities ServerCapabilities `json:"capabilities"`
ServerInfo *ServerInfo `json:"serverInfo,omitempty"`
}
InitializeResult is the LSP initialize response body.
type Location¶
Location is an LSP source location.
type MarkupContent¶
MarkupContent is hover text with a markup kind.
type MarkupKind¶
MarkupKind is an LSP markup content kind.
type Position¶
Position is a zero-based LSP UTF-16 text position.
type PublishDiagnosticsParams¶
type PublishDiagnosticsParams struct {
URI string `json:"uri"`
Version *int32 `json:"version,omitempty"`
Diagnostics []Diagnostic `json:"diagnostics"`
}
PublishDiagnosticsParams sends diagnostics for one document.
type Range¶
Range is an LSP text range.
type RequestMessage¶
type RequestMessage struct {
JSONRPC string `json:"jsonrpc"`
ID *ID `json:"id,omitempty"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
RequestMessage is a JSON-RPC request or notification.
type ResponseError¶
type ResponseError struct {
Code int `json:"code"`
Message string `json:"message"`
Data any `json:"data,omitempty"`
}
ResponseError is a JSON-RPC response error object.
func InternalError¶
InternalError returns the standard JSON-RPC internal-error object.
func InvalidParams¶
InvalidParams returns the standard JSON-RPC invalid-params error.
func MethodNotFound¶
MethodNotFound returns the standard JSON-RPC method-not-found error.
type ResponseMessage¶
ResponseMessage is a JSON-RPC response.
func (ResponseMessage) MarshalJSON¶
type Sender¶
Sender writes a server-to-client notification.
type SenderSetter¶
SenderSetter accepts a server-to-client notification sender.
type Server¶
Server serves JSON-RPC messages over LSP stdio framing.
func NewServer¶
NewServer returns a JSON-RPC server using LSP stdio framing.
func NewServerWithOptions¶
func NewServerWithOptions(
r io.Reader,
w io.Writer,
handler Handler,
options ServerOptions,
) *Server
NewServerWithOptions returns a JSON-RPC server with tracing and logging.
func (*Server) Notify¶
Notify writes a server-to-client JSON-RPC notification.
func (*Server) Serve¶
Serve reads requests until the input stream ends.
type ServerCapabilities¶
type ServerCapabilities struct {
TextDocumentSync TextDocumentSyncKind `json:"textDocumentSync,omitempty"`
DocumentFormattingProvider bool `json:"documentFormattingProvider,omitempty"`
DefinitionProvider bool `json:"definitionProvider,omitempty"`
DocumentSymbolProvider bool `json:"documentSymbolProvider,omitempty"`
CompletionProvider *CompletionOptions `json:"completionProvider,omitempty"`
HoverProvider bool `json:"hoverProvider,omitempty"`
}
ServerCapabilities advertises implemented LSP features.
type ServerInfo¶
ServerInfo names the LSP server.
type ServerOptions¶
ServerOptions configures JSON-RPC tracing and logging.
type Stopper¶
Stopper reports whether the server should stop reading messages.
type SymbolKind¶
SymbolKind is an LSP symbol kind.
type TextDocumentContentChangeEvent¶
type TextDocumentContentChangeEvent struct {
Range *Range `json:"range,omitempty"`
RangeLength *int `json:"rangeLength,omitempty"`
Text string `json:"text"`
}
TextDocumentContentChangeEvent is a full-text or incremental change.
type TextDocumentIdentifier¶
TextDocumentIdentifier identifies a text document by URI.
type TextDocumentItem¶
type TextDocumentItem struct {
URI string `json:"uri"`
LanguageID string `json:"languageId"`
Version int32 `json:"version"`
Text string `json:"text"`
}
TextDocumentItem is an open text document.
type TextDocumentSyncKind¶
TextDocumentSyncKind is an LSP text sync mode.
type TextEdit¶
TextEdit replaces a range with new text.
type VersionedTextDocumentIdentifier¶
type VersionedTextDocumentIdentifier struct {
URI string `json:"uri"`
Version int32 `json:"version"`
}
VersionedTextDocumentIdentifier identifies a versioned text document.
type WorkspaceFolder¶
WorkspaceFolder is an LSP workspace folder.