elvish-0.21.0/000077500000000000000000000000001465720375400131015ustar00rootroot00000000000000elvish-0.21.0/LICENSE000066400000000000000000000020611465720375400141050ustar00rootroot00000000000000MIT License Copyright (c) 2020 Nimble Bun Works Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. elvish-0.21.0/README.md000066400000000000000000000030101465720375400143520ustar00rootroot00000000000000# Language Server Protocol types for Go This is a module that contains type definitions and documentation for the [Language Server Protocol Specification][lsp-spec]. It aims to provide up-to-date and clear definitions to use in a language server. **LSP spec support:** 3.15, 3.16. ## Getting Started ``` go get pkg.nimblebun.works/go-lsp ``` Import it in your project: ```go import ( "pkg.nimblebun.works/go-lsp" ) ``` You can now use the types and constants defined in `lsp`. See the [documentation][docs-link] for more information. ## Disclaimer Our goal was to create an organized, easy to use, well-documented, and up-to-date LSP module for the Go programming language. To achieve this goal, we decided not to rely on automated tools to generate the Go types, but to write everything ourselves by hand. As a result, even though we tried to be as precise as possible, there could be typos in the definitions or the JSON names. If you notice a typo or bug, please report it in the [Issue Tracker][issues-link]! ## Future Plans Future plans for this module include designing a language server SDK, effectively making the module a swiss-army knife for creating language servers in Go easily. ## License MIT. Type declarations and documentations are taken from the [official specification document][lsp-spec]. [docs-link]: https://pkg.go.dev/pkg.nimblebun.works/go-lsp [issues-link]: https://github.com/nimblebun/go-lsp/issues [lsp-spec]: https://microsoft.github.io/language-server-protocol/specifications/specification-current elvish-0.21.0/call_hierarchy.go000066400000000000000000000060111465720375400163770ustar00rootroot00000000000000package lsp // CallHierarchyOptions specifies the options for settin up call hierarchy // support for a language server. type CallHierarchyOptions struct { WorkDoneProgressOptions } // CallHierarchyRegistrationOptions describes options to be used when // registering for call hierarchy capabilities. type CallHierarchyRegistrationOptions struct { TextDocumentRegistrationOptions CallHierarchyOptions StaticRegistrationOptions } // CallHierarchyPrepareParams contains the data the client sends through a // `textDocument/prepareCallHierarchy` request. type CallHierarchyPrepareParams struct { TextDocumentPositionParams WorkDoneProgressParams } // CallHierarchyItem represents a single item in the call hierarchy. type CallHierarchyItem struct { // The name of this item. Name string `json:"name"` // The kind of this item. Kind SymbolKind `json:"kind"` // Tags for this item. Tags []SymbolTag `json:"tags,omitempty"` // More detail for this item, e.g. the signature of a function. Detail string `json:"detail,omitempty"` // The resource identifier of this item. URI DocumentURI `json:"uri"` // The range enclosing this symbol not including leading/trailing whitespace // but everything else, e.g. comments and code. Range *Range `json:"range,omitempty"` // The range that should be selected and revealed when this symbol is being // picked, e.g. the name of a function. Must be contained by the // [`range`](#CallHierarchyItem.range). SelectionRange *Range `json:"selectionRange,omitempty"` // A data entry field that is preserved between a call hierarchy prepare and // incoming calls or outgoing calls requests. Data interface{} `json:"data,omitempty"` } // CallHierarchyIncomingCallsParams contains the data the client sends through a // `callHierarchy/incomingCalls` request. type CallHierarchyIncomingCallsParams struct { WorkDoneProgressParams PartialResultParams // The item that belongs to this call hierarchy incoming call. Item *CallHierarchyItem `json:"item"` } // CallHierarchyIncomingCall represents a single incoming call. type CallHierarchyIncomingCall struct { // The item that makes the call. From *CallHierarchyItem `json:"from"` // The ranges at which the calls appear. This is relative to the caller // denoted by [`this.from`](#CallHierarchyIncomingCall.from). FromRanges []*Range `json:"fromRanges,omitempty"` } // CallHierarchyOutgoingCallsParams contains the data the client sends through a // `callHierarchy/outgoingCalls` request. type CallHierarchyOutgoingCallsParams struct { WorkDoneProgressParams PartialResultParams // The item that belongs to this call hierarchy outgoing call. Item *CallHierarchyItem `json:"item"` } // CallHierarchyOutgoingCall represents a single outgoing call. type CallHierarchyOutgoingCall struct { // The item that is called. To *CallHierarchyItem `json:"to"` // The range at which this item is called. This is the range relative to // the caller, e.g the item passed to `callHierarchy/outgoingCalls` request. FromRanges []*Range `json:"fromRanges,omitempty"` } elvish-0.21.0/client_capabilities.go000066400000000000000000001050211465720375400174160ustar00rootroot00000000000000package lsp // DidChangeConfigurationClientCapabilities contains information about the // client's configuration change capabilities. type DidChangeConfigurationClientCapabilities struct { // Did change configuration notification supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` } // DidChangeWatchedFilesClientCapabilities contains information about the // client's file watcher change capabilities. type DidChangeWatchedFilesClientCapabilities struct { // Did change watched files notification supports dynamic registration. // Please note that the current protocol doesn't support static // configuration for file changes from the server side. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` } // WorkspaceEditClientCapabilities contains information about the client's // workspace edit capabilities. type WorkspaceEditClientCapabilities struct { // The client supports versioned document changes in `WorkspaceEdit`s DocumentChanges bool `json:"documentChanges,omitempty"` // The resource operations the client supports. Clients should at least // support 'create', 'rename' and 'delete' files and folders. ResourceOperations []ResourceOperationKind `json:"resourceOperations,omitempty"` // The failure handling strategy of a client if applying the workspace edit // fails. FailureHandling []FailureHandlingKind `json:"failureHandling,omitempty"` // Whether the client normalizes line endings to the client specific setting. // If set to `true` the client will normalize line ending characters in a // workspace edit to the client specific new line character(s). // // @since 3.16.0 NormalizesLineEndings bool `json:"normalizesLineEndings,omitempty"` // Whether the client in general supports change annotations on text edits, // create file, rename file and delete file changes. // // @since 3.16.0 ChangeAnnotationSupport struct { // Whether the client groups edits with equal labels into tree nodes, for // instance all edits labelled with "Changes in Strings" would be a tree // node. GroupsOnLabel bool `json:"groupsOnLabel,omitempty"` } `json:"changeAnnotationSupport,omitempty"` } // WorkspaceSymbolClientCapabilities contains information about the client's // workspace symbol capabilities. type WorkspaceSymbolClientCapabilities struct { // Symbol request supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` // Specific capabilities for the `SymbolKind` in the `workspace/symbol` // request. SymbolKind struct { ValueSet []SymbolKind `json:"valueSet,omitempty"` } `json:"symbolKind,omitempty"` // The client supports tags on `SymbolInformation`. // Clients supporting tags have to handle unknown tags gracefully. // // @since 3.16.0 TagSupport struct { ValueSet []SymbolTag `json:"valueSet,omitempty"` } `json:"tagSupport,omitempty"` } // ExecuteCommandClientCapabilities contains information about the client's // command execution capabilities. type ExecuteCommandClientCapabilities struct { // Execute command supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` } // TextDocumentSyncClientCapabilities contains information about the client's // text document sync capabilities. type TextDocumentSyncClientCapabilities struct { // Whether text document synchronization supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` // The client supports sending will save notifications. WillSave bool `json:"willSave,omitempty"` // 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"` // The client supports did save notifications. DidSave bool `json:"didSave,omitempty"` } // PublishDiagnosticsClientCapabilities contains information about the client's // diagnostics publishing capabilities. type PublishDiagnosticsClientCapabilities struct { // Whether the clients accepts diagnostics with related information. RelatedInformation bool `json:"relatedInformation,omitempty"` // Client supports the tag property to provide meta data about a diagnostic. // Clients supporting tags have to handle unknown tags gracefully. TagSupport struct { ValueSet []DiagnosticTag `json:"valueSet"` } `json:"tagSupport,omitempty"` // Whether the client interprets the version property of the // `textDocument/publishDiagnostics` notification's parameter. VersionSupport bool `json:"versionSupport,omitempty"` // Client supports a codeDescription property // // @since 3.16.0 CodeDescriptionSupport bool `json:"codeDescriptionSupport,omitempty"` // Whether code action supports the `data` property which is // preserved between a `textDocument/publishDiagnostics` and // `textDocument/codeAction` request. // // @since 3.16.0 DataSupport bool `json:"dataSupport,omitempty"` } // CompletionClientCapabilities contains information about the client's // completion capabilities. type CompletionClientCapabilities struct { // Whether completion supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` // The client supports the following `CompletionItem` specific capabilities. CompletionItem struct { // 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, so that typing in // one will update others as well. SnippetSupport bool `json:"snippetSupport,omitempty"` // Client supports commit characters on a completion item. CommitCharactersSupport bool `json:"commitCharactersSupport,omitempty"` // Client supports the follow content formats for the documentation // property. The order describes the preferred format of the client. DocumentationFormat []MarkupKind `json:"documentationFormat,omitempty"` // Client supports the deprecated property on a completion item. DeprecatedSupport bool `json:"deprecatedSupport,omitempty"` // Client supports the preselect property on a completion item. PreselectSupport bool `json:"preselectSupport,omitempty"` // Client supports the tag property on a completion item. // Clients supporting tags have to handle unknown tags gracefully. // Clients especially need to preserve unknown tags when sending // a completion item back to the server in a resolve call. TagSupport struct { // The tags supported by the client. ValueSet []CompletionItemTag `json:"valueSet"` } `json:"tagSupport,omitempty"` // Client supports insert replace edit to control different behavior if a // completion item is inserted in the text or should replace text. // // @since 3.16.0 InsertReplaceSupport bool `json:"insertReplaceSupport,omitempty"` // Indicates which properties a client can resolve lazily on a completion // item. Before version 3.16.0 only the predefined properties // `documentation` and `detail` could be resolved lazily. // // @since 3.16.0 ResolveSupport struct { // The properties that a client can resolve lazily. Properties []string `json:"properties"` } `json:"resolveSupport,omitempty"` // The client supports the `insertTextMode` property on a completion item to // override the whitespace handling mode as defined by the client. // // @since 3.16.0 InsertTextModeSupport struct { ValueSet []InsertTextMode `json:"valueSet"` } `json:"insertTextModeSupport,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 { // The completion item kinds supported by the client. ValueSet []CompletionItemKind `json:"valueSet,omitempty"` } `json:"completionItemKind,omitempty"` // The client supports to send additional context information for a // `textDocument/completion` request. ContextSupport bool `json:"contextSupport,omitempty"` } // HoverClientCapabilities contains information about the client's hover // capabilities. type HoverClientCapabilities struct { // Whether hover supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` // Client supports the follow content formats for the content property. The // order describes the preferred format of the client. ContentFormat []MarkupKind `json:"contentFormat,omitempty"` } // SignatureHelpClientCapabilities contains information about the client's // signature help capabilities. type SignatureHelpClientCapabilities struct { // Whether signature help supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` // The client supports the following `SignatureInformation` specific // properties. SignatureInformation struct { // Client supports the follow content formats for the documentation // property. The order describes the preferred format of the client. DocumentationFormat []MarkupKind `json:"documentationFormat,omitempty"` // Client capabilities specific to parameter information. ParameterInformation struct { // The client supports processing label offsets instead of a simple label // string. LabelOffsetSupport bool `json:"labelOffsetSupport,omitempty"` } `json:"parameterInformation,omitempty"` // The client supports the `activeParameter` property on // `SignatureInformation` literal. // // @since 3.16.0 ActiveParameterSupport bool `json:"activeParameterSupport,omitempty"` } `json:"signatureInformation,omitempty"` // The client supports to send additional context information for a // `textDocument/signatureHelp` request. A client that opts into // contextSupport will also support the `retriggerCharacters` on // `SignatureHelpOptions`. ContextSupport bool `json:"contextSupport,omitempty"` } // DeclarationClientCapabilities contains information about the client's // go-to-declaration capabilities. type DeclarationClientCapabilities struct { // Whether declaration supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` // The client supports additional metadata in the form of declaration links. LinkSupport bool `json:"linkSupport,omitempty"` } // DefinitionClientCapabilities contains information about the client's // go-to-definition capabilities. type DefinitionClientCapabilities struct { // Whether definition supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` // The client supports additional metadata in the form of definition links. LinkSupport bool `json:"linkSupport,omitempty"` } // TypeDefinitionClientCapabilities contains information about the client's // go-to-type-definition capabilities. type TypeDefinitionClientCapabilities struct { // Whether type definition supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` // The client supports additional metadata in the form of definition links. LinkSupport bool `json:"linkSupport,omitempty"` } // ImplementationClientCapabilities contains information about the client's // go-to-implementation capabilities. type ImplementationClientCapabilities struct { // Whether implementation supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` // The client supports additional metadata in the form of definition links. LinkSupport bool `json:"linkSupport,omitempty"` } // ReferenceClientCapabilities contains information about the client's find // references capabilities. type ReferenceClientCapabilities struct { // Whether references support dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` } // DocumentHighlightClientCapabilities contains information about the client's // document highlight capabilities. type DocumentHighlightClientCapabilities struct { // Whether document highlight supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` } // DocumentSymbolClientCapabilities contains information about the client's // document symbol capabilities. type DocumentSymbolClientCapabilities struct { // Whether document symbol supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` // Specific capabilities for the `SymbolKind` in the // `textDocument/documentSymbol` request. SymbolKind struct { // The symbol 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 symbol kinds from `File` to `Array` as defined in // the initial version of the protocol. ValueSet []SymbolKind `json:"valueSet,omitempty"` } `json:"symbolKind,omitempty"` // The client supports hierarchical document symbols. // // @since 3.16.0 HierarchicalDocumentSymbolSupport bool `json:"hierarchicalDocumentSymbolSupport,omitempty"` // The client supports tags on `SymbolInformation`. Tags are supported on // `DocumentSymbol` if `hierarchicalDocumentSymbolSupport` is set to true. // Clients supporting tags have to handle unknown tags gracefully. // // @since 3.16.0 TagSupport struct { // The tags supported by the client. ValueSet []SymbolTag } `json:"tagSupport,omitempty"` // The client supports an additional label presented in the UI when // registering a document symbol provider. // // @since 3.16.0 LabelSupport bool `json:"labelSupport,omitempty"` } // DocumentLinkClientCapabilities contains information about the client's // document link capabilities. type DocumentLinkClientCapabilities struct { // Whether document link supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` // Whether the client supports the `tooltip` property on `DocumentLink`. TooltipSupport bool `json:"tooltipSupport,omitempty"` } // DocumentColorClientCapabilities contains information about the client's // document color capabilities. type DocumentColorClientCapabilities struct { // Whether document color supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` } // DocumentFormattingClientCapabilities contains information about the client's // document formatting capabilities. type DocumentFormattingClientCapabilities struct { // Whether document formatting supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` } // DocumentRangeFormattingClientCapabilities contains information about the // client's document formatting capabilities. type DocumentRangeFormattingClientCapabilities struct { // Whether document formatting supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` } // DocumentOnTypeFormattingClientCapabilities contains information about the // client's document on-type formatting capabilities. type DocumentOnTypeFormattingClientCapabilities struct { // Whether on-type formatting supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` } // PrepareSupportDefaultBehavior indicates the default behavior for the client's // prepare support. // // @since 3.16.0 type PrepareSupportDefaultBehavior int const ( // PSDefaultBehaviorIdentifier means the client's default behavior is to // select the identifier according the to language's syntax rule. PSDefaultBehaviorIdentifier PrepareSupportDefaultBehavior = iota + 1 ) // RenameClientCapabilities contains information about the client's file rename // capabilities. type RenameClientCapabilities struct { // Whether rename supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` // Client supports testing for validity of rename operations before execution. PrepareSupport bool `json:"prepareSupport,omitempty"` // Client supports the default behavior result // (`{ defaultBehavior: boolean }`). // // The value indicates the default behavior used by the client. // // @since 3.16.0 PrepareSupportDefaultBehavior PrepareSupportDefaultBehavior `json:"prepareSupportDefaultBehavior,omitempty"` // Whether the client honors the change annotations in text edits and resource // operations returned via the rename request's workspace edit by for example // presenting the workspace edit in the user interface and asking for // confirmation. // // @since 3.16.0 HonorsChangeAnnotations bool `json:"honorsChangeAnnotations,omitempty"` } // FoldingRangeClientCapabilities contains information about the client's // folding range provider capabilities. type FoldingRangeClientCapabilities struct { // Whether the implementation supports dynamic registration for folding range // providers. // If this is set to `true`, the client supports the new // `FoldingRangeRegistrationOptions` return value for the corresponding // server capability as well. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` // The maximum number of folding ranges that the client prefers to // receive per document. // The value serves as a hint, servers are free to follow the limit. RangeLimit int `json:"rangeLimit,omitempty"` // If set, the client signals that it only supports folding complete lines. // If set, the client will ignore specified `startCharacter` and // `endCharacter` properties in a FoldingRange. LineFoldingOnly bool `json:"lineFoldingOnly,omitempty"` } // SelectionRangeClientCapabilities contains information about the client's // selection range provider capabilities. type SelectionRangeClientCapabilities struct { // Whether implementation supports dynamic registration for selection // range providers. // If set to `true`, the client supports the new // `SelectionRangeRegistrationOptions` return value for the corresponding // server capability as well. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` } // CodeActionClientCapabilities contains information about the client's code // action capabilities. type CodeActionClientCapabilities struct { // Whether code action supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` // The client supports code action literals as a valid // response of the `textDocument/codeAction` request. CodeActionLiteralSupport struct { // The code action kind is supported with the following value set. CodeActionKind struct { // The code action 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. ValueSet []CodeActionKind `json:"valueSet"` } `json:"codeActionKind,omitempty"` } `json:"codeActionLiteralSupport,omitempty"` // Whether code action supports the `isPreferred` property. IsPreferredSupport bool `json:"isPreferredSupport,omitempty"` // Whether code action supports the `disabled` property. // // @since 3.16.0 DisabledSupport bool `json:"disabledSupport,omitempty"` // Whether code action supports the `data` property which is preserved between // a `textDocument/codeAction` and a `codeAction/resolve` request. // // @since 3.16.0 DataSupport bool `json:"dataSupport,omitempty"` // Whether the client supports resolving additional code action properties via // a separate `codeAction/resolve` request. // // @since 3.16.0 ResolveSupport struct { // The properties that a client can resolve lazily. Properties []string `json:"properties"` } `json:"resolveSupport,omitempty"` // Whether the client honors the change annotations in text edits and resource // operations returned via the `CodeAction#edit` property by for example // presenting the workspace edit in the user interface and asking for // confirmation. // // @since 3.16.0 HonorsChangeAnnotations bool `json:"honorsChangeAnnotations,omitempty"` } // CodeLensClientCapabilities contains information about the client's CodeLens // capabilities. type CodeLensClientCapabilities struct { // Whether CodeLens supports dynamic registration. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` } // Client capabilities specific to the used markdown parser. // // @since 3.16.0 type MarkdownClientCapabilities struct { // The name of the parser. Parser string `json:"parser"` // The version of the parser. Version string `json:"version,omitempty"` } // Client capabilities specific to regular expressions. // // @since 3.16.0 type RegularExpressionsClientCapabilities struct { // The name of the engine. Engine string `json:"engine"` // The version of the engine. Version string `json:"version,omitempty"` } // CodeLensWorkspaceCapabilities contains information about the client's // workspace CodeLens capabilities. // // @since 3.16.0 type CodeLensWorkspaceClientCapabilities struct { // Whether the client implementation supports a refresh request sent from the // server to the client. // // Note that this event is global and will force the client to refresh all // code lenses currently shown. It should be used with absolute care and is // useful for situation where a server for example detect a project wide // change that requires such a calculation. RefreshSupport bool `json:"refreshSupport,omitempty"` } // LinkedEditingRangeClientCapabilities contains information about the client's // linked editing range capabilities. // // @since 3.16.0 type LinkedEditingRangeClientCapabilities struct { // Whether implementation supports dynamic registration. // If this is set to `true` the client supports the new // `(TextDocumentRegistrationOptions & StaticRegistrationOptions)` // return value for the corresponding server capability as well. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` } // CallHierarchyClientCapabilities contains information about the client's // call hierarchy capabilities. // // @since 3.16.0 type CallHierarchyClientCapabilities struct { // Whether implementation supports dynamic registration. If this is set to // `true` the client supports the new `(TextDocumentRegistrationOptions & // StaticRegistrationOptions)` return value for the corresponding server // capability as well. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` } // SemanticTokensClientCapabilities contains information about the client's // semantic tokens capabilities. // // @since 3.16.0 type SemanticTokensClientCapabilities struct { // Whether implementation supports dynamic registration. If this is set to // `true` the client supports the new `(TextDocumentRegistrationOptions & // StaticRegistrationOptions)` return value for the corresponding server // capability as well. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` // Which requests the client supports and might send to the server // depending on the server's capability. Please note that clients might not // show semantic tokens or degrade some of the user experience if a range // or full request is advertised by the client but not provided by the // server. If for example the client capability `requests.full` and // `request.range` are both set to true but the server only provides a // range provider the client might not render a minimap correctly or might // even decide to not show any semantic tokens at all. Requests struct { // The client will send the `textDocument/semanticTokens/range` request // if the server provides a corresponding handler. Range bool `json:"range,omitempty"` // The client will send the `textDocument/semanticTokens/full` request // if the server provides a corresponding handler. Full *struct { // The client will send the `textDocument/semanticTokens/full/delta` // request if the server provides a corresponding handler. Delta bool `json:"delta,omitempty"` } `json:"full,omitempty"` } `json:"requests"` // The token types that the client supports TokenTypes []SemanticTokenType `json:"tokenTypes"` // The token modifiers that the client supports. TokenModifiers []SemanticTokenModifiers `json:"tokenModifiers"` // The formats the clients supports. Formats []TokenFormat `json:"formats"` // Whether the client supports tokens that can overlap each other. OverlappingTokenSupport bool `json:"overlappingTokenSupport,omitempty"` // Whether the client supports tokens that can span multiple lines. MultilineTokenSupport bool `json:"multilineTokenSupport,omitempty"` } // SemanticTokensWorkspaceClientCapabilities contains information about the // client's semantic tokens workspace capabilities. // // @since 3.16.0 type SemanticTokensWorkspaceClientCapabilities struct { // Whether the client implementation supports a refresh request sent from // the server to the client. // // Note that this event is global and will force the client to refresh all // semantic tokens currently shown. It should be used with absolute care // and is useful for situation where a server for example detect a project // wide change that requires such a calculation. RefreshSupport bool `json:"refreshSupport,omitempty"` } // MonikerClientCapabilities contains information about the client's moniker // capabilities. // // @since 3.16.0 type MonikerClientCapabilities struct { // Whether implementation supports dynamic registration. If this is set to // `true` the client supports the new `(TextDocumentRegistrationOptions & // StaticRegistrationOptions)` return value for the corresponding server // capability as well. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` } // ShowMessageRequestClientCapabilities contains information about the client's // show message request capabilities. // // @since 3.16.0 type ShowMessageRequestClientCapabilities struct { // Capabilities specific to the `MessageActionItem` type. MessageActionItem *struct { // Whether the client supports additional attributes which are preserved and // sent back to the server in the request's response. AdditionalPropertiesSupport bool `json:"additionalPropertiesSupport,omitempty"` } `json:"messageActionItem"` } // ShowDocumentClientCapabilities contains information about the client's // show document capabilities. // // @since 3.16.0 type ShowDocumentClientCapabilities struct { // The client has support for the show document request. Support bool `json:"support"` } // TextDocumentClientCapabilities define capabilities the editor / tool provides // on text documents. type TextDocumentClientCapabilities struct { Synchronization *TextDocumentSyncClientCapabilities `json:"synchronization,omitempty"` // Capabilities specific to the `textDocument/completion` request. Completion *CompletionClientCapabilities `json:"completion,omitempty"` // Capabilities specific to the `textDocument/hover` request. Hover *HoverClientCapabilities `json:"hover,omitempty"` // Capabilities specific to the `textDocument/signatureHelp` request. SignatureHelp *SignatureHelpClientCapabilities `json:"signatureHelp,omitempty"` // Capabilities specific to the `textDocument/declaration` request. Declaration *DeclarationClientCapabilities `json:"declaration,omitempty"` // Capabilities specific to the `textDocument/definition` request. Definition *DefinitionClientCapabilities `json:"definition,omitempty"` // Capabilities specific to the `textDocument/typeDefinition` request. TypeDefinition *TypeDefinitionClientCapabilities `json:"typeDefinition,omitempty"` // Capabilities specific to the `textDocument/implementation` request. Implementation *ImplementationClientCapabilities `json:"implementation,omitempty"` // Capabilities specific to the `textDocument/references` request. References *ReferenceClientCapabilities `json:"references,omitempty"` // Capabilities specific to the `textDocument/documentHighlight` request. DocumentHighlight *DocumentHighlightClientCapabilities `json:"documentHighlight,omitempty"` // Capabilities specific to the `textDocument/documentSymbol` request. DocumentSymbol *DocumentSymbolClientCapabilities `json:"documentSymbol,omitempty"` // Capabilities specific to the `textDocument/codeAction` request. CodeAction *CodeActionClientCapabilities `json:"codeAction,omitempty"` // Capabilities specific to the `textDocument/codeLens` request. CodeLens *CodeLensClientCapabilities `json:"codeLens,omitempty"` // Capabilities specific to the `textDocument/documentLink` request. DocumentLink *DocumentLinkClientCapabilities `json:"documentLink,omitempty"` // Capabilities specific to the `textDocument/documentColor` and the // `textDocument/colorPresentation` request. ColorProvider *DocumentColorClientCapabilities `json:"colorProvider,omitempty"` // Capabilities specific to the `textDocument/formatting` request. Formatting *DocumentFormattingClientCapabilities `json:"formatting,omitempty"` // Capabilities specific to the `textDocument/rangeFormatting` request. RangeFormatting *DocumentRangeFormattingClientCapabilities `json:"rangeFormatting,omitempty"` // Capabilities specific to the `textDocument/onTypeFormatting` request. OnTypeFormatting *DocumentOnTypeFormattingClientCapabilities `json:"onTypeFormatting,omitempty"` // Capabilities specific to the `textDocument/rename` request. Rename *RenameClientCapabilities `json:"rename,omitempty"` // Capabilities specific to the `textDocument/publishDiagnostics` notification PublishDiagnostics *PublishDiagnosticsClientCapabilities `json:"publishDiagnostics,omitempty"` // Capabilities specific to the `textDocument/foldingRange` request. FoldingRange *FoldingRangeClientCapabilities `json:"foldingRange,omitempty"` // Capabilities specific to the `textDocument/selectionRange` request. SelectionRange *SelectionRangeClientCapabilities `json:"selectionRange,omitempty"` // Capabilities specific to the `textDocument/linkedEditingRange` request. // // @since 3.16.0 LinkedEditingRange *LinkedEditingRangeClientCapabilities `json:"linkedEditingRange,omitempty"` // Capabilities specific to the various call hierarchy requests. // // @since 3.16.0 CallHierarchy *CallHierarchyClientCapabilities `json:"callHierarchy,omitempty"` // Capabilities specific to the various semantic token requests. // // @since 3.16.0 SemanticTokens *SemanticTokensClientCapabilities `json:"semanticTokens,omitempty"` // Capabilities specific to the `textDocument/moniker` request. // // @since 3.16.0 Moniker *MonikerClientCapabilities `json:"moniker,omitempty"` } // ClientCapabilities defines workspace-specific client capabilities. type ClientCapabilities struct { // Workspace specific client capabilities. Workspace *struct { // The client supports applying batch edits // to the workspace by supporting the request // 'workspace/applyEdit' ApplyEdit bool `json:"applyEdit,omitempty"` // Capabilities specific to `WorkspaceEdit`s WorkspaceEdit *WorkspaceEditClientCapabilities `json:"workspaceEdit,omitempty"` // Capabilities specific to the `workspace/didChangeConfiguration` // notification. DidChangeConfiguration *DidChangeConfigurationClientCapabilities `json:"didChangeConfiguration,omitempty"` // Capabilities specific to the `workspace/didChangeWatchedFiles` // notification. DidChangeWatchedFiles *DidChangeWatchedFilesClientCapabilities `json:"didChangeWatchedFiles,omitempty"` // Capabilities specific to the `workspace/symbol` request. Symbol *WorkspaceSymbolClientCapabilities `json:"symbol,omitempty"` // Capabilities specific to the `workspace/executeCommand` request. ExecuteCommand *ExecuteCommandClientCapabilities `json:"executeCommand,omitempty"` // The client has support for workspace folders. WorkspaceFolders bool `json:"workspaceFolders,omitempty"` // The client supports `workspace/configuration` requests. Configuration bool `json:"configuration,omitempty"` // Capabilities specific to the semantic token requests scoped to the // workspace. // // @since 3.16.0 SemanticTokens *SemanticTokensWorkspaceClientCapabilities `json:"semanticTokens,omitempty"` // Capabilities specific to the code lens requests scoped to the // workspace. // // @since 3.16.0 CodeLens *CodeLensWorkspaceClientCapabilities `json:"codeLens,omitempty"` // The client has support for file requests/notifications. // // @since 3.16.0 FileOperations *struct { // Whether the client supports dynamic registration for file requests or // notifications. DynamicRegistration bool `json:"dynamicRegistration,omitempty"` // The client has support for sending didCreateFiles notifications. DidCreate bool `json:"didCreate,omitempty"` // The client has support for sending willCreateFiles requests. WillCreate bool `json:"willCreate,omitempty"` // The client has support for sending didRenameFiles notifications. DidRename bool `json:"didRename,omitempty"` // The client has support for sending willRenameFiles requests. WillRename bool `json:"willRename,omitempty"` // The client has support for sending didDeleteFiles notifications. DidDelete bool `json:"didDelete,omitempty"` // The client has support for sending willDeleteFiles requests. WillDelete bool `json:"willDelete,omitempty"` } `json:"fileOperations,omitempty"` } `json:"workspace,omitempty"` // Text document specific client capabilities. TextDocument *TextDocumentClientCapabilities `json:"textDocument,omitempty"` // Window specific client capabilities. Window *struct { // Whether client supports handling progress notifications. // If set, servers are allowed to report in `workDoneProgress` property // in the request specific server capabilities. WorkDoneProgress bool `json:"workDoneProgress,omitempty"` // Capabilities specific to the showMessage request // // @since 3.16.0 ShowMessage *ShowMessageRequestClientCapabilities `json:"showMessage,omitempty"` // Client capabilities for the show document request. // // @since 3.16.0 ShowDocument *ShowDocumentClientCapabilities `json:"showDocument,omitempty"` } `json:"window,omitempty"` // General client capabilities. // // @since 3.16.0 General *struct { // Client capabilities specific to regular expressions. // // @since 3.16.0 RegularExpressions *RegularExpressionsClientCapabilities `json:"regularExpressions,omitempty"` // Client capabilities specific to the client's markdown parser. // // @since 3.16.0 Markdown *MarkdownClientCapabilities `json:"markdown,omitempty"` } `json:"general,omitempty"` // Experimental client capabilities. Experimental interface{} `json:"experimental,omitempty"` } elvish-0.21.0/codelens.go000066400000000000000000000025371465720375400152330ustar00rootroot00000000000000package lsp // CodeLens represents a command that should be shown along with // source text, like the number of references, a way to run tests, etc. // // A CodeLens is _unresolved_ when no command is associated to it. // For performance reasons, the creation of a CodeLens and resolving should // be done in two stages. type CodeLens struct { // The range in which the CodeLens is valid. Should only span a single line. Range Range `json:"range"` // The command this CodeLens represents. Command Command `json:"command,omitempty"` // A data entry field that is preserved on a CodeLens item between // a CodeLens and a CodeLens resolve request. Data interface{} `json:"data,omitempty"` } // CodeLensOptions contains the options for the CodeLens handler. type CodeLensOptions struct { WorkDoneProgressOptions // Code lens has a resolve provider as well. ResolveProvider bool `json:"resolveProvider,omitempty"` } // CodeLensRegistrationOptions contains the options for the CodeLens handler // registration. type CodeLensRegistrationOptions struct { TextDocumentRegistrationOptions CodeLensOptions } // CodeLensParams contains the fields sent in a `textDocument/codeLens` request. type CodeLensParams struct { WorkDoneProgressParams PartialResultParams // The document to request CodeLens for. TextDocument TextDocumentIdentifier `json:"textDocument"` } elvish-0.21.0/command.go000066400000000000000000000163721465720375400150570ustar00rootroot00000000000000package lsp // 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. The recommended way to handle commands is to implement their // execution on the server side if the client and server provides the // corresponding capabilities. Alternatively the tool extension code could // handle the command. The protocol currently doesn’t specify a set of // well-known commands. 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"` } // ExecuteCommandOptions contains the options for the command execution handler. type ExecuteCommandOptions struct { WorkDoneProgressOptions // The commands to be executed on the server. Commands []string `json:"commands"` } // ExecuteCommandRegistrationOptions contains the command execution registration // options. type ExecuteCommandRegistrationOptions struct { ExecuteCommandOptions } // ExecuteCommandParams contains the fields sent in a `workspace/executeCommand` // request. type ExecuteCommandParams struct { WorkDoneProgressParams // The identifier of the actual command handler. Command string `json:"command"` // Arguments that the command should be invoked with. Arguments interface{} `json:"arguments,omitempty"` } // CodeActionKind defines a set of predefined code action kinds. type CodeActionKind string const ( // CAKEmpty defines an empty kind. CAKEmpty CodeActionKind = "" // CAKQuickFix is the base kind for quickfix actions: 'quickfix'. CAKQuickFix = "quickfix" // CAKRefactor is the base kind for refactoring actions: 'refactor'. CAKRefactor = "refactor" // CAKRefactorExtract is the base kind for refactoring extraction actions: // 'refactor.extract'. // // Example extract actions: // - Extract method // - Extract function // - Extract variable // - Extract interface from class // - ... CAKRefactorExtract = "refactor.extract" // CAKRefactorInline is the base kind for refactoring inline actions: // 'refactor.inline'. // // Example inline actions: // // - Inline function // - Inline variable // - Inline constant // - ... CAKRefactorInline = "refactor.inline" // CAKRefactorRewrite is the base kind for refactoring rewrite actions: // 'refactor.rewrite'. // // Example rewrite actions: // // - Convert JavaScript function to class // - Add or remove parameter // - Encapsulate field // - Make method static // - Move method to base class // - ... CAKRefactorRewrite = "refactor.rewrite" // CAKSource is the base kind for source actions: `source`. // // Source code actions apply to the entire file. CAKSource = "source" // CAKSourceOrganizeImports is the base kind for an organize imports source // action `source.organizeImports`. CAKSourceOrganizeImports = "source.organizeImports" ) // CodeActionContext contains additional diagnostic information about the // context in which a code action is run. type CodeActionContext struct { // An array of diagnostics known on the client side overlapping the range // provided to the `textDocument/codeAction` request. // They are provided so that the server knows which errors are currently // presented to the user for the given range. There is no guarantee that // these accurately reflect the error state of the resource. // The primary parameter to compute code actions is the provided range. Diagnostics []Diagnostic `json:"diagnostics"` // Requested kind of actions to return. // // Actions not of this kind are filtered out by the client before // being shown, so servers can omit computing them. Only []CodeActionKind `json:"only,omitempty"` } // CodeAction represents a change that can be performed in code. // For example, to fix a problem or to refactor code. // // A CodeAction must set either `edit` and/or a `command`. // If both are supplied, the `edit` is applied first, then the `command` // is executed. type CodeAction struct { // A short, human-readable, title for this code action. Title string `json:"title"` // The kind of the code action. Used to filter code actions. Kind CodeActionKind `json:"kind,omitempty"` // The diagnostics that this code action resolves. Diagnostics []Diagnostic `json:"diagnostics,omitempty"` // Marks this as a preferred action. // Preferred actions are used by the `auto fix` command and can be // targeted by keybindings. // // A quick fix should be marked preferred if it properly addresses the // underlying error. // A refactoring should be marked preferred if it is the most reasonable // choice of actions to take. IsPreferred bool `json:"isPreferred,omitempty"` // Marks that the code action cannot currently be applied. // // Clients should follow the following guidelines regarding disabled code // actions: // // - Disabled code actions are not shown in automatic lightbulbs code // action menus. // // - Disabled actions are shown as faded out in the code action menu when // the user request a more specific type of code action, such as // refactorings. // // - If the user has a keybinding that auto applies a code action and only // a disabled code actions are returned, the client should show the user // an error message with `reason` in the editor. // // @since 3.16.0 Disabled struct { // Human readable description of why the code action is currently disabled. // // This is displayed in the code actions UI. Reason string `json:"reason"` } `json:"disabled,omitempty"` // The workspace edit this code action performs. Edit WorkspaceEdit `json:"edit,omitempty"` // A command this code action executes. If a code action // provides an edit and a command, first the edit is // executed and then the command. Command Command `json:"command,omitempty"` // A data entry field that is preserved on a code action between a // `textDocument/codeAction` and a `codeAction/resolve` request. // // @since 3.16.0 Data interface{} `json:"data,omitempty"` } // CodeActionOptions contains the options for the code action handler. type CodeActionOptions struct { WorkDoneProgressOptions // CodeActionKinds that this server may return. // // The list of kinds may be generic, such as `CodeActionKind.Refactor`, // or the server may list out every specific kind they provide. CodeActionKinds []CodeActionKind `json:"codeActionKinds,omitempty"` // The server provides support to resolve additional information for a code // action. // // @since 3.16.0 ResolveProvider bool `json:"resolveProvider,omitempty"` } // CodeActionRegistrationOptions contains the options for the code action // handler registration. type CodeActionRegistrationOptions struct { TextDocumentRegistrationOptions CodeActionOptions } // CodeActionParams contains the fields sent in a `textDocument/codeAction` // request. type CodeActionParams struct { WorkDoneProgressParams PartialResultParams // The document in which the command was invoked. TextDocument TextDocumentIdentifier `json:"textDocument"` // The range for which the command was invoked. Range Range `json:"range"` // Context carrying additional information. Context CodeActionContext `json:"context"` } elvish-0.21.0/common.go000066400000000000000000000036211465720375400147220ustar00rootroot00000000000000package lsp // URI is a generic unique resource identifier. type URI string // CancelParams contains the parameters of the `$/cancelRequest` method. type CancelParams struct { // The request ID to cancel. ID ID `json:"id"` } // StaticRegistrationOptions can be used to register a feature in the initialize // result with a given server control ID to be able to un-register the feature // later on. type StaticRegistrationOptions struct { // The id used to register the request. The id can be used to deregister // the request again. See also Registration#id. ID string `json:"id,omitempty"` } // TextDocumentRegistrationOptions denotes options to dynamically register for // requests for a set of text documents type TextDocumentRegistrationOptions struct { // A document selector to identify the scope of the registration. // If not provided, the document selector provided on the client side // will be used. DocumentSelector DocumentSelector `json:"documentSelector,omitempty"` } // MarkupKind describes the content type that a client supports in various // result literals like `Hover`, `ParameterInfo` or `CompletionItem`. type MarkupKind string const ( // MKPlainText denotes that plaintext is supported as a content format. MKPlainText MarkupKind = "plaintext" // MKMarkdown denotes that markdown is supported as a content format. MKMarkdown = "markdown" ) // MarkupContent represents a string value, which content is interpreted based // on its kind flag. type MarkupContent struct { // The type of the Markup. Kind MarkupKind `json:"kind"` // The content itself. Value string `json:"value"` } // PartialResultParams is a parameter literal used to pass a partial result // token. type PartialResultParams struct { // An optional token that a server can use to report partial results // (for example, streaming) to the client. PartialResultToken ProgressToken `json:"partialResultToken,omitempty"` } elvish-0.21.0/completion.go000066400000000000000000000303031465720375400156000ustar00rootroot00000000000000package lsp // CompletionTriggerKind specifies how a completion was triggered. type CompletionTriggerKind int const ( // CTKInvoked means the completion was triggered by typing an identifier // (24x7 code complete), manual invocation (e.g Ctrl+Space) or via API. CTKInvoked CompletionTriggerKind = iota + 1 // CTKTriggerCharacter means the completion was triggered by a trigger // character specified by the `triggerCharacters` properties of // `CompletionRegistrationOptions`. CTKTriggerCharacter // CTKTriggerForIncompleteCompletions means the completion was re-triggered as // the current completion list is incomplete. CTKTriggerForIncompleteCompletions ) func (ctk CompletionTriggerKind) String() string { switch ctk { case CTKInvoked: return "invoked" case CTKTriggerCharacter: return "trigger character" case CTKTriggerForIncompleteCompletions: return "trigger for incomplete completions" } return "" } // CompletionContext contains additional information about the context in which // a completion request is triggered. type CompletionContext struct { // How the completion was triggered. TriggerKind CompletionTriggerKind `json:"triggerKind"` // The trigger character (single character) that has trigger code complete. // Is undefined if `TriggerKind != CTKTriggerCharacter TriggerCharacter string `json:"triggerCharacter,omitempty"` } // InsertTextFormat defines whether the insert text in a completion item should // be interpreted as plain text or a snippet. type InsertTextFormat int const ( // ITFPlainText means the primary text to be inserted is treated as a plain // string. ITFPlainText InsertTextFormat = iota + 1 // ITFSnippet means the primary text to be inserted is treated as a snippet. // // 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. ITFSnippet ) func (itf InsertTextFormat) String() string { switch itf { case ITFPlainText: return "plain text" case ITFSnippet: return "snippet" } return "" } // CompletionItemTag defines extra annotations that tweak the rendering of a // completion item. type CompletionItemTag int // CITDeprecated will render a completion as obsolete, usually using a // strike-out . const CITDeprecated CompletionItemTag = 1 // CompletionItemKind specifies the type of a completion. type CompletionItemKind int const ( // CIKText represents a text completion item kind. CIKText CompletionItemKind = iota + 1 // CIKMethod represents a method completion item kind. CIKMethod // CIKFunction represents a function completion item kind. CIKFunction // CIKConstructor represents a constructor completion item kind. CIKConstructor // CIKField represents a field completion item kind. CIKField // CIKVariable represents a variable completion item kind. CIKVariable // CIKClass represents a class completion item kind. CIKClass // CIKInterface represents an interface completion item kind. CIKInterface // CIKModule represents a module completion item kind. CIKModule // CIKProperty represents a property completion item kind. CIKProperty // CIKUnit represents a unit completion item kind. CIKUnit // CIKValue represents a value completion item kind. CIKValue // CIKEnum represents an enum completion item kind. CIKEnum // CIKKeyword represents a keyword completion item kind. CIKKeyword // CIKSnippet represents a snippet completion item kind. CIKSnippet // CIKColor represents a color completion item kind. CIKColor // CIKFile represents a file completion item kind. CIKFile // CIKReference represents a reference completion item kind. CIKReference // CIKFolder represents a folder completion item kind. CIKFolder // CIKEnumMember represents an enum member completion item kind. CIKEnumMember // CIKConstant represents a constant completion item kind. CIKConstant // CIKStruct represents a struct completion item kind. CIKStruct // CIKEvent represents a event completion item kind. CIKEvent // CIKOperator represents an operator completion item kind. CIKOperator // CIKTypeParameter represents a type parameter completion item kind. CIKTypeParameter ) func (kind CompletionItemKind) String() string { switch kind { case CIKText: return "text" case CIKMethod: return "method" case CIKFunction: return "function" case CIKConstructor: return "constructor" case CIKField: return "field" case CIKVariable: return "variable" case CIKClass: return "class" case CIKInterface: return "interface" case CIKModule: return "module" case CIKProperty: return "property" case CIKUnit: return "unit" case CIKValue: return "value" case CIKEnum: return "enum" case CIKKeyword: return "keyword" case CIKSnippet: return "snippet" case CIKColor: return "color" case CIKFile: return "file" case CIKReference: return "reference" case CIKFolder: return "folder" case CIKEnumMember: return "enum member" case CIKConstant: return "constant" case CIKStruct: return "struct" case CIKEvent: return "event" case CIKOperator: return "operator" case CIKTypeParameter: return "type parameter" } return "" } // CompletionItem describes a single completion item. type CompletionItem struct { // The label of this completion item. By default // also the text that is inserted when selecting // this completion. Label string `json:"label,omitempty"` // The kind of this completion item. Based of the kind // an icon is chosen by the editor. The standardized set // of available values is defined in `CompletionItemKind`. Kind CompletionItemKind `json:"kind,omitempty"` // Tags for this completion item. Tags []CompletionItemTag `json:"tags,omitempty"` // A human-readable string with additional information // about this item, like type or symbol information. Detail string `json:"detail,omitempty"` // A human-readable string that represents a doc-comment. Documentation MarkupContent `json:"documentation,omitempty"` // Select this item when showing. // // *Note* that only one completion item can be selected and that the // tool / client decides which item that is. The rule is that the *first* // item of those that match best is selected. Preselect bool `json:"preselect,omitempty"` // A string that should be used when comparing this item // with other items. When `falsy` the label is used. SortText string `json:"sortText,omitempty"` // A string that should be used when filtering a set of // completion items. When `falsy` the label is used. FilterText string `json:"filterText,omitempty"` // A string that should be inserted into a document when selecting // this completion. When `falsy` the label is used. // // The `insertText` is subject to interpretation by the client side. // Some tools might not take the string literally. // For example, VS Code when code complete is requested in this example // `con` and a completion item with an `insertText` of // `console` is provided, it will only insert `sole`. // Therefore, it is recommended to use `textEdit` instead since it avoids // additional client side interpretation. InsertText string `json:"insertText,omitempty"` // The format of the insert text. // The format applies to both the `insertText` property and the `newText` // property of a provided `textEdit`. // If omitted, defaults to `ITFPlainText`. InsertTextFormat InsertTextFormat `json:"insertTextFormat,omitempty"` // How whitespace and indentation is handled during completion item insertion. // If not provided the client's default value is used. // // @since 3.16.0 InsertTextMode InsertTextMode `json:"insertTextMode,omitempty"` // An edit that is applied to a document when selecting this completion. // When an edit is provided, the value of `insertText` is ignored. // // *Note:* The range of the edit must be a single line range and it must // contain the position at which completion has been requested. // // TODO: add support for InsertReplaceEdit TextEdit *TextEdit `json:"textEdit,omitempty"` // An optional array of additional text edits that are applied when // selecting this completion. // Edits must not overlap (including the same insert position) with the // main edit nor with themselves. // // Additional text edits should be used to change text unrelated to the // current cursor position (for example adding an import statement at the // top of the file if the completion item will insert an unqualified type). AdditionalTextEdits []TextEdit `json:"additionalTextEdits,omitempty"` // An optional set of characters that when pressed, while this completion // is active, will accept it first and then type that character. // *Note* that all commit characters should have `length=1` and that // superfluous characters will be ignored. CommitCharacters []string `json:"commitCharacters,omitempty"` // An optional command that is executed *after* inserting this completion. // *Note* that additional modifications to the current document should be // described with the additionalTextEdits-property. Command Command `json:"command,omitempty"` // A data entry field that is preserved on a completion item between // a completion and a completion resolve request. Data interface{} `json:"data,omitempty"` } // CompletionList represents a collection of `CompletionItem`s to be presented // in the editor. type CompletionList struct { // This list it not complete. Further typing should result in recomputing // this list. IsIncomplete bool `json:"isIncomplete"` // The completion items. Items []CompletionItem `json:"items"` } // CompletionOptions contains the options for the completion handler. type CompletionOptions struct { WorkDoneProgressOptions // If code complete should automatically be triggered on characters // not being valid inside an identifier (for example `.` in JavaScript), // list them in `triggerCharacters`. TriggerCharacters []string `json:"triggerCharacters,omitempty"` // The list of all possible characters that commit a completion. // This field can be used if clients don't support individual commit // characters per completion item. // // If a server provides both `allCommitCharacters` and commit characters // on an individual completion item, the ones on the completion item win. AllCommitCharacters []string `json:"allCommitCharacters,omitempty"` // The server provides support to resolve additional // information for a completion item. ResolveProvider bool `json:"resolveProvider,omitempty"` } // CompletionRegistrationOptions contains the options for the completion handler // registration. type CompletionRegistrationOptions struct { TextDocumentRegistrationOptions CompletionOptions } // CompletionParams contains the fields sent in a `textDocument/completion` // request. type CompletionParams struct { TextDocumentPositionParams WorkDoneProgressParams PartialResultParams // The completion context. Context CompletionContext `json:"context,omitempty"` } // A special text edit to provide an insert and a replace operation. // // @since 3.16.0 type InsertReplaceEdit struct { // The string to be inserted. NewText string `json:"newText"` // The range if the insert is requested. Insert *Range `json:"insert"` // The range if the replace is requested. Replace *Range `json:"replace"` } // How whitespace and indentation is handled during completion item insertion. // // @since 3.16.0 type InsertTextMode int const ( // InsertTextModeAsIs means the insertion or replace strings is taken as it // is. If the value is multi line the lines below the cursor will be inserted // using the indentation defined in the string value. The client will not // apply any kind of adjustments to the string. InsertTextModeAsIs InsertTextMode = iota + 1 // InsertTextModeAdjustIndentation means The editor adjusts leading whitespace // of new lines so that they match the indentation up to the cursor of the // line for which the item is accepted. // // Consider a line like this: <2tabs><3tabs>foo. Accepting a multi // line completion item is indented using 2 tabs and all following lines // inserted will be indented using 2 tabs as well. InsertTextModeAdjustIndentation ) elvish-0.21.0/configuration.go000066400000000000000000000012431465720375400162770ustar00rootroot00000000000000package lsp // DidChangeConfigurationParams contains the parameters contained in a // `workspace/didChangeConfiguration` request. type DidChangeConfigurationParams struct { Settings interface{} `json:"settings"` } // ConfigurationItem defines a single configuration item. type ConfigurationItem struct { // The scope to get the configuration section for. ScopeURI DocumentURI `json:"scopeUri,omitempty"` // The configuration section asked for. Section string `json:"section,omitempty"` } // ConfigurationParams contains the parameters contained in a // `workspace/configuration` request. type ConfigurationParams struct { Items []ConfigurationItem `json:"items"` } elvish-0.21.0/diagnostic.go000066400000000000000000000073011465720375400155550ustar00rootroot00000000000000package lsp // DiagnosticSeverity denotes the severity of a given problem in a document. type DiagnosticSeverity int const ( // DSError reports an error. DSError DiagnosticSeverity = iota + 1 // DSWarning reports a warning. DSWarning // DSInformation reports an information. DSInformation // DSHint reports a hint. DSHint ) func (severity DiagnosticSeverity) String() string { switch severity { case DSError: return "error" case DSWarning: return "warning" case DSInformation: return "information" case DSHint: return "hint" } return "" } // DiagnosticTag denotes the status of a given code snippet in a document. type DiagnosticTag int const ( // DTUnnecessary reports unused or unnecessary code. // // Clients are allowed to render diagnostics with this tag faded out // instead of having an error squiggle. DTUnnecessary DiagnosticTag = iota + 1 // DTDeprecated reports deprecated or obsolete code. // // Clients are allowed to rendered diagnostics with this tag strike through. DTDeprecated ) func (tag DiagnosticTag) String() string { switch tag { case DTUnnecessary: return "unnecessary" case DTDeprecated: return "deprecated" } return "" } // CodeDescription represents a structure to capture a description for an error // code. // // @since 3.16.0 type CodeDescription struct { Href URI `json:"href"` } // Diagnostic represents a diagnostic, such as a compiler error or warning. // Diagnostic objects are only valid in the scope of a resource. 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, which might appear in the user interface. Code string `json:"code"` // An optional property to describe the error code. // // @since 3.16.0 CodeDescription *CodeDescription `json:"codeDescription,omitempty"` // A human-readable string describing the source of this diagnostic, e.g. // 'typescript' or 'super lint'. Source string `json:"omitempty"` // The diagnostic's message. Message string `json:"message"` // Additional metadata about the diagnostic. Tags []DiagnosticTag `json:"tags,omitempty"` // 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:"diagnosticRelatedInformation,omitempty"` // A data entry field that is preserved between a // `textDocument/publishDiagnostics` notification and // `textDocument/codeAction` request. // // @since 3.16.0 Data interface{} `json:"data,omitempty"` } // DiagnosticRelatedInformation represents a related message and source code // location for a diagnostic. This should be used to point to code locations // that cause or are related to a diagnostics, for example, when duplicating a // symbol in a scope. 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"` } // PublishDiagnosticsParams contains the parameters sent in a // `textDocument/publishDiagnostics` notification. type PublishDiagnosticsParams struct { // The URI for which diagnostic information is reported. URI DocumentURI `json:"uri"` // The version number of the document the diagnostics are published for. // Optional. Version int `json:"version,omitempty"` // An array of diagnostic information items. Diagnostics []Diagnostic `json:"diagnostics"` } elvish-0.21.0/document.go000066400000000000000000000337151465720375400152570ustar00rootroot00000000000000package lsp // DocumentURI is a document's unique resource identifier. type DocumentURI string // Position in a text document expressed as zero-based line and zero-based // character offset. A position is between two characters like an ‘insert’ // cursor in a editor. Special values like for example `-1` to denote the end of // a line are not supported. type Position struct { // Line position in a document (zero-based). Line int `json:"line"` // Character offset on a line in a document (zero-based). Assuming that the // line is represented as a string, the `character` value represents the gap // between the `character` and `character + 1`. // // If the character value is greater than the line length it defaults back // to the line length. Character int `json:"character"` } // 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. Therefore the // end position is exclusive. If you want to specify a range that contains a // line including the line ending character(s) then use an end position denoting // the start of the next line. type Range struct { // The range's start position. Start Position `json:"start"` // The range's end position. End Position `json:"end"` } // Location represents a location inside a resource, such as a line inside a // text file. type Location struct { URI DocumentURI `json:"uri"` Range Range `json:"range"` } // LocationLink represents a link between a source and a target location. type LocationLink struct { // Span of the origin of this link. // // Used as the underlined span for mouse interaction. // Defaults to the word range at the mouse position. OriginSelectionRange Range `json:"originSelectionRange,omitempty"` // The target resource identifier of this link. TargetURI DocumentURI `json:"targetUri"` // The full target range of this link. // For example, if the target is a symbol, then target range is the range // enclosing this symbol not including leading/trailing whitespace but // everything else like comments. // This information is typically used to highlight the range in the editor. TargetRange Range `json:"targetRange"` // The range that should be selected and revealed when this link is being // followed, for example, the name of a function. // Must be contained by the the `targetRange`. TargetSelectionRange Range `json:"targetSelectionRange"` } // DocumentHighlightKind defines a document highlight kind. type DocumentHighlightKind int const ( // DocumentHighlightKindText denotes a textual occurrence. DocumentHighlightKindText DocumentHighlightKind = iota + 1 // DocumentHighlightKindRead denotes read-access of a symbol, like reading a // variable. DocumentHighlightKindRead // DocumentHighlightKindWrite denotes write-access of a symbol, like writing // to a variable. DocumentHighlightKindWrite ) func (hk DocumentHighlightKind) String() string { switch hk { case DocumentHighlightKindText: return "text" case DocumentHighlightKindRead: return "string" case DocumentHighlightKindWrite: return "write" } return "" } // DocumentHighlight is a range inside a text document which deserves special // attention. Usually a document highlight is visualized by changing the // background color of its range. type DocumentHighlight struct { // The range this highlight applies to. Range Range `json:"range"` // The highlight kind, default is DocumentHighlightKindText. Kind DocumentHighlightKind `json:"kind"` } // DocumentHighlightOptions contains the options for the document highlight // handler. type DocumentHighlightOptions struct { WorkDoneProgressOptions } // DocumentHighlightRegistrationOptions contains the options for the document // highlight handler registration. type DocumentHighlightRegistrationOptions struct { TextDocumentRegistrationOptions DocumentHighlightOptions } // DocumentHighlightParams contains the fields sent in a // `textDocument/documentHighlight` request. type DocumentHighlightParams struct { TextDocumentPositionParams WorkDoneProgressParams PartialResultParams } // DocumentLink is a range in a text document that links to an internal or // external resource, like another text document or a web site. type DocumentLink struct { // The range this link applies to. Range Range `json:"range"` // The uri this link points to. If missing a resolve request is sent later. Target DocumentURI `json:"target,omitempty"` // The tooltip text when you hover over this link. // // If a tooltip is provided, it will be displayed in a string that // includes instructions on how to trigger the link, // such as `{0} (ctrl + click)`. // The specific instructions vary depending on OS, user settings, // and localization. Tooltip string `json:"tooltip,omitempty"` // A data entry field that is preserved on a document link between a // DocumentLinkRequest and a DocumentLinkResolveRequest. Data interface{} `json:"data,omitempty"` } // DocumentLinkOptions contains the options for the document link handler. type DocumentLinkOptions struct { WorkDoneProgressOptions // Document links have a resolve provider as well. ResolveProvider bool `json:"resolveProvider,omitempty"` } // DocumentLinkRegistrationOptions contains the options for the document link // handler registration. type DocumentLinkRegistrationOptions struct { TextDocumentRegistrationOptions DocumentLinkOptions } // DocumentLinkParams contains the fields sent in a // `textDocument/documentLink` request. type DocumentLinkParams struct { WorkDoneProgressParams PartialResultParams // The document to provide document links for. TextDocument TextDocumentIdentifier `json:"textDocument"` } // Color represents a color in RGBA space. type Color struct { // The red component of this color in the range [0-1]. Red float64 `json:"red"` // The green component of this color in the range [0-1]. Green float64 `json:"green"` // The blue component of this color in the range [0-1]. Blue float64 `json:"blue"` // The alpha component of this color in the range [0-1]. Alpha float64 `json:"alpha"` } // ColorInformation contains the color information for a given range. type ColorInformation struct { // The range in the document where this color appears. Range Range `json:"range"` // The actual color value for this color range. Color Color `json:"color"` } // DocumentColorOptions contains the options for the document color handler. type DocumentColorOptions struct { WorkDoneProgressOptions } // DocumentColorRegistrationOptions contains the options for the document color // handler registration. type DocumentColorRegistrationOptions struct { TextDocumentRegistrationOptions StaticRegistrationOptions DocumentColorOptions } // DocumentColorParams contains the fields sent in a // `textDocument/documentColor` request. type DocumentColorParams struct { WorkDoneProgressParams PartialResultParams // The text document. TextDocument TextDocumentIdentifier `json:"textDocument"` } // ColorPresentation contains the presentation data of a color value. type ColorPresentation struct { // The label of this color presentation. It will be shown on the color // picker header. // By default, this is also the text that is inserted when selecting // this color presentation. Label string `json:"label"` // A `TextEdit` which is applied to a document when selecting // this presentation for the color. // When `falsy`, the `ColorPresentation.Label` is used. TextEdit TextEdit `json:"textEdit,omitempty"` // An optional array of additional `TextEdit`s that are // applied when selecting this color presentation. // Edits must not overlap with the main `ColorPresentation.TextEdit` // nor with themselves. AdditionalTextEdits []TextEdit `json:"additionalTextEdits,omitempty"` } // ColorPresentationParams contains the fields sent in a // `textDocument/colorPresentation` request. type ColorPresentationParams struct { WorkDoneProgressParams PartialResultParams // The text document. TextDocument TextDocumentIdentifier `json:"textDocument"` // The color information to request presentations for. Color Color `json:"color"` // The range where the color would be inserted. Serves as a context. Range Range `json:"range"` } // FormattingOptions is a value-object describing what options formatting should // use. type FormattingOptions struct { // Size of a tab in spaces. TabSize int `json:"tabSize"` // Prefer spaces over tabs. InsertSpaces bool `json:"insertSpaces"` // Trim trailing whitespace on a line. TrimTrailingWhitespace bool `json:"trimTrailingWhitespace,omitempty"` // Insert a newline character at the end of the file if one does not exist. InsertFinalNewline bool `json:"insertFinalNewline,omitempty"` // Trim all newlines after the final newline at the end of the file. TrimFinalNewlines bool `json:"trimFinalNewlines,omitempty"` } // DocumentFormattingOptions contains the options for the document formatting // handler. type DocumentFormattingOptions struct { WorkDoneProgressOptions } // DocumentFormattingRegistrationOptions contains the options for the document // formatting handler registration. type DocumentFormattingRegistrationOptions struct { TextDocumentRegistrationOptions DocumentFormattingOptions } // DocumentFormattingParams contains the fields sent in a // `textDocument/formatting` request. type DocumentFormattingParams struct { WorkDoneProgressParams // The document to format. TextDocument TextDocumentIdentifier `json:"textDocument"` // The format options. Options FormattingOptions `json:"options"` } // DocumentRangeFormattingOptions contains the options for the document range // formatting handler. type DocumentRangeFormattingOptions struct { WorkDoneProgressOptions } // DocumentRangeFormattingRegistrationOptions contains the options for the // document range formatting handler registration. type DocumentRangeFormattingRegistrationOptions struct { TextDocumentRegistrationOptions DocumentRangeFormattingOptions } // DocumentRangeFormattingParams contains the fields sent in a // `textDocument/rangeFormatting` request. type DocumentRangeFormattingParams struct { WorkDoneProgressParams // The document to format. TextDocument TextDocumentIdentifier `json:"textDocument"` // The range to format. Range Range `json:"range"` // The format options. Options FormattingOptions `json:"options"` } // DocumentOnTypeFormattingOptions contains the options for the document on-type // formatting handler. type DocumentOnTypeFormattingOptions struct { // A character on which formatting should be triggered, like `}`. FirstTriggerCharacter string `json:"firstTriggerCharacter"` // More trigger characters. MoreTriggerCharacter []string `json:"moreTriggerCharacter,omitempty"` } // DocumentOnTypeFormattingRegistrationOptions contains the options for the // document on-type formatting handler registration. type DocumentOnTypeFormattingRegistrationOptions struct { TextDocumentRegistrationOptions DocumentOnTypeFormattingOptions } // DocumentOnTypeFormattingParams contains the fields sent in a // `textDocument/onTypeFormatting` request. type DocumentOnTypeFormattingParams struct { TextDocumentPositionParams // The character that has been typed. Character string `json:"ch"` // The format options. Options FormattingOptions `json:"options"` } // FoldingRangeKind contains the known range kinds. type FoldingRangeKind string const ( // FoldingRangeKindComment denotes that the folding range is for a comment. FoldingRangeKindComment FoldingRangeKind = "comment" // FoldingRangeKindImports denotes that the folding range is for imports or // includes. FoldingRangeKindImports = "imports" // FoldingRangeKindRegion denotes that the folding range is for a region // (e.g. `#region`). FoldingRangeKindRegion = "region" ) // FoldingRange represents a folding range for the client. type FoldingRange struct { // The zero-based line number from where the folded range starts. StartLine int `json:"startLine"` // The zero-based character offset from where the folded range starts. // If not defined, defaults to the length of the start line. StartCharacter int `json:"startCharacter,omitempty"` // The zero-based line number where the folded range ends. EndLine int `json:"endLine"` // The zero-based character offset before the folded range ends. // If not defined, defaults to the length of the end line. EndCharacter int `json:"endCharacter,omitempty"` // Describes the kind of the folding range such as `comment` or `region`. // The kind is used to categorize folding ranges and used by commands // like 'Fold all comments'. // See FoldingRangeKind for an enumeration of standardized kinds. Kind FoldingRangeKind `json:"kind,omitempty"` } // FoldingRangeOptions contains the options for the folding range provider // handler. type FoldingRangeOptions struct { WorkDoneProgressOptions } // FoldingRangeRegistrationOptions contains the options for the folding range // provider handler registration. type FoldingRangeRegistrationOptions struct { TextDocumentRegistrationOptions FoldingRangeOptions StaticRegistrationOptions } // FoldingRangeParams contains the fields sent in a `textDocument/foldingRange` // request. type FoldingRangeParams struct { WorkDoneProgressParams PartialResultParams // The text document. TextDocument TextDocumentIdentifier `json:"textDocument"` } // SelectionRangeOptions contains the options for the selection range provider // handler. type SelectionRangeOptions struct { WorkDoneProgressOptions } // SelectionRangeRegistrationOptions contains the options for the selection // range provider handler registration. type SelectionRangeRegistrationOptions struct { SelectionRangeOptions TextDocumentRegistrationOptions StaticRegistrationOptions } // SelectionRangeParams contains the fields sent in a // `textDocument/selectionRange` request. type SelectionRangeParams struct { WorkDoneProgressParams PartialResultParams // The text document. TextDocument TextDocumentIdentifier `json:"textDocument"` // The positions inside the text document. Positions []Position `json:"positions"` } elvish-0.21.0/files.go000066400000000000000000000147431465720375400145430ustar00rootroot00000000000000package lsp // WatchKind defines the kind of the file system watcher. type WatchKind int const ( // WKCreate means the watcher is interested in create events. WKCreate WatchKind = 1 << iota // WKChange means the watcher is interested in change events. WKChange // WKDelete means the watcher is interested in delete events. WKDelete ) func (kind WatchKind) String() string { switch kind { case WKCreate: return "create" case WKChange: return "change" case WKDelete: return "delete" case WKCreate | WKChange: return "create/change" case WKCreate | WKDelete: return "create/delete" case WKChange | WKDelete: return "change/delete" case WKCreate | WKChange | WKDelete: return "create/change/delete" } return "" } // FileChangeType defines the type of a file event. type FileChangeType int const ( // FCTCreated means the file got created. FCTCreated FileChangeType = 1 << iota // FCTChanged means the file got changed. FCTChanged // FCTDeleted means the file got deleted. FCTDeleted ) func (fct FileChangeType) String() string { switch fct { case FCTCreated: return "created" case FCTChanged: return "changed" case FCTDeleted: return "deleted" case FCTCreated | FCTChanged: return "created/changed" case FCTCreated | FCTDeleted: return "created/deleted" case FCTChanged | FCTDeleted: return "changed/deleted" case FCTCreated | FCTChanged | FCTDeleted: return "created/changed/deleted" } return "" } // FileSystemWatcher defines a watcher on a given glob pattern. type FileSystemWatcher struct { // The glob pattern to watch. GlobPattern string `json:"globPattern"` // The kind of events of interest. If omitted it defaults to // `WKCreate | WKChange | WKDelete`, which is `7`. Kind WatchKind `json:"kind,omitempty"` } // FileEvent is an event describing a file change. type FileEvent struct { // The file's URI. URI DocumentURI `json:"uri"` // The change type. Type FileChangeType `json:"type"` } // DidChangeWatchedFilesRegistrationOptions describes options to be used when // registering for file system change events. type DidChangeWatchedFilesRegistrationOptions struct { // The watchers to register. Watchers []FileSystemWatcher `json:"watchers"` } // DidChangeWatchedFilesParams contains the parameters of a request of method // `workspace/didChangeWatchedFiles`. type DidChangeWatchedFilesParams struct { Changes []FileEvent `json:"changes"` } // RenameOptions contains the options for the rename handler. type RenameOptions struct { WorkDoneProgressOptions // Renames should be checked and tested before being executed. PrepareProvider bool `json:"prepareProvider,omitempty"` } // RenameRegistrationOptions contains the options for the rename handler // registration. type RenameRegistrationOptions struct { TextDocumentRegistrationOptions RenameOptions } // RenameParams contains the fields sent in a `textDocument/rename` request. type RenameParams struct { TextDocumentPositionParams WorkDoneProgressParams // The new name of the symbol. If the given name is not valid the // request must return a [ResponseError](#ResponseError) with an // appropriate message set. NewName string `json:"newName"` } // PrepareRenameParams contains the fields sent in a `textDocument/prepareRename` // request. type PrepareRenameParams struct { TextDocumentPositionParams } // A pattern kind describing if a glob pattern matches a file a folder or both. // // @since 3.16.0 type FileOperationPatternKind string const ( // FOPKindFile means the pattern matches a file only. FOPKindFile FileOperationPatternKind = "file" // FOPKindFolder means the pattern matches a folder only. FOPKindFolder FileOperationPatternKind = "folder" ) // Matching options for the file operation pattern. // // @since 3.16.0 type FileOperationPatternOptions struct { // The pattern should be matched ignoring casing. IgnoreCase bool `json:"ignoreCase,omitempty"` } // A pattern to describe in which file operation requests or notifications the // server is interested in. // // @since 3.16.0 type FileOperationPattern struct { // The glob pattern to match. Glob patterns can have the following syntax: // - `*` to match one or more characters in a path segment // - `?` to match on one character in a path segment // - `**` to match any number of path segments, including none // - `{}` to group sub patterns into an OR expression. (e.g. `**​/*.{ts,js}` // matches all TypeScript and JavaScript files) // - `[]` to declare a range of characters to match in a path segment // (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …) // - `[!...]` to negate a range of characters to match in a path segment // (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but // not `example.0`) Glob string `json:"glob"` // Whether to match files or folders with this pattern. // // Matches both if undefined. Matches FileOperationPatternKind `json:"matches,omitempty"` // Additional options used during matching. Options *FileOperationPatternOptions `json:"options,omitempty"` } // A filter to describe in which file operation requests or notifications the // server is interested in. // // @since 3.16.0 type FileOperationFilter struct { // A Uri like `file` or `untitled`. Scheme string `json:"scheme,omitempty"` // The actual file operation pattern. Pattern *FileOperationPattern `json:"pattern"` } // The options to register for file operations. // // @since 3.16.0 type FileOperationRegistrationOptions struct { Filters []FileOperationFilter `json:"filters"` } // Represents information on a file/folder rename. // // @since 3.16.0 type FileRename struct { // A file:// URI for the original location of the file/folder being renamed. OldURI string `json:"oldUri"` // A file:// URI for the new location of the file/folder being renamed. NewURI string `json:"newUri"` } // The parameters sent in notifications/requests for user-initiated renames of // files. // // @since 3.16.0 type RenameFilesParams struct { // An array of all files/folders renamed in this operation. When a folder is // renamed, only the folder will be included, and not its children. Files []FileRename `json:"files"` } // Represents information on a file/folder delete. // // @since 3.16.0 type FileDelete struct { URI string `json:"uri"` } // The parameters sent in notifications/requests for user-initiated deletes of // files. // // @since 3.16.0 type DeleteFilesParams struct { // A file:// URI for the location of the file/folder being deleted. Files []FileDelete `json:"files"` } elvish-0.21.0/go.mod000066400000000000000000000000531465720375400142050ustar00rootroot00000000000000module pkg.nimblebun.works/go-lsp go 1.15 elvish-0.21.0/goto.go000066400000000000000000000057231465720375400144070ustar00rootroot00000000000000package lsp // DeclarationOptions contains the options for the go-to-declaration handler. type DeclarationOptions struct { WorkDoneProgressOptions } // DeclarationRegistrationOptions contains the options for the go-to-declaration // handler registration. type DeclarationRegistrationOptions struct { DeclarationOptions TextDocumentRegistrationOptions StaticRegistrationOptions } // DeclarationParams contains the fields sent in a `textDocument/declaration` // request. type DeclarationParams struct { TextDocumentPositionParams WorkDoneProgressParams PartialResultParams } // DefinitionOptions contains the options for the go-to-definition handler. type DefinitionOptions struct { WorkDoneProgressOptions } // DefinitionRegistrationOptions contains the options for the go-to-definition // handler registration. type DefinitionRegistrationOptions struct { TextDocumentRegistrationOptions DefinitionOptions } // DefinitionParams contains the fields sent in a `textDocument/definition` // request. type DefinitionParams struct { TextDocumentPositionParams WorkDoneProgressParams PartialResultParams } // TypeDefinitionOptions contains the options for the go-to-type-definition // handler. type TypeDefinitionOptions struct { WorkDoneProgressOptions } // TypeDefinitionRegistrationOptions contains the options for the // go-to-type-definition handler registration. type TypeDefinitionRegistrationOptions struct { TextDocumentRegistrationOptions DefinitionOptions } // TypeDefinitionParams contains the fields sent in a // `textDocument/typeDefinition` request. type TypeDefinitionParams struct { TextDocumentPositionParams WorkDoneProgressParams PartialResultParams } // ImplementationOptions contains the options for the go-to-implementation // handler. type ImplementationOptions struct { WorkDoneProgressOptions } // ImplementationRegistrationOptions contains the options for the // go-to-implementation handler registration. type ImplementationRegistrationOptions struct { TextDocumentRegistrationOptions DefinitionOptions } // ImplementationParams contains the fields sent in a // `textDocument/implementation` request. type ImplementationParams struct { TextDocumentPositionParams WorkDoneProgressParams PartialResultParams } // ReferenceContext defines additional context to a reference parameter. type ReferenceContext struct { // Include the declaration of the current symbol. IncludeDeclaration bool `json:"includeDeclaration,omitempty"` } // ReferenceOptions contains the options for the find references handler. type ReferenceOptions struct { WorkDoneProgressOptions } // ReferenceRegistrationOptions contains the options for the find references // handler registration. type ReferenceRegistrationOptions struct { TextDocumentRegistrationOptions ReferenceOptions } // ReferenceParams contains the fields sent in a `textDocument/references` // request. type ReferenceParams struct { WorkDoneProgressParams PartialResultParams Context ReferenceContext `json:"context"` } elvish-0.21.0/hover.go000066400000000000000000000013771465720375400145630ustar00rootroot00000000000000package lsp // Hover is the result of a hover request. type Hover struct { // The hover's content. Contents MarkupContent `json:"contents"` // An optional range is a range inside a text document that is used to // visualize a hover, e.g. by changing the background color. Range *Range `json:"range,omitempty"` } // HoverOptions contains the options for the hover handler. type HoverOptions struct { WorkDoneProgressOptions } // HoverRegistrationOptions contains the options for the hover handler // registration. type HoverRegistrationOptions struct { TextDocumentRegistrationOptions HoverOptions } // HoverParams contains the fields sent in a `textDocument/hover` request. type HoverParams struct { TextDocumentPositionParams WorkDoneProgressParams } elvish-0.21.0/initialize.go000066400000000000000000000054271465720375400156010ustar00rootroot00000000000000package lsp // ClientInfo contains information about the client. type ClientInfo struct { // The name of the client as defined by the client. Name string `json:"name"` // The client's version as defined by the client. Version string `json:"version,omitempty"` } // ServerInfo contains information about the server. type ServerInfo struct { // The name of the server as defined by the server. Name string `json:"name"` // The server's version as defined by the server. Version string `json:"version,omitempty"` } // TraceType specifies the type of trace that needs to be done in a // communication between the client and the server. type TraceType string const ( // TraceOff means tracing is turned off. TraceOff TraceType = "off" // TraceMessages means only the messages will be traced. TraceMessages = "messages" // TraceVerbose means tracing will be detailed. TraceVerbose = "verbose" ) // InitializeParams is a struct containing the parameters of an `initialize` // request. type InitializeParams struct { WorkDoneProgressParams // 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"` // Information about the client. ClientInfo ClientInfo `json:"clientInfo,omitempty"` // The locale the client is currently showing the user interface in. This must // not necessarily be the locale of the operating system. // // Uses IETF language tags as the value's syntax (See // https://en.wikipedia.org/wiki/IETF_language_tag) // // @since 3.16.0 Locale string `json:"locale,omitempty"` // The rootUri of the workspace. RootURI DocumentURI `json:"rootUri,omitempty"` // User provided initialization options. InitializationOptions interface{} `json:"initializationOptions"` // The capabilities provided by the client (editor or tool). // Capabilities ClientCapabilities `json:"capabilities"` // The initial trace setting. If omitted trace is disabled ('off'). Trace TraceType `json:"trace,omitempty"` // 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"` } // InitializeResult contains the fields of the `result` parameter in a response // payload for an `initialize` request. type InitializeResult struct { // The capabilities the language server provides. Capabilities ServerCapabilities `json:"capabilities"` // Information about the server. ServerInfo ServerInfo `json:"serverInfo,omitempty"` } elvish-0.21.0/jsonrpc2.go000066400000000000000000000016461465720375400151770ustar00rootroot00000000000000package lsp import ( "encoding/json" "strconv" ) // ID is a JSON-RPC 2.0 request ID. It can be either a string or a number. type ID struct { AsInteger uint64 AsString string IsString bool } func (id ID) String() string { if id.IsString { return strconv.Quote(id.AsString) } return strconv.FormatUint(id.AsInteger, 10) } // MarshalJSON will turn the ID into a JSON string. func (id ID) MarshalJSON() ([]byte, error) { if id.IsString { return json.Marshal(id.AsString) } return json.Marshal(id.AsInteger) } // UnmarshalJSON will turn the passed data into an ID struct. func (id *ID) UnmarshalJSON(data []byte) error { var asInteger uint64 if err := json.Unmarshal(data, &asInteger); err == nil { *id = ID{AsInteger: asInteger} return nil } var asString string if err := json.Unmarshal(data, &asString); err != nil { return err } *id = ID{ AsString: asString, IsString: true, } return nil } elvish-0.21.0/linked_editing_range.go000066400000000000000000000023071465720375400175570ustar00rootroot00000000000000package lsp // LinkedEditingRangeOptions specifies the options for settin up linked editing // range support for a language server. type LinkedEditingRangeOptions struct { WorkDoneProgressOptions } // LinkedEditingRangeRegistrationOptions describes options to be used when // registering for linked editing range capabilities. type LinkedEditingRangeRegistrationOptions struct { TextDocumentRegistrationOptions LinkedEditingRangeOptions StaticRegistrationOptions } // LinkedEditingRangeParams contains the data the client sends through a // `textDocument/linkedEditingRange` request. type LinkedEditingRangeParams struct { TextDocumentPositionParams WorkDoneProgressParams } // LinkedEditingRanges represents a set of linked editing ranges. type LinkedEditingRanges struct { // A list of ranges that can be renamed together. The ranges must have // identical length and contain identical text content. The ranges cannot // overlap. Ranges []*Range `json:"ranges"` // An optional word pattern (regular expression) that describes valid contents // for the given ranges. If no pattern is provided, the client configuration's // word pattern will be used. WordPattern string `json:"wordPattern,omitempty"` } elvish-0.21.0/main.go000066400000000000000000000001541465720375400143540ustar00rootroot00000000000000// Package lsp contains type definitions and documentation for the Language // Server Protocol. package lsp elvish-0.21.0/message.go000066400000000000000000000046121465720375400150570ustar00rootroot00000000000000package lsp // MessageType defines the type of a message. type MessageType int const ( // MTError is an error message. MTError MessageType = iota + 1 // MTWarning is a warning message. MTWarning // MTInfo is an information message. MTInfo // MTLog is a log message. MTLog ) func (mt MessageType) String() string { switch mt { case MTError: return "error" case MTWarning: return "warning" case MTInfo: return "information" case MTLog: return "log" } return "" } // ShowMessageParams is the payload that is sent on a `window/showMessage` // notification. type ShowMessageParams struct { // The message type. Type MessageType `json:"type"` // The actual message. Message string `json:"message"` } // ShowMessageRequestParams is the payload that is sent on a // `window/showMessageRequest` request. type ShowMessageRequestParams struct { // The message type. Type MessageType `json:"type"` // The actual message. Message string `json:"message"` // The message action items to present. Actions []MessageActionItem `json:"actions,omitempty"` } // MessageActionItem encapsulates a message action. type MessageActionItem struct { Title string `json:"title"` } // Params to show a document. // // @since 3.16.0 type ShowDocumentParams struct { // The URI of the document to show. URI string `json:"uri"` // Indicates to show the resource in an external program. To show for example // `https://code.visualstudio.com/` in the default WEB browser set `external` // to `true`. External bool `json:"external,omitempty"` // An optional property to indicate whether the editor showing the document // should take focus or not. Clients might ignore this property if an external // program is started. TakeFocus bool `json:"takeFocus,omitempty"` // An optional selection range if the document is a text document. Clients // might ignore the property if an external program is started or the file is // not a text file. Selection *Range `json:"selection,omitempty"` } // The result of a show document request. // // @since 3.16.0 type ShowDocumentResult struct { // A boolean indicating if the show was successful. Success bool `json:"success"` } // LogMessageParams is the payload that is sent on a `window/logMessage` // notification. type LogMessageParams struct { // The message type. Type MessageType `json:"type"` // The actual message. Message string `json:"message"` } elvish-0.21.0/monikers.go000066400000000000000000000041731465720375400152640ustar00rootroot00000000000000package lsp // MonikerOptions specifies the options for settin up moniker support for a // language server. type MonikerOptions struct { WorkDoneProgressOptions } // MonikerRegistrationOptions describes options to be used when registering for // moniker capabilities. type MonikerRegistrationOptions struct { TextDocumentRegistrationOptions MonikerOptions } // MonikerParams contains the data the client sends through a // `textDocument/moniker` request. type MonikerParams struct { TextDocumentPositionParams WorkDoneProgressParams PartialResultParams } // UniquenessLevel represents a level of uniqueness for a moniker. type UniquenessLevel string const ( UniquenessLevelDocument UniquenessLevel = "document" UniquenessLevelProject UniquenessLevel = "project" UniquenessLevelGroup UniquenessLevel = "group" UniquenessLevelScheme UniquenessLevel = "scheme" UniquenessLevelGlobal UniquenessLevel = "global" ) func (level UniquenessLevel) String() string { switch level { case UniquenessLevelDocument: return "document" case UniquenessLevelProject: return "project" case UniquenessLevelGroup: return "group" case UniquenessLevelScheme: return "scheme" case UniquenessLevelGlobal: return "global" } return "" } // MonikerKind represents the kind of moniker. type MonikerKind string const ( MonikerKindImport MonikerKind = "import" MonikerKindExport MonikerKind = "export" MonikerKindLocal MonikerKind = "local" ) func (kind MonikerKind) String() string { switch kind { case MonikerKindImport: return "import" case MonikerKindExport: return "export" case MonikerKindLocal: return "local" } return "" } // Moniker represents a single moniker. type Moniker struct { // The scheme of the moniker. For example tsc or .Net Scheme string `json:"scheme"` // The identifier of the moniker. The value is opaque in LSIF however // schema owners are allowed to define the structure if they want. Identifier string `json:"identifier"` // The scope in which the moniker is unique Unique UniquenessLevel `json:"unique"` // The moniker kind if known. Kind MonikerKind `json:"kind,omitempty"` } elvish-0.21.0/progress.go000066400000000000000000000077351465720375400153100ustar00rootroot00000000000000package lsp // ProgressToken represents a token provided by the client or server. type ProgressToken string // ProgressParams denotes a token-value pair for a progress. type ProgressParams struct { // The progress token provided by the client or server. Token ProgressToken `json:"token"` // The progress data. Value interface{} `json:"value"` } // WorkDoneProgressBegin is the payload that must be sent in a `$/progress` // notification. type WorkDoneProgressBegin struct { // Should always be "begin". Kind string `json:"kind"` // Mandatory title of the progress operation. Used to briefly inform about // the kind of operation being performed. Title string `json:"title"` // Controls if a cancel button should show to allow the user to cancel the // long running operation. // Clients that don't support cancellation can ignore the setting. Cancellable bool `json:"cancellable,omitempty"` // Optional, more detailed associated progress message. Contains // complementary information to the `title`. // // Examples: "3/25 files", "project/src/module2", "node_modules/some_dep". // If unset, the previous progress message (if any) is still valid. Message string `json:"message"` // Optional progress percentage to display (value 100 is considered 100%). // If not provided infinite progress is assumed and clients are allowed // to ignore the `percentage` value in subsequent in report notifications. // // The value should be steadily rising. Clients are free to ignore values // that are not following this rule. Percentage int `json:"percentage"` } // WorkDoneProgressReport is the payload that needs to be sent to report // progress. type WorkDoneProgressReport struct { // Should always be "report". Kind string `json:"kind"` // Controls enablement state of a cancel button. T // This property is only valid if a cancel button is requested in // the `WorkDoneProgressBegin` payload. // // Clients that don't support cancellation or don't support controlling // the button's enablement state are allowed to ignore the setting. Cancellable bool `json:"cancellable,omitempty"` // Optional, more detailed associated progress message. Contains // complementary information to the `title`. // // Examples: "3/25 files", "project/src/module2", "node_modules/some_dep". // If unset, the previous progress message (if any) is still valid. Message string `json:"message,omitempty"` // Optional progress percentage to display (value 100 is considered 100%). // If not provided infinite progress is assumed and clients are allowed // to ignore the `percentage` value in subsequent in report notifications. // // The value should be steadily rising. Clients are free to ignore values // that are not following this rule. Percentage int `json:"percentage,omitempty"` } // WorkDoneProgressEnd is the payload that needs to be sent to signal the end of // a progress reporting. type WorkDoneProgressEnd struct { // Should always be "end". Kind string `json:"kind"` // Optional, a final message indicating to for example indicate the outcome // of the operation. Message string `json:"message,omitempty"` } // WorkDoneProgressParams contains the parameters of a progress report. type WorkDoneProgressParams struct { // An optional token that a server can use to report work done progress. WorkDoneToken ProgressToken `json:"workDoneToken,omitempty"` } // WorkDoneProgressOptions is the type definition for the server capability. type WorkDoneProgressOptions struct { WorkDoneProgress bool `json:"workDoneProgress,omitempty"` } // WorkDoneProgressCreateParams is the request payload sent in a // `window/workDoneProgress/create` request. type WorkDoneProgressCreateParams struct { // The token to be used to report progress. Token ProgressToken `json:"token"` } // WorkDoneProgressCancelParams is the request payload sent in a // `window/workDoneProgress/cancel` request. type WorkDoneProgressCancelParams struct { // The token to be used to report progress. Token ProgressToken `json:"token"` } elvish-0.21.0/registration.go000066400000000000000000000021261465720375400161430ustar00rootroot00000000000000package lsp // Registration contains general parameters to register for a capability. type Registration struct { // The id used to register the request. The id can be used to deregister // the request again. ID string `json:"id"` // The method/capability to register for. Method string `json:"method"` // Options necessary for the registration. RegisterOptions interface{} `json:"registerOptions,omitempty"` } // RegistrationParams is the req payload sent in a `client/registerCapability` // request. type RegistrationParams struct { Registrations []Registration `json:"registrations"` } // Unregistration contains general parameters to unregister a capability. type Unregistration struct { // The id used to unregister the request or notification. Usually an id // provided during the register request. ID string `json:"id"` // The method/capability to unregister for. Method string `json:"method"` } // UnregistrationParams is the payload sent in a `client/unregisterCapability` // request. type UnregistrationParams struct { Unregistrations []Unregistration `json:"unregisterations"` } elvish-0.21.0/semantic_tokens.go000066400000000000000000000165411465720375400166250ustar00rootroot00000000000000package lsp // SemanticTokenType represents the type of a semantic token. type SemanticTokenType string const ( STTNamespace SemanticTokenType = "namespace" // STTType represents a generic type. Acts as a fallback for types which can't // be mapped to a specific type like class or enum. STTType SemanticTokenType = "type" STTClass SemanticTokenType = "class" STTEnum SemanticTokenType = "enum" STTInterface SemanticTokenType = "interface" STTStruct SemanticTokenType = "struct" STTTypeParameter SemanticTokenType = "typeParameter" STTParameter SemanticTokenType = "parameter" STTVariable SemanticTokenType = "variable" STTProperty SemanticTokenType = "property" STTEnumMember SemanticTokenType = "enumMember" STTEvent SemanticTokenType = "event" STTFunction SemanticTokenType = "function" STTMethod SemanticTokenType = "method" STTMacro SemanticTokenType = "macro" STTKeyword SemanticTokenType = "keyword" STTModifier SemanticTokenType = "modifier" STTComment SemanticTokenType = "comment" STTString SemanticTokenType = "string" STTNumber SemanticTokenType = "number" STTRegExp SemanticTokenType = "regexp" STTOperator SemanticTokenType = "operator" ) func (stt SemanticTokenType) String() string { switch stt { case STTNamespace: return "namespace" case STTType: return "type" case STTClass: return "class" case STTEnum: return "enum" case STTInterface: return "interface" case STTStruct: return "struct" case STTTypeParameter: return "typeParameter" case STTParameter: return "parameter" case STTVariable: return "variable" case STTProperty: return "property" case STTEnumMember: return "enumMember" case STTEvent: return "event" case STTFunction: return "function" case STTMethod: return "method" case STTMacro: return "macro" case STTKeyword: return "keyword" case STTModifier: return "modifier" case STTComment: return "comment" case STTString: return "string" case STTNumber: return "number" case STTRegExp: return "regexp" case STTOperator: return "operator" } return "" } // SemanticTokenModifiers represents a modifier for a semantic token. type SemanticTokenModifiers string const ( STMDeclaration SemanticTokenModifiers = "declaration" STMDefinition SemanticTokenModifiers = "definition" STMReadOnly SemanticTokenModifiers = "readonly" STMStatic SemanticTokenModifiers = "static" STMDeprecated SemanticTokenModifiers = "deprecated" STMAbstract SemanticTokenModifiers = "abstract" STMAsync SemanticTokenModifiers = "async" STMModification SemanticTokenModifiers = "modification" STMDocumentation SemanticTokenModifiers = "documentation" STMDefaultLibrary SemanticTokenModifiers = "defaultLibrary" ) func (stm SemanticTokenModifiers) String() string { switch stm { case STMDeclaration: return "declaration" case STMDefinition: return "definition" case STMReadOnly: return "readonly" case STMStatic: return "static" case STMDeprecated: return "deprecated" case STMAbstract: return "abstract" case STMAsync: return "async" case STMModification: return "modification" case STMDocumentation: return "documentation" case STMDefaultLibrary: return "defaultLibrary" } return "" } // TokenFormat represents the format of a semantic token. type TokenFormat string const ( TokenFormatRelative TokenFormat = "relative" ) func (tf TokenFormat) String() string { switch tf { case TokenFormatRelative: return "relative" } return "" } // SemanticTokensLegend represents a mapping of semantic token types and // modifiers. type SemanticTokensLegend struct { // The token types a server uses. TokenTypes []SemanticTokenType `json:"tokenTypes"` // The token modifiers a server uses. TokenModifiers []SemanticTokenModifiers `json:"tokenModifiers"` } // SemanticTokensOptions specifies the options for settin up semantic token // support for a language server. type SemanticTokensOptions struct { WorkDoneProgressOptions // The legend used by the server Legend *SemanticTokensLegend `json:"legend,omitempty"` // Server supports providing semantic tokens for a specific range of a // document. Range bool `json:"range,omitempty"` // Server supports providing semantic tokens for a full document. Full struct { // The server supports deltas for full documents. Delta bool `json:"delta,omitempty"` } `json:"full,omitempty"` } // SemanticTokensRegistrationOptions describes options to be used when // registering for semantic token capabilities. type SemanticTokensRegistrationOptions struct { TextDocumentRegistrationOptions SemanticTokensOptions StaticRegistrationOptions } // SemanticTokenParams contains the data the client sends through a // `textDocument/semanticTokens/full` request. type SemanticTokensParams struct { WorkDoneProgressParams PartialResultParams TextDocument *TextDocumentIdentifier `json:"textDocument"` } // SemanticTokens represents a set of semantic tokens for a document. type SemanticTokens struct { // An optional result id. If provided and clients support delta updating // the client will include the result id in the next semantic token request. // A server can then instead of computing all semantic tokens again simply // send a delta. ResultID string `json:"resultId,omitempty"` // The actual tokens. Data []uint `json:"data"` } // SemanticTokensPartialResult is similar to SemanticTokens but only contains // the tokens (without the result ID). // // Note: this type is probably redundant, but the spec defines it. type SemanticTokensPartialResult struct { Data []uint `json:"data"` } // SemanticTokensDeltaParams contains the data the client sends through a // `textDocument/semanticTokens/full/delta` request. type SemanticTokensDeltaParams struct { WorkDoneProgressParams PartialResultParams // The text document TextDocument *TextDocumentIdentifier `json:"textDocument"` // The result id of a previous response. The result Id can either point to // a full response or a delta response depending on what was received last. PreviousResultID string `json:"previousResultId"` } // SemanticTokensEdit represents data about a single semantic tokens edit within // the document. type SemanticTokensEdit struct { // The start offset of the edit. Start uint `json:"start"` // The count of elements to remove. DeleteCount uint `json:"deleteCount"` // The elements to insert. Data []uint `json:"data,omitempty"` } // SemanticTokensDelta represents a set of semantic tokens edits for a document. type SemanticTokensDelta struct { ResultID string `json:"resultId,omitempty"` // The semantic token edits to transform a previous result into a new result. Edits []SemanticTokensEdit `json:"edits"` } // SemanticTokensDeltaPartialResult is similar to SemanticTokensDelta but only // contains the edits (without the result ID). type SemanticTokensDeltaPartialResult struct { Edits []SemanticTokensEdit `json:"edits"` } // SemanticTokensRangeParams contains the data the client sends through a // `textDocument/semanticTokens/range` request. type SemanticTokensRangeParams struct { WorkDoneProgressParams PartialResultParams // The text document TextDocument *TextDocumentIdentifier `json:"textDocument"` // The range of the document to get semantic tokens for. Range *Range `json:"range"` } elvish-0.21.0/server_capabilities.go000066400000000000000000000134041465720375400174510ustar00rootroot00000000000000package lsp // WorkspaceFoldersServerCapabilities contains information about the server's // workspace folders capabilities. type WorkspaceFoldersServerCapabilities struct { // The server has support for workspace folders. Supported bool `json:"supported,omitempty"` // Whether the server wants to receive workspace folder // change notifications. ChangeNotifications string `json:"changeNotifications,omitempty"` } // ServerCapabilities defines the capabilities of the language server. type ServerCapabilities struct { // Defines how text documents are synced. TextDocumentSync *TextDocumentSyncOptions `json:"textDocumentSync,omitempty"` // The server provides completion support. CompletionProvider *CompletionOptions `json:"completionProvider,omitempty"` // The server provides hover support. HoverProvider *HoverOptions `json:"hoverProvider,omitempty"` // The server provides signature help support. SignatureHelpProvider *SignatureHelpOptions `json:"signatureHelpProvider,omitempty"` // The server provides go to declaration support. DeclarationProvider *DeclarationRegistrationOptions `json:"declarationProvider,omitempty"` // The server provides goto definition support. DefinitionProvider *DefinitionRegistrationOptions `json:"definitionProvider,omitempty"` // The server provides goto type definition support. TypeDefinitionProvider *TypeDefinitionRegistrationOptions `json:"typeDefinitionProvider,omitempty"` // The server provides goto implementation support. ImplementationProvider *ImplementationRegistrationOptions `json:"implementationProvider,omitempty"` // The server provides find references support. ReferencesProvider *ReferenceRegistrationOptions `json:"referencesProvider,omitempty"` // The server provides document highlight support. DocumentHighlightProvider *DocumentHighlightRegistrationOptions `json:"documentHighlightProvider,omitempty"` // The server provides document symbol support. DocumentSymbolProvider *DocumentSymbolRegistrationOptions `json:"documentSymbolProvider,omitempty"` // The server provides code actions. CodeActionProvider *CodeActionRegistrationOptions `json:"codeActionProvider,omitempty"` // The server provides CodeLens. CodeLensProvider *CodeLensRegistrationOptions `json:"codeLensProvider,omitempty"` // The server provides document link support. DocumentLinkProvider *DocumentLinkRegistrationOptions `json:"documentLinkProvider,omitempty"` // The server provides color provider support. ColorProvider *DocumentColorRegistrationOptions `json:"colorProvider,omitempty"` // The server provides document formatting. DocumentFormattingProvider *DocumentFormattingRegistrationOptions `json:"documentFormattingProvider,omitempty"` // The server provides document range formatting. DocumentRangeFormattingProvider *DocumentRangeFormattingRegistrationOptions `json:"documentRangeFormattingProvider,omitempty"` // The server provides document formatting on typing. DocumentOnTypeFormattingProvider *DocumentOnTypeFormattingRegistrationOptions `json:"documentOnTypeFormattingProvider,omitempty"` // The server provides rename support. RenameProvider *RenameRegistrationOptions `json:"renameProvider,omitempty"` // The server provides folding provider support. FoldingRangeProvider *FoldingRangeRegistrationOptions `json:"foldingRangeProvider,omitempty"` // The server provides execute command support. ExecuteCommandProvider *ExecuteCommandRegistrationOptions `json:"executeCommandProvider,omitempty"` // The server provides selection range support. SelectionRangeProvider *SelectionRangeRegistrationOptions `json:"selectionRangeProvider,omitempty"` // The server provides linked editing range support. // // @since 3.16.0 LinkedEditingRangeProvider *LinkedEditingRangeRegistrationOptions `json:"linkedEditingRangeProvider,omitempty"` // The server provides call hierarchy support. // // @since 3.16.0 CallHierarchyProvider *CallHierarchyRegistrationOptions `json:"callHierarchyProvider,omitempty"` // The server provides semantic tokens support. // // @since 3.16.0 SemanticTokensProvider *SemanticTokensRegistrationOptions `json:"semanticTokensProvider,omitempty"` // Whether server provides moniker support. // // @since 3.16.0 MonikerProvider *MonikerRegistrationOptions `json:"monikerProvider,omitempty"` // The server provides workspace symbol support. WorkspaceSymbolProvider *WorkspaceSymbolRegistrationOptions `json:"workspaceSymbolProvider,omitempty"` // Workspace specific server capabilities. Workspace *struct { // The server supports workspace folder. WorkspaceFolders WorkspaceFoldersServerCapabilities `json:"workspaceFolders,omitempty"` // The server is interested in file notifications/requests. // // @since 3.16.0 FileOperations *struct { // The server is interested in receiving didCreateFiles notifications. DidCreate *FileOperationRegistrationOptions `json:"didCreate,omitempty"` // The server is interested in receiving willCreateFiles requests. WillCreate *FileOperationRegistrationOptions `json:"willCreate,omitempty"` // The server is interested in receiving didRenameFiles notifications. DidRename *FileOperationRegistrationOptions `json:"didRename,omitempty"` // The server is interested in receiving willRenameFiles requests. WillRename *FileOperationRegistrationOptions `json:"willRename,omitempty"` // The server is interested in receiving didDeleteFiles file notifications DidDelete *FileOperationRegistrationOptions `json:"didDelete,omitempty"` // The server is interested in receiving willDeleteFiles file requests. WillDelete *FileOperationRegistrationOptions `json:"willDelete,omitempty"` } `json:"fileOperations,omitempty"` } `json:"workspace,omitempty"` // Experimental server capabilities. Experimental interface{} `json:"experimental,omitempty"` } elvish-0.21.0/signature.go000066400000000000000000000126531465720375400154400ustar00rootroot00000000000000package lsp // ParameterInformation represents a parameter of a callable-signature. A // parameter can have a label and a doc-comment. type ParameterInformation struct { // The label of this parameter information. Label string `json:"label,omitempty"` // The human-readable doc-comment of this parameter. Will be shown in the UI // but can be omitted. Documentation MarkupContent `json:"documentation,omitempty"` } // SignatureInformation represents the signature of something callable. A // signature can have a label, like a function-name, a doc-comment, and a set of // parameters. type SignatureInformation struct { // The label of this signature. Will be shown in the UI. Label string `json:"label,omitempty"` // The human-readable doc-comment of this signature. Will be shown in the UI // but can be omitted. Documentation MarkupContent `json:"documentation,omitempty"` // The parameters of this signature. Parameters []ParameterInformation `json:"parameters"` // The index of the active parameter. // // If provided, this is used in place of `SignatureHelp.ActiveParameter`. // // @since 3.16.0 ActiveParameter uint `json:"activeParameter,omitempty"` } // SignatureHelp represents the signature of something callable. There can be // multiple signatures but only one active and only one active parameter. type SignatureHelp struct { // One or more signatures. If no signatures are available the signature help // request should return `null`. Signatures []SignatureInformation `json:"signatures"` // The active signature. If omitted or the value lies outside the // range of `signatures` the value defaults to zero or is ignore if // the `SignatureHelp` as no signatures. // // Whenever possible implementors should make an active decision about // the active signature and shouldn't rely on a default value. // // In future version of the protocol this property might become // mandatory to better express this. ActiveSignature int `json:"activeSignature"` // The active parameter of the active signature. If omitted or the value // lies outside the range of `signatures[activeSignature].parameters` // defaults to 0 if the active signature has parameters. If // the active signature has no parameters it is ignored. // In future version of the protocol this property might become // mandatory to better express the active parameter if the // active signature does have any. ActiveParameter int `json:"activeParameter"` } // SignatureHelpTriggerKind defines how a signature help was triggered. type SignatureHelpTriggerKind int const ( // SHTriggerKindInvoked means the signature help was invoked manually by the // user or by a command. SHTriggerKindInvoked SignatureHelpTriggerKind = iota + 1 // SHTriggerKindTriggerCharacter means the signature help was triggered by a // trigger character. SHTriggerKindTriggerCharacter // SHTriggerKindContentChange means the signature help was triggered by the // cursor moving or by the document content changing. SHTriggerKindContentChange ) func (shtk SignatureHelpTriggerKind) String() string { switch shtk { case SHTriggerKindInvoked: return "invoked" case SHTriggerKindTriggerCharacter: return "trigger character" case SHTriggerKindContentChange: return "content change" } return "" } // SignatureHelpContext contains additional information about the context in // which a signature help request was triggered. type SignatureHelpContext struct { // Action that caused signature help to be triggered. TriggerKind SignatureHelpTriggerKind `json:"triggerKind"` // Character that caused signature help to be triggered. // This is undefined when `TriggerKind != SHTriggerKindTriggerCharacter`. TriggerCharacter string `json:"triggerCharacter,omitempty"` // `true` if signature help was already showing when it was triggered. // // Retriggers occur when the signature help is already active and can be // caused by actions such as typing a trigger character, a cursor move, // or document content changes. IsRetrigger bool `json:"isRetrigger"` // The currently active `SignatureHelp`. // // The `ActiveSignatureHelp` has its `SignatureHelp.ActiveSignature` field // updated based on the user navigating through available signatures. ActiveSignatureHelp SignatureHelp `json:"activeSignatureHelp,omitempty"` } // SignatureHelpOptions contains the options for the signature help handler. type SignatureHelpOptions struct { WorkDoneProgressOptions // The characters that trigger signature help automatically. TriggerCharacters []string `json:"triggerCharacters,omitempty"` // List of characters that re-trigger signature help. // // These trigger characters are only active when signature help is already // showing. // All trigger characters are also counted as re-trigger characters. RetriggerCharacters []string `json:"retriggerCharacters,omitempty"` } // SignatureHelpRegistrationOptions contains the options for the signature help // handler registration. type SignatureHelpRegistrationOptions struct { TextDocumentRegistrationOptions SignatureHelpOptions } // SignatureHelpParams contains the fields sent in a // `textDocument/signatureHelp` request. type SignatureHelpParams struct { TextDocumentPositionParams WorkDoneProgressParams // The signature help context. // This is only available if the client specifies to send this using the // client capability `TextDocument.SignatureHelp.ContextSupport == true`. Context SignatureHelpContext `json:"context,omitempty"` } elvish-0.21.0/symbols.go000066400000000000000000000160531465720375400151250ustar00rootroot00000000000000package lsp // SymbolKind specifies the type of a symbol. type SymbolKind int const ( // SKFile denotes a file symbol kind. SKFile SymbolKind = iota + 1 // SKModule denotes a module symbol kind. SKModule // SKNamespace denotes a namespace symbol kind. SKNamespace // SKPackage denotes a package symbol kind. SKPackage // SKClass denotes a class symbol kind. SKClass // SKMethod denotes a method symbol kind. SKMethod // SKProperty denotes a property symbol kind. SKProperty // SKField denotes a field symbol kind. SKField // SKConstructor denotes a constructor symbol kind. SKConstructor // SKEnum denotes an enum symbol kind. SKEnum // SKInterface denotes an interface symbol kind. SKInterface // SKFunction denotes a function symbol kind. SKFunction // SKVariable denotes a variable symbol kind. SKVariable // SKConstant denotes a constant symbol kind. SKConstant // SKString denotes a string symbol kind. SKString // SKNumber denotes a number symbol kind. SKNumber // SKBoolean denotes a boolean symbol kind. SKBoolean // SKArray denotes an array symbol kind. SKArray // SKObject denotes an object symbol kind. SKObject // SKKey denotes a key symbol kind. SKKey // SKNull denotes a null symbol kind. SKNull // SKEnumMember denotes an enum member symbol kind. SKEnumMember // SKStruct denotes a struct symbol kind. SKStruct // SKEvent denotes an event symbol kind. SKEvent // SKOperator denotes an operator symbol kind. SKOperator // SKTypeParameter denotes a type parameter symbol kind. SKTypeParameter ) func (kind SymbolKind) String() string { switch kind { case SKFile: return "file" case SKModule: return "module" case SKNamespace: return "namespace" case SKPackage: return "package" case SKClass: return "class" case SKMethod: return "method" case SKProperty: return "property" case SKField: return "field" case SKConstructor: return "constructor" case SKEnum: return "enum" case SKInterface: return "interface" case SKFunction: return "function" case SKVariable: return "variable" case SKConstant: return "constant" case SKString: return "string" case SKNumber: return "number" case SKBoolean: return "boolean" case SKArray: return "array" case SKObject: return "object" case SKKey: return "key" case SKNull: return "null" case SKEnumMember: return "enum member" case SKStruct: return "struct" case SKEvent: return "event" case SKOperator: return "operator" case SKTypeParameter: return "type parameter" } return "" } // Symbol tags are extra annotations that tweak the rendering of a symbol. // // @since 3.16 type SymbolTag int const ( // STDeprecated will render a symbol as obsolete, usually using a strike-out. STDeprecated SymbolTag = iota + 1 ) func (tag SymbolTag) String() string { switch tag { case STDeprecated: return "deprecated" } return "" } // WorkspaceSymbolOptions is a literal for WorkDoneProgressOptions for symbols // in a workspace. type WorkspaceSymbolOptions struct { WorkDoneProgressOptions } // WorkspaceSymbolRegistrationOptions contains the workspace symbol registration // options. type WorkspaceSymbolRegistrationOptions struct { WorkspaceSymbolOptions } // WorkspaceSymbolParams contains the fields sent in a `workspace/symbol` // request. type WorkspaceSymbolParams struct { WorkDoneProgressParams PartialResultParams // A query string to filter symbols by. Clients may send an empty string here // to request all symbols. Query string `json:"query"` } // DocumentSymbol represents programming constructs like variables, classes, // interfaces etc. that appear in a document. Document symbols can be // hierarchical and they have two ranges: one that encloses its definition and // one that points to its most interesting range, for example, the range of an // identifier. type DocumentSymbol struct { // The name of this symbol. // Will be displayed in the user interface and therefore must not be // an empty string or a string only consisting of white spaces. Name string `json:"name"` // More detail for this symbol, e.g the signature of a function. Detail string `json:"detail,omitempty"` // The kind of this symbol. Kind SymbolKind `json:"kind"` // Tags for this document symbol. // // @since 3.16.0 Tags []SymbolTag `json:"tags,omitempty"` // Indicates if this symbol is deprecated. Deprecated bool `json:"deprecated,omitempty"` // The range enclosing this symbol not including leading/trailing // whitespace but everything else like comments. // This information is typically used to determine if the client's cursor // is inside the symbol to reveal in the symbol in the UI. Range *Range `json:"range"` // The range that should be selected and revealed when this symbol // is being picked, for example, the name of a function. // Must be contained by the `range`. SelectionRange *Range `json:"selectionRange"` // Children of this symbol, e.g. properties of a class. Children []DocumentSymbol `json:"children,omitempty"` } // SymbolInformation represents information about programming constructs like // variables, classes, interfaces etc. type SymbolInformation struct { // The name of this symbol Name string `json:"name"` // The kind of this symbol. Kind SymbolKind `json:"kind"` // Tags for this symbol. // // @since 3.16.0 Tags []SymbolTag `json:"tags,omitempty"` // Indicates if this symbol is deprecated. Deprecated bool `json:"deprecated,omitempty"` // The location of this symbol. The location's range is used by a tool // to reveal the location in the editor. If the symbol is selected in the // tool the range's start information is used to position the cursor. So // the range usually spans more then the actual symbol's name and does // normally include things like visibility modifiers. // // The range doesn't have to denote a node range in the sense of a abstract // syntax tree. It can therefore not be used to re-construct a hierarchy of // the symbols. Location Location `json:"location"` // The name of the symbol containing this symbol. This information is for // user interface purposes (e.g. to render a qualifier in the user interface // if necessary). It can't be used to re-infer a hierarchy for the document // symbols. ContainerName string `json:"containerName,omitempty"` } // DocumentSymbolOptions contains the options for the document symbol handler. type DocumentSymbolOptions struct { WorkDoneProgressOptions // A human-readable string that is shown when multiple outlines trees are // shown for the same document. // // @since 3.16.0 Label string `json:"label,omitempty"` } // DocumentSymbolRegistrationOptions contains the options for the document // symbol handler registration. type DocumentSymbolRegistrationOptions struct { TextDocumentRegistrationOptions DocumentHighlightOptions } // DocumentSymbolParams contains the fields sent in a // `textDocument/documentSymbol` request. type DocumentSymbolParams struct { WorkDoneProgressParams PartialResultParams // The text document. TextDocument TextDocumentIdentifier `json:"textDocument"` } elvish-0.21.0/textdocument.go000066400000000000000000000223521465720375400161570ustar00rootroot00000000000000package lsp // TextDocumentIdentifier encapsulates the URI of a given text document. type TextDocumentIdentifier struct { // The text document's URI. URI DocumentURI `json:"uri"` } // TextDocumentItem is an item to transfer a text document from the client to // the server. 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 increase after each change, // including undo/redo). Version int `json:"version"` // The content of the opened text document. Text string `json:"text"` } // VersionedTextDocumentIdentifier is an identifier to denote a specific version // of a text document. type VersionedTextDocumentIdentifier struct { TextDocumentIdentifier // The version number of this document. // If a versioned text document identifier is sent from the server to the // client and the file is not open in the editor (the server has not // received an open notification before), the server can send `null` to // indicate that the version is known and the content on disk is the // master (as specified with document content ownership). // // The version number of a document will increase after each change, // including undo/redo. The number doesn't need to be consecutive. Version int `json:"version,omitempty"` } // TextDocumentPositionParams is a parameter literal used in requests to pass a // text document and a position inside that document. type TextDocumentPositionParams struct { // The text document. TextDocument TextDocumentIdentifier `json:"textDocument"` // The position inside the text document. Position Position `json:"position"` } // DocumentFilter denotes a document through properties like `language`, // `scheme` or `pattern`. type DocumentFilter struct { // A language id, like `typescript`. Language string `json:"language,omitempty"` // A Uri [scheme](#Uri.scheme), like `file` or `untitled`. Scheme string `json:"scheme,omitempty"` // A glob pattern, like `*.{ts,js}`. Pattern string `json:"pattern,omitempty"` } // DocumentSelector is the combination of one or more document filters. type DocumentSelector []DocumentFilter // ChangeAnnotation represents dditional information that describes document // changes. // // @since 3.16.0 type ChangeAnnotation struct { // A human-readable string describing the actual change. The string is // rendered prominent in the user interface. Label string `json:"label"` // A flag which indicates that user confirmation is needed before applying the // change. NeedsConfirmation bool `json:"needsConfirmation,omitempty"` // A human-readable string which is rendered less prominent in the user // interface. Description string `json:"description,omitempty"` } // ChangeAnnotationIdentifier is an identifier referring to a change annotation // managed by a workspace edit. // // @since 3.16.0 type ChangeAnnotationIdentifier string // TextEdit represents a textual edit applicable to a text document. 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"` // The actual annotation identifier. // NOTE: The official LSP specification has a separate, `AnnotatedTextEdit` // structure that contains this field. Since generics are difficult to // replicate and use in Go, we have decided to add the field to the base // `TextEdit` struct, as the new structure overlaps this one anyway. // // @since 3.16.0 AnnotationID ChangeAnnotationIdentifier `json:"annotationId,omitempty"` } // TextDocumentEdit describes textual changes on a single text document. type TextDocumentEdit struct { // The text document to change. TextDocument VersionedTextDocumentIdentifier `json:"textDocument"` // The edits to be applied. Edits []TextEdit `json:"edits"` } // TextDocumentSyncKind defines how the host (editor) should sync document // changes to the language server. type TextDocumentSyncKind int const ( // TDSyncKindNone means documents should not be synced at all. TDSyncKindNone TextDocumentSyncKind = iota // TDSyncKindFull means cocuments are synced by always sending the full // content of the document. TDSyncKindFull // TDSyncKindIncremental means documents are synced by sending the full // content on open. After that only incremental updates to the document are // sent. TDSyncKindIncremental ) func (kind TextDocumentSyncKind) String() string { switch kind { case TDSyncKindNone: return "none" case TDSyncKindFull: return "full" case TDSyncKindIncremental: return "incremental" } return "" } // TextDocumentSyncOptions specifies the options for setting up text document // sync. type TextDocumentSyncOptions struct { // Open and close notifications are sent to the server. // If omitted open close notification should not be sent. OpenClose bool `json:"openClose,omitempty"` // Change notifications are sent to the server. // If omitted, it defaults to TDSyncKindNone. Change TextDocumentSyncKind `json:"change,omitempty"` // If present will save notifications are sent to the server. // If omitted, the notification should not be sent. WillSave bool `json:"willSave,omitempty"` // If present will save wait until requests are sent to the server. // If omitted, the request should not be sent. WillSaveWaitUntil bool `json:"willSaveWaitUntil,omitempty"` // If present save notifications are sent to the server. // If omitted, the notification should not be sent. Save *SaveOptions `json:"save,omitempty"` } // DidOpenTextDocumentParams contains the data the client sends through a // `textDocument/didOpen` request. type DidOpenTextDocumentParams struct { // The document that was opened. TextDocument TextDocumentItem `json:"textDocument"` } // TextDocumentChangeRegistrationOptions describes options to be used when // registering for text document change events. type TextDocumentChangeRegistrationOptions struct { TextDocumentRegistrationOptions // How documents are synced to the server. SyncKind TextDocumentSyncKind `json:"syncKind"` } // TextDocumentContentChangeEvent is an event describing a change to a text // document. type TextDocumentContentChangeEvent struct { // The range of the document that changed. Range *Range `json:"range,omitempty"` // The new text for the provided range or the whole document. Text string `json:"text"` } // DidChangeTextDocumentParams contains the data the client sends through a // `textDocument/didChange` notification. 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. ContentChanges []TextDocumentContentChangeEvent `json:"contentChanges"` } // TextDocumentSaveReason represents reasons why a text document is saved. type TextDocumentSaveReason int const ( // TDSaveReasonManual represents a document save that was manually triggered, // for example, by the user pressing save, by starting debugging, or by an API // call. TDSaveReasonManual TextDocumentSaveReason = iota + 1 // TDSaveReasonAfterDelay represents a document save that was automatic after // a delay. TDSaveReasonAfterDelay // TDSaveReasonFocusOut represents a document save that happened when the // editor lost focus. TDSaveReasonFocusOut ) func (reason TextDocumentSaveReason) String() string { switch reason { case TDSaveReasonManual: return "manual" case TDSaveReasonAfterDelay: return "after delay" case TDSaveReasonFocusOut: return "focus out" } return "" } // WillSaveTextDocumentParams contains the parameters sent in a will save text // document notification. type WillSaveTextDocumentParams struct { // The document that will be saved. TextDocument TextDocumentIdentifier `json:"textDocument"` // The 'TextDocumentSaveReason'. Reason TextDocumentSaveReason `json:"reason"` } // SaveOptions contains the options that need to be taken into consideration // when saving. type SaveOptions struct { // The client is supposed to include the content on save. IncludeText bool `json:"includeText,omitempty"` } // TextDocumentSaveRegistrationOptions contains the registration options of // textDocument/save. type TextDocumentSaveRegistrationOptions struct { TextDocumentRegistrationOptions // The client is supposed to include the content on save. IncludeText bool `json:"includeText,omitempty"` } // DidSaveTextDocumentParams contains the parameters sent in a // `textDocument/didSave` notification. type DidSaveTextDocumentParams struct { // The document that was saved. TextDocument TextDocumentIdentifier `json:"textDocument"` // Optional the content when saved. Depends on the includeText value // when the save notification was requested. Text string `json:"text,omitempty"` } // DidCloseTextDocumentParams contains the parameters sent in a // `textDocument/didClose` notification. type DidCloseTextDocumentParams struct { // The document that was closed. TextDocument TextDocumentIdentifier `json:"textDocument"` } elvish-0.21.0/workspace.go000066400000000000000000000167761465720375400154470ustar00rootroot00000000000000package lsp // WorkspaceFolder is a structure that defines the reference to a workspace // folder. type WorkspaceFolder struct { // The associated URI for this workspace folder. URI string `json:"uri"` // The name of the workspace folder. Used to refer to this workspace folder in // the user interface. Name string `json:"name"` } // WorkspaceFoldersChangeEvent contains information about a workspace folder // change event. type WorkspaceFoldersChangeEvent struct { // The array of added workspace folders. Added []WorkspaceFolder `json:"added"` // The array of removed workspace folders. Removed []WorkspaceFolder `json:"removed"` } // ResourceOperationKind defines a kind of resource operation. type ResourceOperationKind string const ( // ROKCreate refers to a file/folder creation operation. ROKCreate ResourceOperationKind = "create" // ROKRename refers to a file/folder rename operation. ROKRename = "rename" // ROKDelete refers to a file/folder deletion operation. ROKDelete = "delete" ) // FailureHandlingKind defines how the client should behave on a workspace edit // failure. type FailureHandlingKind string const ( // FHKAbort means applying the workspace change is simply aborted if one of // the changes provided fails. FHKAbort FailureHandlingKind = "abort" // FHKTransactional means all operations are executed transactional. That // means they either all succeed or no changes at all are applied to the // workspace. FHKTransactional = "transactional" // FHKTextOnlyTransactional means if the workspace edit contains only textual // file changes, they are executed transactionally. // If resource changes (create, rename or delete file) are part of the // change, the failure handling strategy is abort. FHKTextOnlyTransactional = "textOnlyTransactional" // FHKUndo means the client tries to undo the operations already executed. But // there is no guarantee that this is succeeding. FHKUndo = "undo" ) // CreateFileOptions contains options to create a file. type CreateFileOptions struct { // Overwrite existing file. Overwrite wins over `ignoreIfExists`. Overwrite bool `json:"overwrite,omitempty"` // Ignore if exists. IgnoreIfExists bool `json:"ignoreIfExists,omitempty"` } // CreateFile defines a file creation operation. type CreateFile struct { // Should always be "create" Kind string `json:"kind"` // The resource to create. URI DocumentURI `json:"uri"` // Additional options. Options CreateFileOptions `json:"options,omitempty"` // AnnotationID is an optional annotation identifer describing the operation. // // @since 3.16.0 AnnotationID ChangeAnnotationIdentifier `json:"annotationId,omitempty"` } // NewCreateFile instantiates a CreateFile struct. func NewCreateFile(URI DocumentURI, options CreateFileOptions) *CreateFile { return &CreateFile{ Kind: "create", URI: URI, Options: options, } } // RenameFileOptions contains options to rename a file. type RenameFileOptions struct { // Overwrite target if existing. Overwrite wins over `ignoreIfExists`. Overwrite bool `json:"overwrite,omitempty"` // Ignore if target exists. IgnoreIfExists bool `json:"ignoreIfExists,omitempty"` } // RenameFile defines a file rename operation. type RenameFile struct { // Should always be "rename" Kind string `json:"kind"` // The old (existing) location. OldURI DocumentURI `json:"oldUri"` // The new location. NewURI DocumentURI `json:"newUri"` // Additional options. Options RenameFileOptions `json:"options,omitempty"` // AnnotationID is an optional annotation identifer describing the operation. // // @since 3.16.0 AnnotationID ChangeAnnotationIdentifier `json:"annotationId,omitempty"` } // NewRenameFile instantiates a RenameFile struct. func NewRenameFile(oldURI, newURI DocumentURI, options RenameFileOptions) *RenameFile { return &RenameFile{ Kind: "rename", OldURI: oldURI, NewURI: newURI, Options: options, } } // DeleteFileOptions contains options to delete a file. type DeleteFileOptions struct { // Delete the content recursively if a folder is denoted. Recursive bool `json:"recursive,omitempty"` // Ignore the operation if the file doesn't exist. IgnoreIfNotExists bool `json:"ignoreIfNotExists,omitempty"` } // DeleteFile defines a file deletion operation. type DeleteFile struct { // Should always be "delete". Kind string `json:"kind"` // The file to delete. URI DocumentURI `json:"uri"` // Additional options. Options DeleteFileOptions `json:"options,omitempty"` // AnnotationID is an optional annotation identifer describing the operation. // // @since 3.16.0 AnnotationID ChangeAnnotationIdentifier `json:"annotationId,omitempty"` } // NewDeleteFile instantiates a DeleteFile struct. func NewDeleteFile(URI DocumentURI, options DeleteFileOptions) *DeleteFile { return &DeleteFile{ Kind: "delete", URI: URI, Options: options, } } // WorkspaceEditDocumentChange is an interface that can be interpreted as a // `TextDocumentEdit`, `CreateFile`, `RenameFile`, or `DeleteFile`. type WorkspaceEditDocumentChange interface{} // WorkspaceEdit represents changes to many resources managed in the workspace. type WorkspaceEdit struct { // Holds changes to existing resources. Changes map[DocumentURI][]TextEdit `json:"changes,omitempty"` // The client capability `workspace.workspaceEdit.resourceOperations` // determines whether document changes are either an array of // `TextDocumentEdit`s to express changes to different text documents, // where each text document edit addresses a specific version // of a text document, or it can contains the above `TextDocumentEdit`s // mixed with create, rename, and delete file / folder operations. // // Whether a client supports versioned document edits is expressed via // `workspace.workspaceEdit.documentChanges` client capability. // // If a client doesn't support `documentChanges` or // `workspace.workspaceEdit.resourceOperations`, then only plain // `TextEdit`s using the `changes` property are supported. DocumentChanges []WorkspaceEditDocumentChange `json:"documentChanges,omitempty"` // A map of change annotations that can be referenced in `AnnotatedTextEdit`s // or create, rename and delete file / folder operations. // // Whether clients honor this property depends on the client capability // `workspace.changeAnnotationSupport`. // // @since 3.16.0 ChangeAnnotations map[ChangeAnnotationIdentifier]*ChangeAnnotation `json:"changeAnnotations,omitempty"` } // DidChangeWorkspaceFoldersParams are the parameters contained in a // `workspace/didChangeWorkspaceFolders` notification. type DidChangeWorkspaceFoldersParams struct { // The actual workspace folder change event. Event WorkspaceFoldersChangeEvent `json:"event"` } // ApplyWorkspaceEditParams contains the fields sent in a `workspace/applyEdit` // request. type ApplyWorkspaceEditParams struct { // An optional label of the workspace edit. This label is // presented in the user interface for example on an undo // stack to undo the workspace edit. Label string `json:"label,omitempty"` // The edits to apply. Edit WorkspaceEdit `json:"edit"` } // ApplyWorkspaceEditResponse contains the fields from a `workspace/applyEdit` // response. type ApplyWorkspaceEditResponse struct { // Indicates whether the edit was applied or not. Applied bool `json:"applied"` // An optional textual description for why the edit was not applied. // This may be used may be used by the server for diagnostic // logging or to provide a suitable error for a request that // triggered the edit. FailureReason string `json:"failureReason,omitempty"` }