Documentation ¶
Index ¶
- Constants
- Variables
- type CancelParams
- type ClientCapabilities
- type Command
- type Completion
- type CompletionContext
- type CompletionItem
- type CompletionItemKind
- type CompletionList
- type CompletionOptions
- type CompletionParams
- type CompletionTriggerKind
- type Diagnostic
- type DiagnosticRelatedInformation
- type DiagnosticSeverity
- type DidChangeTextDocumentParams
- type DidCloseTextDocumentParams
- type DidOpenTextDocumentParams
- type DidSaveTextDocumentParams
- type DocumentFilter
- type DocumentFormattingParams
- type DocumentURI
- type FormattingOptions
- type Hover
- type InitializeError
- type InitializeParams
- type InitializeResult
- type InsertTextFormat
- type Location
- type MarkedString
- type MarkupContent
- type MarkupKind
- type ParameterInformation
- type Position
- type PublishDiagnosticsParams
- type Range
- type ReferenceContext
- type ReferenceParams
- type RenameParams
- type SaveOptions
- type ServerCapabilities
- type SignatureHelp
- type SignatureHelpOptions
- type SignatureInformation
- type TextDocumentClientCapabilities
- type TextDocumentContentChangeEvent
- type TextDocumentEdit
- type TextDocumentIdentifier
- type TextDocumentItem
- type TextDocumentPositionParams
- type TextDocumentSaveReason
- type TextDocumentSyncKind
- type TextDocumentSyncOptions
- type TextEdit
- type VersionedTextDocumentIdentifier
- type WillSaveTextDocumentParams
- type WorkspaceClientCapabilities
- type WorkspaceEdit
- type WorkspaceFolder
Constants ¶
const RequestCancelled int64 = -32800
RequestCancelled is an error code specific to language server protocol it is been used when the requests returns an error response on cancellation
Variables ¶
var EOL = []string{"\n", "\r\n", "\r"}
EOL is a list of options for end of line characters
Functions ¶
This section is empty.
Types ¶
type CancelParams ¶
CancelParams is the params send to ‘$/cancelRequest’ method
type ClientCapabilities ¶
type ClientCapabilities struct { /** * Workspace specific client capabilities. */ Workspace WorkspaceClientCapabilities `json:"workspace,omitempty"` /** * Text document specific client capabilities. */ TextDocument TextDocumentClientCapabilities `json:"textDocument,omitempty"` /** * Experimental client capabilities. */ Experimental interface{} `json:"experimental,omitempty"` }
ClientCapabilities represents the capability of a client editor
type Command ¶
type Command struct { /** * Title of the command, like `save`. */ Title string `json:"title"` /** * The identifier of the actual command handler. */ Command string `json:"command"` /** * Arguments that the command handler should be * invoked with. */ Arguments []interface{} `json:"arguments"` }
Command Represents a reference to a command. Provides a title which will be used to represent a command in the UI. Commands are identified by a string identifier.
type Completion ¶
type Completion struct { /** * Whether completion supports dynamic registration. */ DynamicRegistration bool `json:"dynamicRegistration,omitempty"` /** * The client supports the following `CompletionItem` specific * capabilities. */ CompletionItem struct { SnippetSupport bool `json:"snippetSupport,omitempty"` } `json:"completionItem,omitempty"` /** * The completion item kind values the client supports. When this * property exists the client also guarantees that it will * handle values outside its set gracefully and falls back * to a default value when unknown. * * If this property is not present the client only supports * the completion items kinds from `Text` to `Reference` as defined in * the initial version of the protocol. */ CompletionItemKind struct { ValueSet []CompletionItemKind `json:"valueSet,omitempty"` } `json:"completionItem,omitempty"` }
Completion is Capabilities specific to the `textDocument/completion`, referenced in TextDocumentClientCapabilities
type CompletionContext ¶
type CompletionContext struct { TriggerKind CompletionTriggerKind `json:"triggerKind"` TriggerCharacter string `json:"triggerCharacter,omitempty"` }
CompletionContext Contains additional information about the context in which a completion request is triggered.
type CompletionItem ¶
type CompletionItem struct { Label string `json:"label"` Kind CompletionItemKind `json:"kind,omitempty"` Detail string `json:"detail,omitempty"` Documentation string `json:"documentation,omitempty"` SortText string `json:"sortText,omitempty"` FilterText string `json:"filterText,omitempty"` InsertText string `json:"insertText,omitempty"` InsertTextFormat InsertTextFormat `json:"insertTextFormat,omitempty"` TextEdit *TextEdit `json:"textEdit,omitempty"` Data interface{} `json:"data,omitempty"` }
CompletionItem represents The completion items.
type CompletionItemKind ¶
type CompletionItemKind int
CompletionItemKind indicate a completion entry
const ( Text CompletionItemKind = 1 Method CompletionItemKind = 2 Function CompletionItemKind = 3 Field CompletionItemKind = 4 Variable CompletionItemKind = 6 Module CompletionItemKind = 9 Property CompletionItemKind = 10 Unit CompletionItemKind = 11 Value CompletionItemKind = 12 Keyword CompletionItemKind = 14 File CompletionItemKind = 17 Reference CompletionItemKind = 18 Folder CompletionItemKind = 19 Operator CompletionItemKind = 24 )
List of CompletionItemKind mapped to respective integer values
const ( // Invoked means Completion was triggered by typing an identifier (24x7 code // complete), manual invocation (e.g Ctrl+Space) or via API. Invoked CompletionItemKind = 1 // TriggerCharacter means Completion was triggered by a trigger character specified by //the `triggerCharacters` properties of the `CompletionRegistrationOptions`. TriggerCharacter CompletionItemKind = 2 // TriggerForIncompleteCompletions was re-triggered as the current // completion list is incomplete. TriggerForIncompleteCompletions CompletionItemKind = 3 )
type CompletionList ¶
type CompletionList struct { IsIncomplete bool `json:"isIncomplete"` Items []*CompletionItem `json:"items"` }
CompletionList Represents a collection of [completion items](#CompletionItem) to be presented in the editor.
type CompletionOptions ¶
type CompletionOptions struct { ResolveProvider bool `json:"resolveProvider,omitempty"` TriggerCharacters []string `json:"triggerCharacters,omitempty"` }
CompletionOptions is a list of options server provides for completion support
type CompletionParams ¶
type CompletionParams struct { TextDocumentPositionParams Context CompletionContext `json:"context,omitempty"` }
CompletionParams is the struct for parameters send to "textDocument/completion" request
type CompletionTriggerKind ¶
type CompletionTriggerKind int
CompletionTriggerKind defines how a completion was triggered
type Diagnostic ¶
type Diagnostic struct { /** * The range at which the message applies. */ Range Range `json:"range"` /** * 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"` /** * The diagnostic's code. Can be omitted. */ Code string `json:"code,omitempty"` /** * A human-readable string describing the source of this * diagnostic, e.g. 'typescript' or 'super lint'. */ Source string `json:"source,omitempty"` /** * The diagnostic's message. */ Message string `json:"message"` /** * An array of related diagnostic information, e.g. when symbol-names within * a scope collide all definitions can be marked via this property. */ RelatedInformation []DiagnosticRelatedInformation `json:"relatedInformation"` }
Diagnostic represents a diagnostic, such as a compiler error or warning. Diagnostic objects are only valid in the scope of a resource.
type DiagnosticRelatedInformation ¶
type DiagnosticRelatedInformation struct { /** * The location of this related diagnostic information. */ Location Location `json:"location"` /** * The message of this related diagnostic information. */ Message string `json:"message"` }
DiagnosticRelatedInformation represents a related message and source code location for a diagnostic. This should be used to point to code locations that cause or related to a diagnostics, e.g when duplicating a symbol in a scope.
type DiagnosticSeverity ¶
type DiagnosticSeverity int
DiagnosticSeverity type is for different kind of supported diagnostic severities
const ( Error DiagnosticSeverity = 1 Warning DiagnosticSeverity = 2 Information DiagnosticSeverity = 3 Hint DiagnosticSeverity = 4 )
List of DiagnosticSeverity mapped to respective integer values
type DidChangeTextDocumentParams ¶
type DidChangeTextDocumentParams struct { TextDocument VersionedTextDocumentIdentifier `json:"textDocument"` ContentChanges []TextDocumentContentChangeEvent `json:"contentChanges"` }
DidChangeTextDocumentParams is sent from client to the server to signal changes to a text document
type DidCloseTextDocumentParams ¶
type DidCloseTextDocumentParams struct {
TextDocument TextDocumentIdentifier `json:"textDocument"`
}
DidCloseTextDocumentParams is sent from the client to the server when the document got closed in the client.
type DidOpenTextDocumentParams ¶
type DidOpenTextDocumentParams struct {
TextDocument TextDocumentItem `json:"textDocument"`
}
DidOpenTextDocumentParams is sent from client to the server when the document that was opened.
type DidSaveTextDocumentParams ¶
type DidSaveTextDocumentParams struct { TextDocument TextDocumentIdentifier `json:"textDocument"` Text string `json:"text,omitempty"` }
DidSaveTextDocumentParams is sent from the client to the server when the document was saved in the client.
type DocumentFilter ¶
type DocumentFilter struct { }
DocumentFilter denotes a document through properties like language, scheme or pattern. TODO: not sure this is useful...As I think this has to do with specific languages on the list
type DocumentFormattingParams ¶
type DocumentFormattingParams struct { TextDocument TextDocumentIdentifier `json:"textDocument"` Options FormattingOptions `json:"options"` }
DocumentFormattingParams is the params sent from the client for textDocument/formatting request
type DocumentURI ¶
type DocumentURI string
DocumentURI is the uri representation of the filepath, usually prefixed with "files://"
type FormattingOptions ¶
type FormattingOptions struct { TabSize int `json:"tabSize"` InsertSpaces bool `json:"insertSpaces"` Key string `json:"key"` }
FormattingOptions represent Value-object describing what options formatting should use.
type Hover ¶
type Hover struct { Contents []MarkedString `json:"contents"` Range *Range `json:"range,omitempty"` }
Hover is the result of a hover request.
type InitializeError ¶
type InitializeError struct { /** * Indicates whether the client execute the following retry logic: * (1) show the message provided by the ResponseError to the user * (2) user selects retry or cancel * (3) if user selected retry the initialize method is sent again. */ Retry bool `json:"retry"` }
InitializeError are known error code
type InitializeParams ¶
type InitializeParams struct { /** * The process Id of the parent process that started * the server. Is null if the process has not been started by another process. * If the parent process is not alive then the server should exit (see exit notification) its process. */ ProcessID int `json:"processId,omitempty"` /** * @deprecated in favour of rootUri. * having it here in case some lsp client still uses this field */ RootPath string `json:"rootPath,omitempty"` /** * The rootUri of the workspace. Is null if no * folder is open. If both `rootPath` and `rootUri` are set * `rootUri` wins. */ RootURI DocumentURI `json:"rootUri,omitempty"` /** * User provided initialization options. */ InitializationOptions interface{} `json:"initializationOptions,omitempty"` /** * The capabilities provided by the client (editor or tool) */ Capabilities ClientCapabilities `json:"capabilities"` /** * 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 are params passed into `initialize` method request
func (*InitializeParams) EnsureRoot ¶
func (p *InitializeParams) EnsureRoot() error
EnsureRoot sets the RootURI of the Intialization if not Set
func (*InitializeParams) Root ¶
func (p *InitializeParams) Root() DocumentURI
Root returns the RootURI if set, or otherwise the RootPath with 'file://' prepended.
type InitializeResult ¶
type InitializeResult struct { /** * The capabilities the language server provides. */ Capabilities ServerCapabilities `json:"capabilities"` }
InitializeResult is the response server sends to the client from "initialize" method
type InsertTextFormat ¶
type InsertTextFormat int
InsertTextFormat defines whether the insert text in a completion item should be interpreted as plain text or a snippet.
const ( // ITFPlainText The primary text to be inserted is treated as a plain string. ITFPlainText InsertTextFormat = 1 // ITFSnippet is the primary text to be inserted is treated as a snippet. ITFSnippet InsertTextFormat = 2 )
type Location ¶
type Location struct { URI DocumentURI `json:"uri"` Range Range `json:"range"` }
Location represents a location inside a resource, such as a line inside a text file.
type MarkedString ¶
MarkedString can be used to render human readable text. TODO(bnmetrics): this might not be needed anymore
type MarkupContent ¶
type MarkupContent struct { Kind MarkupKind `json:"kind"` Value string `json:"value"` }
MarkupContent represents a string value which content can be represented in different formats.
type MarkupKind ¶
type MarkupKind string
MarkupKind Describes the content type that a client supports in various result literals like `Hover`, `ParameterInfo` or `CompletionItem`. `MarkupKinds` must not start with a `$`
const ( PlainText MarkupKind = "plaintext" MarkDown MarkupKind = "markdown" )
Two types of MarkupKind
type ParameterInformation ¶
type ParameterInformation struct { Label string `json:"label"` Documentation string `json:"documentation,omitempty"` }
ParameterInformation represents a parameter of a callable-signature. A parameter can have a label and a doc-comment.
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 is the position in a text document expressed as zero-based line and zero-based character offset
type PublishDiagnosticsParams ¶
type PublishDiagnosticsParams struct { URI DocumentURI `json:"uri"` Diagnostics []*Diagnostic `json:"diagnostics"` }
PublishDiagnosticsParams is the params sent from the server to the client for textDocument/publishDiagnostics method
type Range ¶
type Range struct { /** * The range's start position. */ Start Position `json:"start"` /** * The range's end position. */ End Position `json:"end"` }
Range is A range in a text document expressed as (zero-based) start and end positions. A range is comparable to a selection in an editor
type ReferenceContext ¶
type ReferenceContext struct {
IncludeDeclaration bool `json:"includeDeclaration"`
}
ReferenceContext is the context used in ReferenceParams
type ReferenceParams ¶
type ReferenceParams struct { *TextDocumentPositionParams Context ReferenceContext `json:"context"` }
ReferenceParams is the params sent from the client for textDocument/references request
type RenameParams ¶
type RenameParams struct { TextDocument TextDocumentIdentifier `json:"textDocument"` Position Position `json:"position"` NewName string `json:"newName"` }
RenameParams is the params sent from the client for textDocument/rename request
type SaveOptions ¶
type SaveOptions struct { /** * The client is supposed to include the content on save. */ IncludeText bool `json:"includeText"` }
SaveOptions are the options for dealing with saving files
type ServerCapabilities ¶
type ServerCapabilities struct { /** * Defines how text documents are synced. Is either a detailed structure defining each notification or * for backwards compatibility the TextDocumentSyncKind number. If omitted it defaults to `TextDocumentSyncKind.None`. */ TextDocumentSync *TextDocumentSyncKind `json:"textDocumentSync,omitempty"` HoverProvider bool `json:"hoverProvider"` CompletionProvider *CompletionOptions `json:"completionProvider"` SignatureHelpProvider *SignatureHelpOptions `json:"signatureHelpProvider"` DefinitionProvider bool `json:"definitionProvider"` TypeDefinitionProvider bool `json:"typeDefinitionProvider,omitempty"` ImplementationProvider bool `json:"implementationProvider,omitempty"` ReferencesProvider bool `json:"referenceProvider,omitempty"` RenameProvider bool `json:"renameProvider,omitempty"` DocumentSymbolProvider bool `json:"documentSymbolProvider,omitempty"` DocumentHighlightProvider bool `json:"documentHighlightProvider,omitempty"` DocumentFormattingProvider bool `json:"documentFormattingProvider,omitempty"` }
ServerCapabilities Defines how text documents are synced.
type SignatureHelp ¶
type SignatureHelp struct { Signatures []SignatureInformation `json:"signatures"` ActiveSignature int `json:"activeSignature"` ActiveParameter int `json:"activeParameter"` }
SignatureHelp is the response from "textDocument/signatureHelp" represents the signature of something callable.
type SignatureHelpOptions ¶
type SignatureHelpOptions struct {
TriggerCharacters []string `json:"triggerCharacters,omitempty"`
}
SignatureHelpOptions indicate the server provides signature help support
type SignatureInformation ¶
type SignatureInformation struct { Label string `json:"label"` Documentation string `json:"documentation,omitempty"` Parameters []ParameterInformation `json:"parameters,omitempty"` }
SignatureInformation represents the signature of something callable.
type TextDocumentClientCapabilities ¶
type TextDocumentClientCapabilities struct {
Completion Completion `json:"completion, omitempty"`
}
TextDocumentClientCapabilities define capabilities the editor / tool provides on text documents. TODO: work out if this is being dynamically filled in
type TextDocumentContentChangeEvent ¶
type TextDocumentContentChangeEvent struct { Range *Range `json:"range,omitEmpty"` RangeLength uint `json:"rangeLength,omitEmpty"` Text string `json:"text"` }
TextDocumentContentChangeEvent 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.
type TextDocumentEdit ¶
type TextDocumentEdit struct { /** * The text document to change. */ TextDocument VersionedTextDocumentIdentifier `json:"textDocument"` Edits []TextEdit }
TextDocumentEdit describes all changes on a version Si and after they are applied move the document to version Si+1
type TextDocumentIdentifier ¶
type TextDocumentIdentifier struct { /** * The text document's URI. */ URI DocumentURI }
TextDocumentIdentifier contains the URL of the text document
type TextDocumentItem ¶
type TextDocumentItem struct { /** * The text document's URI. */ URI DocumentURI `json:"uri"` /** * The text document's language identifier. */ LanguageID string `json:"languageId"` /** * The version number of this document (it will strictly increase after each * change, including undo/redo). */ Version int `json:"version"` /** * The content of the opened text document. */ Text string `json:"text"` }
TextDocumentItem is an item to transfer a text document from the client to the server
type TextDocumentPositionParams ¶
type TextDocumentPositionParams struct { /** * The text document. */ TextDocument TextDocumentIdentifier `json:"textDocument"` /** * The 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
type TextDocumentSaveReason ¶
type TextDocumentSaveReason int
TextDocumentSaveReason Represents reasons why a text document is saved.
const ( Manual TextDocumentSaveReason = 1 AfterDelay TextDocumentSaveReason = 2 FocusOut TextDocumentSaveReason = 3 )
Represents reasons why a text document is saved.
type TextDocumentSyncKind ¶
type TextDocumentSyncKind int
TextDocumentSyncKind defines how the host (editor) should sync document changes to the language server.
const ( SyncNone TextDocumentSyncKind = 0 SyncFull TextDocumentSyncKind = 1 SyncIncremental TextDocumentSyncKind = 2 )
List of TextDocumentSyncKind mapped to respective integer values
type TextDocumentSyncOptions ¶
type TextDocumentSyncOptions struct { OpenClose bool `json:"openClose"` Change *TextDocumentSyncKind `json:"change"` WillSave bool `json:"willSave,omitempty"` WillSaveWaitUtil bool `json:"willSaveWaitUntil"` Save *SaveOptions `json:"save"` }
TextDocumentSyncOptions defines the open and close notifications are sent to the server. TODO(bnmetrics): this might not be needed
type TextEdit ¶
type TextEdit struct { /** * The range of the text document to be manipulated. To insert * text into a document create a range where start === end. */ Range Range `json:"range"` /** * The string to be inserted. For delete operations use an * empty string. */ NewText string `json:"newText"` }
TextEdit represents complex text manipulations are described with an array of TextEdit’s, representing a single change to the document.
type VersionedTextDocumentIdentifier ¶
type VersionedTextDocumentIdentifier struct { /** * Extending TextDocumentIdentifier */ *TextDocumentIdentifier Version int `json:"version"` }
VersionedTextDocumentIdentifier allow clients to check the text document version before an edit is applied
type WillSaveTextDocumentParams ¶
type WillSaveTextDocumentParams struct { TextDocument TextDocumentIdentifier `json:"textDocument"` Reason TextDocumentSaveReason `json:"reason,omitempty"` }
WillSaveTextDocumentParams is sent from the client to the server before the document is actually saved.
type WorkspaceClientCapabilities ¶
type WorkspaceClientCapabilities struct { }
WorkspaceClientCapabilities define capabilities the editor / tool provides on the workspace TODO(bnm): Not sure if this is needed, have it empty until I think of something
type WorkspaceEdit ¶
type WorkspaceEdit struct { /** * Holds changes to existing resources. */ Changes map[DocumentURI][]TextEdit `json:"changes"` /** * An array of `TextDocumentEdit`s to express changes to n different text documents * where each text document edit addresses a specific version of a text document. * Whether a client supports versioned document edits is expressed via * `WorkspaceClientCapabilities.workspaceEdit.documentChanges`. */ DocumentChanges []TextDocumentEdit `json:"documentChanges"` }
WorkspaceEdit epresents changes to many resources managed in the workspace.
type WorkspaceFolder ¶
type WorkspaceFolder struct { /** * The associated URI for this workspace folder. */ URI string `json:"uri"` /** * The name of the workspace folder. Defaults to the * uri's basename. */ Name string `json:"name"` }
WorkspaceFolder represents The workspace folders configured in the client when the server starts.