Documentation ¶
Index ¶
- type ClientCapabilities
- type CodeLensOptions
- type CompletionOptions
- type Config
- type ConfigurationItem
- type ConfigurationParams
- type Conn
- type Diagnostic
- type DiagnosticSeverity
- type DidChangeConfigurationParams
- type DidChangeTextDocumentParams
- type DidCloseTextDocumentParams
- type DidOpenTextDocumentParams
- type DidSaveTextDocumentParams
- type DocumentFilter
- type DocumentOnTypeFormattingOptions
- type DocumentSelector
- type DocumentURI
- type DynamicRegistration
- type Handler
- type Health
- type Hover
- type IniterFunc
- type InitializeParams
- type InitializeResult
- type Location
- type LogMessageParams
- type MarkupContent
- type MarkupKind
- type MessageType
- type Position
- type PublishDiagnosticsParams
- type Range
- type ReferenceContext
- type ReferenceParams
- type Registration
- type RegistrationParams
- type SaveOptions
- type ServerCapabilities
- type ShowMessageParams
- type SignatureHelpOptions
- type TextDocumentClientCapabilities
- type TextDocumentContentChangeEvent
- type TextDocumentIdentifier
- type TextDocumentItem
- type TextDocumentPositionParams
- type TextDocumentRegistrationOptions
- type TextDocumentSyncKind
- type TextDocumentSyncOptions
- type VersionedTextDocumentIdentifier
- type WorkspaceClientCapabilities
- type WorkspaceFolder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientCapabilities ¶
type ClientCapabilities struct { // Workspace specific client capabilities. Workspace *WorkspaceClientCapabilities `json:"workspace,omitempty"` // TextDocument specific client capabilities. TextDocument *TextDocumentClientCapabilities `json:"textDocument,omitempty"` // Experimental client capabilities. Experimental interface{} `json:"experimental,omitempty"` }
ClientCapabilities contains specific groups of capabilities of the client https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#initialize-request
type CodeLensOptions ¶
type CodeLensOptions struct {
ResolveProvider bool `json:"resolveProvider,omitempty"`
}
type CompletionOptions ¶
type ConfigurationItem ¶
type ConfigurationItem struct { // ScopeURI is the scope to get the configuration section for. ScopeURI *string `json:"scopeUri,omitempty"` // Section is the configuration section asked for. Section *string `json:"section,omitempty"` }
ConfigurationItem is used by the server to request a configuration section
type ConfigurationParams ¶
type ConfigurationParams struct {
Items []ConfigurationItem `json:"items"`
}
ConfigurationParams is a collection of ConfigurationItem, used by the workspace/configuration request from the server
type Conn ¶
type Conn interface { jsonrpc2.JSONRPC2 Reply(ctx context.Context, id jsonrpc2.ID, result interface{}) error ReplyWithError(ctx context.Context, id jsonrpc2.ID, respErr *jsonrpc2.Error) error }
Conn allows mocking jsonrpc2.Conn
type Diagnostic ¶
type Diagnostic struct { // Range is the range at which the message applies. Range Range `json:"range"` // Severity is the diagnostic's severity. Can be omitted. If omitted it is up // to the client to interpret diagnostics as error, warning, info or hint. Severity *DiagnosticSeverity `json:"severity,omitempty"` // Source is a human-readable string describing the source of this // diagnostic, e.g. 'typescript' or 'super lint'. Source *string `json:"source,omitempty"` // Message is the diagnostic's message. Message string `json:"message"` }
Diagnostic represents a diagnostic, such as a compiler error or warning. Diagnostic objects are only valid in the scope of a resource.
type DiagnosticSeverity ¶
type DiagnosticSeverity int
DiagnosticSeverity represents the severity of a diagnostic
const ( // ErrorDiagnosticSeverity reports an error. ErrorDiagnosticSeverity DiagnosticSeverity // WarningDiagnosticSeverity reports a warning. WarningDiagnosticSeverity // InformationDiagnosticSeverity reports an information. InformationDiagnosticSeverity // HintDiagnosticSeverity reports a hint. HintDiagnosticSeverity )
type DidChangeConfigurationParams ¶
type DidChangeConfigurationParams struct { // Settings are the changed settings Settings map[string]interface{} `json:"settings"` }
DidChangeConfigurationParams contains all settings that have changed
type DidChangeTextDocumentParams ¶
type DidChangeTextDocumentParams struct { /** * The document that did change. The version number points * to the version after all provided content changes have * been applied. */ TextDocument VersionedTextDocumentIdentifier `json:"textDocument"` /** * The actual content changes. The content changes descibe single state changes * to the document. So if there are two content changes c1 and c2 for a document * in state S10 then c1 move the document to S11 and c2 to S12. */ ContentChanges []TextDocumentContentChangeEvent `json:"contentChanges"` }
DidChangeTextDocumentParams is supplied by the client to describe the change or changes made to a text document https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#didchangetextdocument-notification
type DidCloseTextDocumentParams ¶
type DidCloseTextDocumentParams struct { // TextDocument specifies the document that was closed. TextDocument TextDocumentIdentifier `json:"textDocument"` }
DidCloseTextDocumentParams is sent from the client to the server when the document got closed in the client https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#didclosetextdocument-notification
type DidOpenTextDocumentParams ¶
type DidOpenTextDocumentParams struct { // TextDocument is the document that was opened. TextDocument TextDocumentItem `json:"textDocument"` }
DidOpenTextDocumentParams is supplied by the client to describe when a document is opened in the editor https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#didopentextdocument-notification
type DidSaveTextDocumentParams ¶
type DidSaveTextDocumentParams struct { // TextDocument is the document that was saved. TextDocument TextDocumentIdentifier `json:"textDocument"` // Text is the content when saved, and is optional. Depends on the // includeText value when the save notifcation was requested. Text *string `json:"text,omitempty"` }
DidSaveTextDocumentParams is supplied by the client when a file is written to disk https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#didsavetextdocument-notification
type DocumentFilter ¶
type DocumentFilter struct { // LanguageID is a language name, like `typescript`. Language *string `json:"language,omitempty"` // Scheme is a Uri [scheme](#Uri.scheme), like `file` or `untitled`. Scheme *string `json:"scheme,omitempty"` // Pattern is a glob pattern, like `*.{ts,js}`. Pattern *string `json:"pattern,omitempty"` }
DocumentFilter denotes a document through properties like language, schema or pattern. https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#new-documentfilter
type DocumentSelector ¶
type DocumentSelector []DocumentFilter
DocumentSelector is the combination of one or more document filters.
type DocumentURI ¶
type DocumentURI string
DocumentURI is a document identifier https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#uri
type DynamicRegistration ¶
type DynamicRegistration struct { // DynamicRegistration determines whether the 'Did change' // notification supports dynamic registration. DynamicRegistration *bool `json:"dynamicRegistration,omitempty"` }
DynamicRegistration contains information about dynamic changes to capabilities
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler implements jsonrpc2.Handle. There is one Handler per client connection. The Handler has a Workspace to service the incoming LSP requests.
func NewHandler ¶
func NewHandler(load *health.Load, le *langd.LoaderEngine) *Handler
NewHandler creates a new Handler.
func (*Handler) ConfigureLoaderContext ¶
ConfigureLoaderContext will instantiate the loader if its not present, and provide the GOROOT specified by the settings
func (*Handler) SendMessage ¶
SendMessage implements log.SendMessage, so that the server can send a message to the client.
func (*Handler) SetConnection ¶
SetConnection assigns a JSONRPC2 connection and connects the handler to its log
type Hover ¶
type Hover struct { // Contents is the hover's content Contents MarkupContent `json:"contents"` // Range is an optional range inside a text document, used to visualize a // hover, e.g. by changing the background color. Range *Range `json:"range,omitempty"` }
Hover is the result of a hover request.
type IniterFunc ¶
IniterFunc creates a request handler for a particular method
type InitializeParams ¶
type InitializeParams struct { ProcessID int `json:"processId,omitempty"` RootURI DocumentURI `json:"rootUri,omitempty"` InitializationOptions interface{} `json:"initializationOptions,omitempty"` Capabilities ClientCapabilities `json:"capabilities"` Trace string `json:"trace"` // WorkspaceFolders are the workspace folders configured in the client when // the server starts. This property is only available if the client // supports workspace folders. It can be `null` if the client supports // workspace folders but none are configured. WorkspaceFolders *[]WorkspaceFolder `json:"workspaceFolders,omitempty"` }
InitializeParams contains the parameters provided by the client for the initialize method
type InitializeResult ¶
type InitializeResult struct { // Capabilities describe what the server is capable of handling Capabilities ServerCapabilities `json:"capabilities,omitempty"` }
InitializeResult is the response to the initialize request, and includes information regarding the server's capabilities
type Location ¶
type Location struct { URI DocumentURI `json:"uri"` Range Range `json:"range"` }
Location is a spanning location inside a document https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#location
type LogMessageParams ¶
type LogMessageParams struct { // Type is the message type. See {@link MessageType} Type MessageType `json:"type"` // Message is the actual message Message string `json:"message"` }
LogMessageParams is used by the LogMessageNotification to send messages from the server to the client. https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#logmessage-notification
type MarkupContent ¶
type MarkupContent struct { // Kind is the type of the Markup Kind MarkupKind `json:"kind"` // Value is the content itself Value string `json:"value"` }
MarkupContent represents a string value which content is interpreted base on its kind flag. Currently the protocol supports `plaintext` and `markdown` as markup kinds.
If the kind is `markdown` then the value can contain fenced code blocks like in GitHub issues. See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting
Here is an example how such a string can be constructed using JavaScript / TypeScript: ```ts
let markdown: MarkdownContent = { kind: MarkupKind.Markdown, value: [ '# Header', 'Some text', '```typescript', 'someCode();', '```' ].join('\n') };
```
*Please Note* that clients might sanitize the return markdown. A client could decide to remove HTML from the markdown to avoid script execution.
type MarkupKind ¶
type MarkupKind string
MarkupKind describes the content type that a client supports in various result literals like `Hover`, `ParameterInfo` or `CompletionItem`.
Please note that `MarkupKinds` must not start with a `$`. This kinds are reserved for internal usage.
const ( // PlainText is supported as a content format PlainText MarkupKind = "plaintext" // Markdown is supported as a content format Markdown = "markdown" )
type MessageType ¶
type MessageType int
MessageType is the type of message https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#showmessage-notification
const ( // ErrorMessageType is an error message. ErrorMessageType MessageType // WarningMessageType is a warning message. WarningMessageType // InfoMessageType is an information message. InfoMessageType // LogMessageType is a log message. LogMessageType )
type Position ¶
type Position struct { // Line position in a document (zero-based) Line int `json:"line"` // Character offset on a line in a document (zero-based) Character int `json:"character"` }
Position points to a location in a text document https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#position
type PublishDiagnosticsParams ¶
type PublishDiagnosticsParams struct { // URI is the uri for which diagnostic information is reported. URI DocumentURI `json:"uri"` // Diagnostics is an array of diagnostic information items. Diagnostics []Diagnostic `json:"diagnostics"` }
PublishDiagnosticsParams is the notification payload on a server-to-client PublishDiagnostics request.
type Range ¶
type Range struct { // Start is the range's start position Start Position `json:"start"` // End is the range's end position End Position `json:"end"` }
Range is a contigous block within a document https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#range
type ReferenceContext ¶
type ReferenceContext struct { // IncludeDeclaration determines whether to include the declaration of the // current symbol. IncludeDeclaration bool `json:"includeDeclaration"` }
ReferenceContext is included in ReferenceParams for the `Find References` request
type ReferenceParams ¶
type ReferenceParams struct { TextDocumentPositionParams // Context contains contextual options for this request Context *ReferenceContext `json:"context"` }
ReferenceParams supports the `Find References` request
type Registration ¶
type Registration struct { // ID used to register the request. The id can be used to deregister the request again. ID string `json:"id"` // Method or capability to register for Method string `json:"method"` // RegisterOptions are options necessary for the registration. RegisterOptions *[]interface{} `json:"registerOptions"` }
Registration is used to register for a capability. https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#new-register-capability
type RegistrationParams ¶
type RegistrationParams struct {
Registrations []Registration `json:"registrations"`
}
RegistrationParams is an collection of Registration
type SaveOptions ¶
type SaveOptions struct { // IncludeText specifies whether the client should include file content // on save IncludeText bool `json:"includeText"` }
SaveOptions includes options that the server can indicate to the client.
type ServerCapabilities ¶
type ServerCapabilities struct { TextDocumentSync TextDocumentSyncOptions `json:"textDocumentSync,omitempty"` HoverProvider bool `json:"hoverProvider,omitempty"` CompletionProvider *CompletionOptions `json:"completionProvider,omitempty"` SignatureHelpProvider *SignatureHelpOptions `json:"signatureHelpProvider,omitempty"` DefinitionProvider bool `json:"definitionProvider,omitempty"` ReferencesProvider bool `json:"referencesProvider,omitempty"` DocumentHighlightProvider bool `json:"documentHighlightProvider,omitempty"` DocumentSymbolProvider bool `json:"documentSymbolProvider,omitempty"` WorkspaceSymbolProvider bool `json:"workspaceSymbolProvider,omitempty"` CodeActionProvider bool `json:"codeActionProvider,omitempty"` CodeLensProvider *CodeLensOptions `json:"codeLensProvider,omitempty"` DocumentFormattingProvider bool `json:"documentFormattingProvider,omitempty"` DocumentRangeFormattingProvider bool `json:"documentRangeFormattingProvider,omitempty"` DocumentOnTypeFormattingProvider *DocumentOnTypeFormattingOptions `json:"documentOnTypeFormattingProvider,omitempty"` RenameProvider bool `json:"renameProvider,omitempty"` }
type ShowMessageParams ¶
type ShowMessageParams struct { // Type is the message type Type MessageType `json:"type"` // Message is the actual message Message string `json:"message"` }
ShowMessageParams allows the IDE to display a message to the user https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#showmessage-notification
type SignatureHelpOptions ¶
type SignatureHelpOptions struct { // TriggerCharacters are characters that trigger signature help automatically TriggerCharacters []string `json:"triggerCharacters,omitempty"` }
SignatureHelpOptions specifies how the server can assist with signatures
type TextDocumentClientCapabilities ¶
type TextDocumentClientCapabilities struct { // Synchronization contains sync-related capabilities Synchronization *struct { // DynamicRegistration states whether text document synchronization // supports dynamic registration. DynamicRegistration *bool `json:"dynamicRegistration,omitempty"` // WillSave state whether the client supports sending will save // notifications. WillSave *bool `json:"willSave,omitempty"` // WillSaveWaitUntil states whether the client supports sending a will // save request and waits for a response providing text edits which will // be applied to the document before it is saved. WillSaveWaitUntil *bool `json:"willSaveWaitUntil,omitempty"` // DidSave states whether the client supports did save notifications. DidSave *bool `json:"didSave,omitEmpty"` } `json:"synchronization,omitempty"` // Completion contains capabilities specific to `textDocument/completion` Completion *struct { // DynamicRegistration states whether completion supports dynamic // registration. DynamicRegistration *bool `json:"dynamicRegistration,omitempty"` // CompletionItem determines whether the client supports the following // `CompletionItem` specific capabilities. CompletionItem *struct { // SnippetSupport states whether the client supports snippets as insert // text. // // A snippet can define tab stops and placeholders with `$1`, `$2` // and `${3:foo}`. `$0` defines the final tab stop, it defaults to // the end of the snippet. Placeholders with equal identifiers are linked, // that is typing in one will update others too. SnippetSupport *bool `json:"snippetSupport,omitempty"` } `json:"completionItem,omitempty"` } `json:"completion,omitempty"` // Hover determines capabilities specific to `textDocument/hover` Hover *DynamicRegistration `json:"hover,omitempty"` // SignatureHelp determines capabilities specific to `textDocument/signatureHelp` SignatureHelp *DynamicRegistration `json:"signatureHelp,omitempty"` // References determines capabilities specific to `textDocument/references` References *DynamicRegistration `json:"references,omitempty"` // DocumentHighlight determines capabilities specific to `textDocument/documentHighlight` DocumentHighlight *DynamicRegistration `json:"documentHighlight,omitempty"` // DocumentSymbol determines capabilities specific to `textDocument/documentSymbol` DocumentSymbol *DynamicRegistration `json:"documentSymbol,omitempty"` // Formatting determines capabilities specific to `textDocument/formatting` Formatting *DynamicRegistration `json:"formatting,omitempty"` // RangeFormatting determines capabilities specific to `textDocument/rangeFormatting` RangeFormatting *DynamicRegistration `json:"rangeFormatting,omitempty"` // OnTypeFormatting determines capabilities specific to `textDocument/onTypeFormatting` OnTypeFormatting *DynamicRegistration `json:"onTypeFormatting,omitempty"` // Definition determines capabilities specific to `textDocument/definition` Definition *DynamicRegistration `json:"definition,omitempty"` // CodeAction determines capabilities specific to `textDocument/codeAction` CodeAction *DynamicRegistration `json:"codeAction,omitempty"` // CodeLens determines capabilities specific to `textDocument/codeLens` CodeLens *DynamicRegistration `json:"codeLens,omitempty"` // DocumentLink determines capabilities specific to `textDocument/documentLink` DocumentLink *DynamicRegistration `json:"documentLink,omitempty"` // Rename determines capabilities specific to `textDocument/rename` Rename *DynamicRegistration `json:"rename,omitempty"` }
type TextDocumentContentChangeEvent ¶
type TextDocumentContentChangeEvent struct { // Range states the range of the document that changed. Range *Range `json:"range,omitempty"` // RangeLength is the length of the range that got replaced. RangeLength *int `json:"rangeLength,omitempty"` // Text is the new text of the range/document. Text string `json:"text"` }
TextDocumentContentChangeEvent is an event describing a change to a text document. If range and rangeLength are omitted the new text is considered to be the full content of the document.
func (*TextDocumentContentChangeEvent) String ¶
func (tdcce *TextDocumentContentChangeEvent) String() string
type TextDocumentIdentifier ¶
type TextDocumentIdentifier struct { // URI of the text document URI DocumentURI `json:"uri"` }
TextDocumentIdentifier is an identifier for a text document https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#textdocumentidentifier
type TextDocumentItem ¶
type TextDocumentItem struct { // URI is the text document's URI URI DocumentURI `json:"uri"` // LanguageID is the text document's language identifier LanguageID string `json:"languageId"` // Version is the version number of this document (it will increase after // each change, including undo/redo) Version int `json:"version"` // Text is the content of the opened text document Text string `json:"text"` }
TextDocumentItem is an item to trasnfer a text document from the client to the server https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#textdocumentitem
type TextDocumentPositionParams ¶
type TextDocumentPositionParams struct { // TextDocument idenfities the document TextDocument TextDocumentIdentifier `json:"textDocument"` // Position inside the text document Position Position `json:"position"` }
TextDocumentPositionParams is a parameter literal used in requests to pass a text document and a position inside that document. https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#textdocumentpositionparams
type TextDocumentRegistrationOptions ¶
type TextDocumentRegistrationOptions struct { // DocumentSelector is used to identify the scope of the registration. If set to null // the document selector provided on the client side will be used. DocumentSelector *DocumentSelector `json:"documentSelector,omitempty"` }
TextDocumentRegistrationOptions are additional the text document options
type TextDocumentSyncKind ¶
type TextDocumentSyncKind int
TextDocumentSyncKind defines how the host (editor) should sync document changes to the language server.
const ( // None specifies that documents should not be synced at all. None TextDocumentSyncKind = iota // Full specifies that documents are synced by always sending the full // content of the document Full // Incremental specifies that documents are synced by sending the full // content on open; after that only incremental updates to the document are // send Incremental )
type TextDocumentSyncOptions ¶
type TextDocumentSyncOptions struct { // OpenClose determine whether open & close notifications are sent to the // server OpenClose bool `json:"openClose,omitempty"` // Change determines which type of change notifications are sent to the server Change TextDocumentSyncKind `json:"change"` // WillSave determine whether will-save notifications are sent to the server WillSave bool `json:"willSave,omitempty"` // WillSaveWaitUntil determines whether will-save-wait-until requests are // sent to the server WillSaveWaitUntil bool `json:"willSaveWaitUntil,omitempty"` // Save specifies what data is sent along with a save notification Save *SaveOptions `json:"save,omitempty"` }
TextDocumentSyncOptions specify what the server can handle with regard to changes to a text document
type VersionedTextDocumentIdentifier ¶
type VersionedTextDocumentIdentifier struct { TextDocumentIdentifier // Version is the version number of this document. Version int `json:"version"` }
VersionedTextDocumentIdentifier is a TextDocumentIdenfigier with a version number NOTE: figure out how to do JSON marshalling so that the structure is flattened.
type WorkspaceClientCapabilities ¶
type WorkspaceClientCapabilities struct { // ApplyEdit determines whether the client supports applying batch edits to the workspace by supporting // the request 'workspace/applyEdit' ApplyEdit *bool `json:"applyEdit"` // WorkspaceEdit determines whether the client will handle WorkspaceEdit struct { // DocumentChanges declares whether the client supports versioned document changes DocumentChanges *bool `json:"documentChanges,omitempty"` } `json:"workspaceEdit,omitempty"` // DidChangeConfiguration specifies whether the `workspace/didChangeConfiguration` notification // can dynamically change DidChangeConfiguration *DynamicRegistration `json:"didChangeConfiguration,omitempty"` // DidChangeWatchedFiles specifies whether the `workspace/didChangeWatchedFiles` notification // can dynamically change DidChangeWatchedFiles *DynamicRegistration `json:"didChangeWatchedFiles"` // Symbol specifies whether the `workspace/symbol` notification can dynamically change Symbol *DynamicRegistration `json:"symbol,omitempty"` // ExecuteCommand specifies whether the `workspace/executeCommand` request // can dynamically change ExecuteCommand *DynamicRegistration `json:"executeCommand,omitempty"` }
WorkspaceClientCapabilities contains specific client capabilities.
type WorkspaceFolder ¶
type WorkspaceFolder struct { // URI is the associated URI for this workspace folder. URI string `json:"uri"` // Name is the name of the workspace folder. Defaults to the uri's basename. Name string `json:"name"` }
WorkspaceFolder is provided when opening a workspace
Source Files ¶
- cancel.go
- definition.go
- didChangeConfiguration.go
- didChangeTextDocument.go
- didClose.go
- didOpen.go
- didSave.go
- exit.go
- handler.go
- health.go
- hover.go
- initFuncMap.go
- initialize.go
- initialized.go
- logMessage.go
- noopNotification.go
- publishDiagnostics.go
- references.go
- requestBase.go
- requestMap.go
- shutdown.go
- types.go
- uninitedMethod.go