Documentation
¶
Index ¶
- Constants
- func ReadMessage(r io.Reader) ([]byte, error)
- func WriteMessage(w io.Writer, body []byte) error
- type ClientCapabilities
- type CompletionItem
- type CompletionItemKind
- type CompletionList
- type CompletionOptions
- type CompletionParams
- type DefinitionParams
- type Diagnostic
- type DiagnosticSeverity
- type DidChangeTextDocumentParams
- type DidChangeWatchedFilesParams
- type DidCloseTextDocumentParams
- type DidOpenTextDocumentParams
- type DidSaveTextDocumentParams
- type DocumentFormattingParams
- type DocumentSymbol
- type DocumentSymbolParams
- type FileChangeType
- type FileEvent
- type FormattingOptions
- type Handler
- type HandlerFunc
- type Hover
- type HoverParams
- type ID
- type InitializeParams
- type InitializeResult
- type Location
- type MarkupContent
- type MarkupKind
- type Position
- type PublishDiagnosticsParams
- type Range
- type RequestMessage
- type ResponseError
- type ResponseMessage
- type Sender
- type SenderSetter
- type Server
- type ServerCapabilities
- type ServerInfo
- type ServerOptions
- type Stopper
- type SymbolKind
- type TextDocumentContentChangeEvent
- type TextDocumentIdentifier
- type TextDocumentItem
- type TextDocumentSyncKind
- type TextEdit
- type VersionedTextDocumentIdentifier
- type WorkspaceFolder
Constants ¶
const ( ErrorCodeParseError = -32700 ErrorCodeInvalidRequest = -32600 ErrorCodeMethodNotFound = -32601 ErrorCodeInvalidParams = -32602 ErrorCodeInternalError = -32603 ErrorCodeRequestCancel = -32800 )
Variables ¶
This section is empty.
Functions ¶
func ReadMessage ¶
ReadMessage reads one Content-Length-framed JSON-RPC message body.
Types ¶
type ClientCapabilities ¶
type ClientCapabilities struct{}
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 ¶
type CompletionItemKind int
CompletionItemKind is an LSP completion item kind.
const ( CompletionItemKindText CompletionItemKind = 1 CompletionItemKindMethod CompletionItemKind = 2 CompletionItemKindFunction CompletionItemKind = 3 CompletionItemKindField CompletionItemKind = 5 CompletionItemKindVariable CompletionItemKind = 6 CompletionItemKindKeyword CompletionItemKind = 14 )
type CompletionList ¶
type CompletionList struct {
IsIncomplete bool `json:"isIncomplete"`
Items []CompletionItem `json:"items"`
}
CompletionList is an LSP completion response.
type CompletionOptions ¶
type CompletionOptions struct {
TriggerCharacters []string `json:"triggerCharacters,omitempty"`
}
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 ¶
type DiagnosticSeverity int
DiagnosticSeverity is an LSP diagnostic severity.
const ( DiagnosticSeverityError DiagnosticSeverity = 1 DiagnosticSeverityWarning DiagnosticSeverity = 2 DiagnosticSeverityInformation DiagnosticSeverity = 3 DiagnosticSeverityHint DiagnosticSeverity = 4 )
type DidChangeTextDocumentParams ¶
type DidChangeTextDocumentParams struct {
TextDocument VersionedTextDocumentIdentifier `json:"textDocument"`
ContentChanges []TextDocumentContentChangeEvent `json:"contentChanges"`
}
DidChangeTextDocumentParams is sent when a text document changes.
type DidChangeWatchedFilesParams ¶
type DidChangeWatchedFilesParams struct {
Changes []FileEvent `json:"changes"`
}
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 ¶
type DidOpenTextDocumentParams struct {
TextDocument TextDocumentItem `json:"textDocument"`
}
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 ¶
type DocumentSymbolParams struct {
TextDocument TextDocumentIdentifier `json:"textDocument"`
}
DocumentSymbolParams is a document symbol request.
type FileChangeType ¶
type FileChangeType int
FileChangeType is an LSP watched-file change kind.
const ( FileChangeTypeCreated FileChangeType = 1 FileChangeTypeChanged FileChangeType = 2 FileChangeTypeDeleted FileChangeType = 3 )
type FileEvent ¶
type FileEvent struct {
URI string `json:"uri"`
Type FileChangeType `json:"type"`
}
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 ¶
type Handler interface {
HandleRequest(context.Context, *RequestMessage) (any, *ResponseError)
}
Handler serves JSON-RPC requests.
type HandlerFunc ¶
type HandlerFunc func(context.Context, *RequestMessage) (any, *ResponseError)
HandlerFunc adapts a function to Handler.
func (HandlerFunc) HandleRequest ¶
func (f HandlerFunc) HandleRequest(ctx context.Context, req *RequestMessage) (any, *ResponseError)
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 ¶
type ID struct {
// contains filtered or unexported fields
}
ID is a JSON-RPC request id.
func (ID) MarshalJSON ¶
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 MarkupContent ¶
type MarkupContent struct {
Kind MarkupKind `json:"kind"`
Value string `json:"value"`
}
MarkupContent is hover text with a markup kind.
type MarkupKind ¶
type MarkupKind string
MarkupKind is an LSP markup content kind.
const ( MarkupKindPlainText MarkupKind = "plaintext" MarkupKindMarkdown MarkupKind = "markdown" )
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 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 ¶
func InternalError(err error) *ResponseError
InternalError returns the standard JSON-RPC internal-error object.
func InvalidParams ¶
func InvalidParams(message string) *ResponseError
InvalidParams returns the standard JSON-RPC invalid-params error.
func MethodNotFound ¶
func MethodNotFound(method string) *ResponseError
MethodNotFound returns the standard JSON-RPC method-not-found error.
type ResponseMessage ¶
type ResponseMessage struct {
JSONRPC string
ID *ID
Result any
Error *ResponseError
}
ResponseMessage is a JSON-RPC response.
func (ResponseMessage) MarshalJSON ¶
func (r ResponseMessage) MarshalJSON() ([]byte, error)
type SenderSetter ¶
type SenderSetter interface {
SetSender(Sender)
}
SenderSetter accepts a server-to-client notification sender.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server serves JSON-RPC messages over 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.
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 ¶
type Stopper interface {
StopRequested() bool
}
Stopper reports whether the server should stop reading messages.
type SymbolKind ¶
type SymbolKind int
SymbolKind is an LSP symbol kind.
const ( SymbolKindFile SymbolKind = 1 SymbolKindModule SymbolKind = 2 SymbolKindClass SymbolKind = 5 SymbolKindFunction SymbolKind = 12 SymbolKindVariable SymbolKind = 13 SymbolKindField SymbolKind = 8 )
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 ¶
type TextDocumentIdentifier struct {
URI string `json:"uri"`
}
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 ¶
type TextDocumentSyncKind int
TextDocumentSyncKind is an LSP text sync mode.
const ( TextDocumentSyncKindNone TextDocumentSyncKind = 0 TextDocumentSyncKindFull TextDocumentSyncKind = 1 TextDocumentSyncKindIncremental TextDocumentSyncKind = 2 )
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.