github.com/tiagovtristao/plz@v13.4.0+incompatible/tools/build_langserver/lsp/service.go (about) 1 package lsp 2 3 import "github.com/sourcegraph/jsonrpc2" 4 5 // ServerCapabilities Defines how text documents are synced. 6 type ServerCapabilities struct { 7 /** 8 * Defines how text documents are synced. Is either a detailed structure defining each notification or 9 * for backwards compatibility the TextDocumentSyncKind number. If omitted it defaults to `TextDocumentSyncKind.None`. 10 */ 11 TextDocumentSync *TextDocumentSyncKind `json:"textDocumentSync,omitempty"` 12 13 HoverProvider bool `json:"hoverProvider"` 14 CompletionProvider *CompletionOptions `json:"completionProvider"` 15 SignatureHelpProvider *SignatureHelpOptions `json:"signatureHelpProvider"` 16 DefinitionProvider bool `json:"definitionProvider"` 17 TypeDefinitionProvider bool `json:"typeDefinitionProvider,omitempty"` 18 ImplementationProvider bool `json:"implementationProvider,omitempty"` 19 ReferencesProvider bool `json:"referenceProvider,omitempty"` 20 RenameProvider bool `json:"renameProvider,omitempty"` 21 DocumentSymbolProvider bool `json:"documentSymbolProvider,omitempty"` 22 DocumentHighlightProvider bool `json:"documentHighlightProvider,omitempty"` 23 DocumentFormattingProvider bool `json:"documentFormattingProvider,omitempty"` 24 } 25 26 // TextDocumentPositionParams is a parameter literal used in requests to pass a text document 27 // and a position inside that document 28 type TextDocumentPositionParams struct { 29 /** 30 * The text document. 31 */ 32 TextDocument TextDocumentIdentifier `json:"textDocument"` 33 34 /** 35 * The position inside the text document. 36 */ 37 Position Position `json:"position"` 38 } 39 40 // TextDocumentSyncOptions defines the open and close notifications are sent to the server. 41 // TODO(bnmetrics): this might not be needed 42 type TextDocumentSyncOptions struct { 43 OpenClose bool `json:"openClose"` 44 Change *TextDocumentSyncKind `json:"change"` 45 WillSave bool `json:"willSave,omitempty"` 46 WillSaveWaitUtil bool `json:"willSaveWaitUntil"` 47 Save *SaveOptions `json:"save"` 48 } 49 50 // SaveOptions are the options for dealing with saving files 51 type SaveOptions struct { 52 /** 53 * The client is supposed to include the content on save. 54 */ 55 IncludeText bool `json:"includeText"` 56 } 57 58 // CompletionOptions is a list of options server provides for completion support 59 type CompletionOptions struct { 60 ResolveProvider bool `json:"resolveProvider,omitempty"` 61 TriggerCharacters []string `json:"triggerCharacters,omitempty"` 62 } 63 64 // SignatureHelpOptions indicate the server provides signature help support 65 type SignatureHelpOptions struct { 66 TriggerCharacters []string `json:"triggerCharacters,omitempty"` 67 } 68 69 // SignatureHelp is the response from "textDocument/signatureHelp" 70 // represents the signature of something callable. 71 type SignatureHelp struct { 72 Signatures []SignatureInformation `json:"signatures"` 73 ActiveSignature int `json:"activeSignature"` 74 ActiveParameter int `json:"activeParameter"` 75 } 76 77 // SignatureInformation represents the signature of something callable. 78 type SignatureInformation struct { 79 Label string `json:"label"` 80 Documentation string `json:"documentation,omitempty"` 81 Parameters []ParameterInformation `json:"parameters,omitempty"` 82 } 83 84 // ParameterInformation represents a parameter of a callable-signature. A parameter can 85 // have a label and a doc-comment. 86 type ParameterInformation struct { 87 Label string `json:"label"` 88 Documentation string `json:"documentation,omitempty"` 89 } 90 91 // CancelParams is the params send to ‘$/cancelRequest’ method 92 type CancelParams struct { 93 ID jsonrpc2.ID `json:"id"` 94 } 95 96 // DidOpenTextDocumentParams is sent from client to the server when the document that was opened. 97 type DidOpenTextDocumentParams struct { 98 TextDocument TextDocumentItem `json:"textDocument"` 99 } 100 101 // DidChangeTextDocumentParams is sent from client to the server to signal changes to a text document 102 type DidChangeTextDocumentParams struct { 103 TextDocument VersionedTextDocumentIdentifier `json:"textDocument"` 104 ContentChanges []TextDocumentContentChangeEvent `json:"contentChanges"` 105 } 106 107 // TextDocumentContentChangeEvent an event describing a change to a text document. If range and rangeLength are omitted 108 // the new text is considered to be the full content of the document. 109 type TextDocumentContentChangeEvent struct { 110 Range *Range `json:"range,omitEmpty"` 111 RangeLength uint `json:"rangeLength,omitEmpty"` 112 Text string `json:"text"` 113 } 114 115 // DidCloseTextDocumentParams is sent from the client to the server when the document got closed in the client. 116 type DidCloseTextDocumentParams struct { 117 TextDocument TextDocumentIdentifier `json:"textDocument"` 118 } 119 120 // DidSaveTextDocumentParams is sent from the client to the server when the document was saved in the client. 121 type DidSaveTextDocumentParams struct { 122 TextDocument TextDocumentIdentifier `json:"textDocument"` 123 Text string `json:"text,omitempty"` 124 } 125 126 // WillSaveTextDocumentParams is sent from the client to the server before the document is actually saved. 127 type WillSaveTextDocumentParams struct { 128 TextDocument TextDocumentIdentifier `json:"textDocument"` 129 Reason TextDocumentSaveReason `json:"reason,omitempty"` 130 } 131 132 // Hover is the result of a hover request. 133 type Hover struct { 134 Contents []MarkedString `json:"contents"` 135 Range *Range `json:"range,omitempty"` 136 } 137 138 // CompletionParams is the struct for parameters send to "textDocument/completion" request 139 type CompletionParams struct { 140 TextDocumentPositionParams 141 Context CompletionContext `json:"context,omitempty"` 142 } 143 144 // CompletionContext Contains additional information about the context in which a completion request is triggered. 145 type CompletionContext struct { 146 TriggerKind CompletionTriggerKind `json:"triggerKind"` 147 TriggerCharacter string `json:"triggerCharacter,omitempty"` 148 } 149 150 // CompletionList Represents a collection of [completion items](#CompletionItem) to be presented 151 // in the editor. 152 type CompletionList struct { 153 IsIncomplete bool `json:"isIncomplete"` 154 Items []*CompletionItem `json:"items"` 155 } 156 157 // CompletionItem represents The completion items. 158 type CompletionItem struct { 159 Label string `json:"label"` 160 Kind CompletionItemKind `json:"kind,omitempty"` 161 Detail string `json:"detail,omitempty"` 162 Documentation string `json:"documentation,omitempty"` 163 SortText string `json:"sortText,omitempty"` 164 FilterText string `json:"filterText,omitempty"` 165 InsertText string `json:"insertText,omitempty"` 166 InsertTextFormat InsertTextFormat `json:"insertTextFormat,omitempty"` 167 TextEdit *TextEdit `json:"textEdit,omitempty"` 168 Data interface{} `json:"data,omitempty"` 169 } 170 171 // PublishDiagnosticsParams is the params sent from the server to the client for textDocument/publishDiagnostics method 172 type PublishDiagnosticsParams struct { 173 URI DocumentURI `json:"uri"` 174 Diagnostics []*Diagnostic `json:"diagnostics"` 175 } 176 177 // DocumentFormattingParams is the params sent from the client for textDocument/formatting request 178 type DocumentFormattingParams struct { 179 TextDocument TextDocumentIdentifier `json:"textDocument"` 180 Options FormattingOptions `json:"options"` 181 } 182 183 // FormattingOptions represent Value-object describing what options formatting should use. 184 type FormattingOptions struct { 185 TabSize int `json:"tabSize"` 186 InsertSpaces bool `json:"insertSpaces"` 187 Key string `json:"key"` 188 } 189 190 // ReferenceParams is the params sent from the client for textDocument/references request 191 type ReferenceParams struct { 192 *TextDocumentPositionParams 193 194 Context ReferenceContext `json:"context"` 195 } 196 197 // ReferenceContext is the context used in ReferenceParams 198 type ReferenceContext struct { 199 IncludeDeclaration bool `json:"includeDeclaration"` 200 } 201 202 // RenameParams is the params sent from the client for textDocument/rename request 203 type RenameParams struct { 204 TextDocument TextDocumentIdentifier `json:"textDocument"` 205 Position Position `json:"position"` 206 NewName string `json:"newName"` 207 }