1// Generated code. Do not edit
2package lsp
3
4import (
5 "context"
6 "log/slog"
7 "time"
8
9 "github.com/charmbracelet/crush/internal/config"
10 "github.com/charmbracelet/crush/internal/lsp/protocol"
11)
12
13// Implementation sends a textDocument/implementation request to the LSP server.
14// A request to resolve the implementation locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such.
15func (c *Client) Implementation(ctx context.Context, params protocol.ImplementationParams) (protocol.Or_Result_textDocument_implementation, error) {
16 var result protocol.Or_Result_textDocument_implementation
17 err := c.Call(ctx, "textDocument/implementation", params, &result)
18 return result, err
19}
20
21// TypeDefinition sends a textDocument/typeDefinition request to the LSP server.
22// A request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Definition or a Thenable that resolves to such.
23func (c *Client) TypeDefinition(ctx context.Context, params protocol.TypeDefinitionParams) (protocol.Or_Result_textDocument_typeDefinition, error) {
24 var result protocol.Or_Result_textDocument_typeDefinition
25 err := c.Call(ctx, "textDocument/typeDefinition", params, &result)
26 return result, err
27}
28
29// DocumentColor sends a textDocument/documentColor request to the LSP server.
30// A request to list all color symbols found in a given text document. The request's parameter is of type DocumentColorParams the response is of type ColorInformation ColorInformation[] or a Thenable that resolves to such.
31func (c *Client) DocumentColor(ctx context.Context, params protocol.DocumentColorParams) ([]protocol.ColorInformation, error) {
32 var result []protocol.ColorInformation
33 err := c.Call(ctx, "textDocument/documentColor", params, &result)
34 return result, err
35}
36
37// ColorPresentation sends a textDocument/colorPresentation request to the LSP server.
38// A request to list all presentation for a color. The request's parameter is of type ColorPresentationParams the response is of type ColorInformation ColorInformation[] or a Thenable that resolves to such.
39func (c *Client) ColorPresentation(ctx context.Context, params protocol.ColorPresentationParams) ([]protocol.ColorPresentation, error) {
40 var result []protocol.ColorPresentation
41 err := c.Call(ctx, "textDocument/colorPresentation", params, &result)
42 return result, err
43}
44
45// FoldingRange sends a textDocument/foldingRange request to the LSP server.
46// A request to provide folding ranges in a document. The request's parameter is of type FoldingRangeParams, the response is of type FoldingRangeList or a Thenable that resolves to such.
47func (c *Client) FoldingRange(ctx context.Context, params protocol.FoldingRangeParams) ([]protocol.FoldingRange, error) {
48 var result []protocol.FoldingRange
49 err := c.Call(ctx, "textDocument/foldingRange", params, &result)
50 return result, err
51}
52
53// Declaration sends a textDocument/declaration request to the LSP server.
54// A request to resolve the type definition locations of a symbol at a given text document position. The request's parameter is of type TextDocumentPositionParams the response is of type Declaration or a typed array of DeclarationLink or a Thenable that resolves to such.
55func (c *Client) Declaration(ctx context.Context, params protocol.DeclarationParams) (protocol.Or_Result_textDocument_declaration, error) {
56 var result protocol.Or_Result_textDocument_declaration
57 err := c.Call(ctx, "textDocument/declaration", params, &result)
58 return result, err
59}
60
61// SelectionRange sends a textDocument/selectionRange request to the LSP server.
62// A request to provide selection ranges in a document. The request's parameter is of type SelectionRangeParams, the response is of type SelectionRange SelectionRange[] or a Thenable that resolves to such.
63func (c *Client) SelectionRange(ctx context.Context, params protocol.SelectionRangeParams) ([]protocol.SelectionRange, error) {
64 var result []protocol.SelectionRange
65 err := c.Call(ctx, "textDocument/selectionRange", params, &result)
66 return result, err
67}
68
69// PrepareCallHierarchy sends a textDocument/prepareCallHierarchy request to the LSP server.
70// A request to result a CallHierarchyItem in a document at a given position. Can be used as an input to an incoming or outgoing call hierarchy. Since 3.16.0
71func (c *Client) PrepareCallHierarchy(ctx context.Context, params protocol.CallHierarchyPrepareParams) ([]protocol.CallHierarchyItem, error) {
72 var result []protocol.CallHierarchyItem
73 err := c.Call(ctx, "textDocument/prepareCallHierarchy", params, &result)
74 return result, err
75}
76
77// IncomingCalls sends a callHierarchy/incomingCalls request to the LSP server.
78// A request to resolve the incoming calls for a given CallHierarchyItem. Since 3.16.0
79func (c *Client) IncomingCalls(ctx context.Context, params protocol.CallHierarchyIncomingCallsParams) ([]protocol.CallHierarchyIncomingCall, error) {
80 var result []protocol.CallHierarchyIncomingCall
81 err := c.Call(ctx, "callHierarchy/incomingCalls", params, &result)
82 return result, err
83}
84
85// OutgoingCalls sends a callHierarchy/outgoingCalls request to the LSP server.
86// A request to resolve the outgoing calls for a given CallHierarchyItem. Since 3.16.0
87func (c *Client) OutgoingCalls(ctx context.Context, params protocol.CallHierarchyOutgoingCallsParams) ([]protocol.CallHierarchyOutgoingCall, error) {
88 var result []protocol.CallHierarchyOutgoingCall
89 err := c.Call(ctx, "callHierarchy/outgoingCalls", params, &result)
90 return result, err
91}
92
93// SemanticTokensFull sends a textDocument/semanticTokens/full request to the LSP server.
94// Since 3.16.0
95func (c *Client) SemanticTokensFull(ctx context.Context, params protocol.SemanticTokensParams) (protocol.SemanticTokens, error) {
96 var result protocol.SemanticTokens
97 err := c.Call(ctx, "textDocument/semanticTokens/full", params, &result)
98 return result, err
99}
100
101// SemanticTokensFullDelta sends a textDocument/semanticTokens/full/delta request to the LSP server.
102// Since 3.16.0
103func (c *Client) SemanticTokensFullDelta(ctx context.Context, params protocol.SemanticTokensDeltaParams) (protocol.Or_Result_textDocument_semanticTokens_full_delta, error) {
104 var result protocol.Or_Result_textDocument_semanticTokens_full_delta
105 err := c.Call(ctx, "textDocument/semanticTokens/full/delta", params, &result)
106 return result, err
107}
108
109// SemanticTokensRange sends a textDocument/semanticTokens/range request to the LSP server.
110// Since 3.16.0
111func (c *Client) SemanticTokensRange(ctx context.Context, params protocol.SemanticTokensRangeParams) (protocol.SemanticTokens, error) {
112 var result protocol.SemanticTokens
113 err := c.Call(ctx, "textDocument/semanticTokens/range", params, &result)
114 return result, err
115}
116
117// LinkedEditingRange sends a textDocument/linkedEditingRange request to the LSP server.
118// A request to provide ranges that can be edited together. Since 3.16.0
119func (c *Client) LinkedEditingRange(ctx context.Context, params protocol.LinkedEditingRangeParams) (protocol.LinkedEditingRanges, error) {
120 var result protocol.LinkedEditingRanges
121 err := c.Call(ctx, "textDocument/linkedEditingRange", params, &result)
122 return result, err
123}
124
125// WillCreateFiles sends a workspace/willCreateFiles request to the LSP server.
126// The will create files request is sent from the client to the server before files are actually created as long as the creation is triggered from within the client. The request can return a WorkspaceEdit which will be applied to workspace before the files are created. Hence the WorkspaceEdit can not manipulate the content of the file to be created. Since 3.16.0
127func (c *Client) WillCreateFiles(ctx context.Context, params protocol.CreateFilesParams) (protocol.WorkspaceEdit, error) {
128 var result protocol.WorkspaceEdit
129 err := c.Call(ctx, "workspace/willCreateFiles", params, &result)
130 return result, err
131}
132
133// WillRenameFiles sends a workspace/willRenameFiles request to the LSP server.
134// The will rename files request is sent from the client to the server before files are actually renamed as long as the rename is triggered from within the client. Since 3.16.0
135func (c *Client) WillRenameFiles(ctx context.Context, params protocol.RenameFilesParams) (protocol.WorkspaceEdit, error) {
136 var result protocol.WorkspaceEdit
137 err := c.Call(ctx, "workspace/willRenameFiles", params, &result)
138 return result, err
139}
140
141// WillDeleteFiles sends a workspace/willDeleteFiles request to the LSP server.
142// The did delete files notification is sent from the client to the server when files were deleted from within the client. Since 3.16.0
143func (c *Client) WillDeleteFiles(ctx context.Context, params protocol.DeleteFilesParams) (protocol.WorkspaceEdit, error) {
144 var result protocol.WorkspaceEdit
145 err := c.Call(ctx, "workspace/willDeleteFiles", params, &result)
146 return result, err
147}
148
149// Moniker sends a textDocument/moniker request to the LSP server.
150// A request to get the moniker of a symbol at a given text document position. The request parameter is of type TextDocumentPositionParams. The response is of type Moniker Moniker[] or null.
151func (c *Client) Moniker(ctx context.Context, params protocol.MonikerParams) ([]protocol.Moniker, error) {
152 var result []protocol.Moniker
153 err := c.Call(ctx, "textDocument/moniker", params, &result)
154 return result, err
155}
156
157// PrepareTypeHierarchy sends a textDocument/prepareTypeHierarchy request to the LSP server.
158// A request to result a TypeHierarchyItem in a document at a given position. Can be used as an input to a subtypes or supertypes type hierarchy. Since 3.17.0
159func (c *Client) PrepareTypeHierarchy(ctx context.Context, params protocol.TypeHierarchyPrepareParams) ([]protocol.TypeHierarchyItem, error) {
160 var result []protocol.TypeHierarchyItem
161 err := c.Call(ctx, "textDocument/prepareTypeHierarchy", params, &result)
162 return result, err
163}
164
165// Supertypes sends a typeHierarchy/supertypes request to the LSP server.
166// A request to resolve the supertypes for a given TypeHierarchyItem. Since 3.17.0
167func (c *Client) Supertypes(ctx context.Context, params protocol.TypeHierarchySupertypesParams) ([]protocol.TypeHierarchyItem, error) {
168 var result []protocol.TypeHierarchyItem
169 err := c.Call(ctx, "typeHierarchy/supertypes", params, &result)
170 return result, err
171}
172
173// Subtypes sends a typeHierarchy/subtypes request to the LSP server.
174// A request to resolve the subtypes for a given TypeHierarchyItem. Since 3.17.0
175func (c *Client) Subtypes(ctx context.Context, params protocol.TypeHierarchySubtypesParams) ([]protocol.TypeHierarchyItem, error) {
176 var result []protocol.TypeHierarchyItem
177 err := c.Call(ctx, "typeHierarchy/subtypes", params, &result)
178 return result, err
179}
180
181// InlineValue sends a textDocument/inlineValue request to the LSP server.
182// A request to provide inline values in a document. The request's parameter is of type InlineValueParams, the response is of type InlineValue InlineValue[] or a Thenable that resolves to such. Since 3.17.0
183func (c *Client) InlineValue(ctx context.Context, params protocol.InlineValueParams) ([]protocol.InlineValue, error) {
184 var result []protocol.InlineValue
185 err := c.Call(ctx, "textDocument/inlineValue", params, &result)
186 return result, err
187}
188
189// InlayHint sends a textDocument/inlayHint request to the LSP server.
190// A request to provide inlay hints in a document. The request's parameter is of type InlayHintsParams, the response is of type InlayHint InlayHint[] or a Thenable that resolves to such. Since 3.17.0
191func (c *Client) InlayHint(ctx context.Context, params protocol.InlayHintParams) ([]protocol.InlayHint, error) {
192 var result []protocol.InlayHint
193 err := c.Call(ctx, "textDocument/inlayHint", params, &result)
194 return result, err
195}
196
197// Resolve sends a inlayHint/resolve request to the LSP server.
198// A request to resolve additional properties for an inlay hint. The request's parameter is of type InlayHint, the response is of type InlayHint or a Thenable that resolves to such. Since 3.17.0
199func (c *Client) Resolve(ctx context.Context, params protocol.InlayHint) (protocol.InlayHint, error) {
200 var result protocol.InlayHint
201 err := c.Call(ctx, "inlayHint/resolve", params, &result)
202 return result, err
203}
204
205// Diagnostic sends a textDocument/diagnostic request to the LSP server.
206// The document diagnostic request definition. Since 3.17.0
207func (c *Client) Diagnostic(ctx context.Context, params protocol.DocumentDiagnosticParams) (protocol.DocumentDiagnosticReport, error) {
208 var result protocol.DocumentDiagnosticReport
209 err := c.Call(ctx, "textDocument/diagnostic", params, &result)
210 return result, err
211}
212
213// DiagnosticWorkspace sends a workspace/diagnostic request to the LSP server.
214// The workspace diagnostic request definition. Since 3.17.0
215func (c *Client) DiagnosticWorkspace(ctx context.Context, params protocol.WorkspaceDiagnosticParams) (protocol.WorkspaceDiagnosticReport, error) {
216 var result protocol.WorkspaceDiagnosticReport
217 err := c.Call(ctx, "workspace/diagnostic", params, &result)
218 return result, err
219}
220
221// InlineCompletion sends a textDocument/inlineCompletion request to the LSP server.
222// A request to provide inline completions in a document. The request's parameter is of type InlineCompletionParams, the response is of type InlineCompletion InlineCompletion[] or a Thenable that resolves to such. Since 3.18.0 PROPOSED
223func (c *Client) InlineCompletion(ctx context.Context, params protocol.InlineCompletionParams) (protocol.Or_Result_textDocument_inlineCompletion, error) {
224 var result protocol.Or_Result_textDocument_inlineCompletion
225 err := c.Call(ctx, "textDocument/inlineCompletion", params, &result)
226 return result, err
227}
228
229// TextDocumentContent sends a workspace/textDocumentContent request to the LSP server.
230// The workspace/textDocumentContent request is sent from the client to the server to request the content of a text document. Since 3.18.0 PROPOSED
231func (c *Client) TextDocumentContent(ctx context.Context, params protocol.TextDocumentContentParams) (string, error) {
232 var result string
233 err := c.Call(ctx, "workspace/textDocumentContent", params, &result)
234 return result, err
235}
236
237// Initialize sends a initialize request to the LSP server.
238// The initialize request is sent from the client to the server. It is sent once as the request after starting up the server. The requests parameter is of type InitializeParams the response if of type InitializeResult of a Thenable that resolves to such.
239func (c *Client) Initialize(ctx context.Context, params protocol.ParamInitialize) (protocol.InitializeResult, error) {
240 var result protocol.InitializeResult
241 err := c.Call(ctx, "initialize", params, &result)
242 return result, err
243}
244
245// Shutdown sends a shutdown request to the LSP server and cleans up resources.
246// A shutdown request is sent from the client to the server. It is sent once when the client decides to shutdown the server. The only notification that is sent after a shutdown request is the exit event.
247func (c *Client) Shutdown(ctx context.Context) error {
248 var shutdownErr error
249 c.shutdownOnce.Do(func() {
250 cfg := config.Get()
251
252 // Step 1: Send shutdown request (expects a response)
253 if cfg.Options.DebugLSP {
254 slog.Debug("Sending LSP shutdown request", "name", c.name)
255 }
256
257 shutdownCtx, cancel := context.WithTimeout(ctx, 2*time.Second)
258 defer cancel()
259
260 if err := c.Call(shutdownCtx, "shutdown", nil, nil); err != nil {
261 // Log but don't fail - server might already be shutting down
262 slog.Warn("LSP shutdown request failed", "name", c.name, "error", err)
263 shutdownErr = err
264 }
265
266 // Step 2: Send exit notification (no response expected)
267 if cfg.Options.DebugLSP {
268 slog.Debug("Sending LSP exit notification", "name", c.name)
269 }
270
271 if err := c.Notify(ctx, "exit", nil); err != nil {
272 slog.Warn("LSP exit notification failed", "name", c.name, "error", err)
273 }
274
275 // Step 3: Signal our goroutines to stop
276 close(c.shutdownChan)
277
278 // Step 4: Clean up resources
279 c.cleanupResources()
280
281 // Step 5: Wait for goroutines with timeout
282 done := make(chan struct{})
283 go func() {
284 <-c.stderrDone
285 <-c.messageHandlerDone
286 <-c.healthCheckDone
287 close(done)
288 }()
289
290 select {
291 case <-done:
292 if cfg.Options.DebugLSP {
293 slog.Debug("LSP goroutines stopped cleanly", "name", c.name)
294 }
295 case <-time.After(2 * time.Second):
296 slog.Warn("Timeout waiting for LSP goroutines", "name", c.name)
297 }
298 })
299 return shutdownErr
300}
301
302// cleanupResources closes all handlers and cleans up internal state
303func (c *Client) cleanupResources() {
304 // Close all pending request handlers
305 c.handlersMu.Lock()
306 for id, ch := range c.handlers {
307 close(ch)
308 delete(c.handlers, id)
309 }
310 c.handlersMu.Unlock()
311
312 // Clear pending requests tracking
313 c.pendingRequestsMu.Lock()
314 for id := range c.pendingRequests {
315 delete(c.pendingRequests, id)
316 }
317 c.pendingRequestsMu.Unlock()
318
319 // Clear open files
320 c.openFilesMu.Lock()
321 for uri := range c.openFiles {
322 delete(c.openFiles, uri)
323 }
324 c.openFilesMu.Unlock()
325
326 // Clear diagnostics
327 c.diagnosticsMu.Lock()
328 for uri := range c.diagnostics {
329 delete(c.diagnostics, uri)
330 }
331 c.diagnosticsMu.Unlock()
332}
333
334// WillSaveWaitUntil sends a textDocument/willSaveWaitUntil request to the LSP server.
335// A document will save request is sent from the client to the server before the document is actually saved. The request can return an array of TextEdits which will be applied to the text document before it is saved. Please note that clients might drop results if computing the text edits took too long or if a server constantly fails on this request. This is done to keep the save fast and reliable.
336func (c *Client) WillSaveWaitUntil(ctx context.Context, params protocol.WillSaveTextDocumentParams) ([]protocol.TextEdit, error) {
337 var result []protocol.TextEdit
338 err := c.Call(ctx, "textDocument/willSaveWaitUntil", params, &result)
339 return result, err
340}
341
342// Completion sends a textDocument/completion request to the LSP server.
343// Request to request completion at a given text document position. The request's parameter is of type TextDocumentPosition the response is of type CompletionItem CompletionItem[] or CompletionList or a Thenable that resolves to such. The request can delay the computation of the CompletionItem.detail detail and CompletionItem.documentation documentation properties to the completionItem/resolve request. However, properties that are needed for the initial sorting and filtering, like sortText, filterText, insertText, and textEdit, must not be changed during resolve.
344func (c *Client) Completion(ctx context.Context, params protocol.CompletionParams) (protocol.Or_Result_textDocument_completion, error) {
345 var result protocol.Or_Result_textDocument_completion
346 err := c.Call(ctx, "textDocument/completion", params, &result)
347 return result, err
348}
349
350// ResolveCompletionItem sends a completionItem/resolve request to the LSP server.
351// Request to resolve additional information for a given completion item.The request's parameter is of type CompletionItem the response is of type CompletionItem or a Thenable that resolves to such.
352func (c *Client) ResolveCompletionItem(ctx context.Context, params protocol.CompletionItem) (protocol.CompletionItem, error) {
353 var result protocol.CompletionItem
354 err := c.Call(ctx, "completionItem/resolve", params, &result)
355 return result, err
356}
357
358// Hover sends a textDocument/hover request to the LSP server.
359// Request to request hover information at a given text document position. The request's parameter is of type TextDocumentPosition the response is of type Hover or a Thenable that resolves to such.
360func (c *Client) Hover(ctx context.Context, params protocol.HoverParams) (protocol.Hover, error) {
361 var result protocol.Hover
362 err := c.Call(ctx, "textDocument/hover", params, &result)
363 return result, err
364}
365
366// SignatureHelp sends a textDocument/signatureHelp request to the LSP server.
367func (c *Client) SignatureHelp(ctx context.Context, params protocol.SignatureHelpParams) (protocol.SignatureHelp, error) {
368 var result protocol.SignatureHelp
369 err := c.Call(ctx, "textDocument/signatureHelp", params, &result)
370 return result, err
371}
372
373// Definition sends a textDocument/definition request to the LSP server.
374// A request to resolve the definition location of a symbol at a given text document position. The request's parameter is of type TextDocumentPosition the response is of either type Definition or a typed array of DefinitionLink or a Thenable that resolves to such.
375func (c *Client) Definition(ctx context.Context, params protocol.DefinitionParams) (protocol.Or_Result_textDocument_definition, error) {
376 var result protocol.Or_Result_textDocument_definition
377 err := c.Call(ctx, "textDocument/definition", params, &result)
378 return result, err
379}
380
381// References sends a textDocument/references request to the LSP server.
382// A request to resolve project-wide references for the symbol denoted by the given text document position. The request's parameter is of type ReferenceParams the response is of type Location Location[] or a Thenable that resolves to such.
383func (c *Client) References(ctx context.Context, params protocol.ReferenceParams) ([]protocol.Location, error) {
384 var result []protocol.Location
385 err := c.Call(ctx, "textDocument/references", params, &result)
386 return result, err
387}
388
389// DocumentHighlight sends a textDocument/documentHighlight request to the LSP server.
390// Request to resolve a DocumentHighlight for a given text document position. The request's parameter is of type TextDocumentPosition the request response is an array of type DocumentHighlight or a Thenable that resolves to such.
391func (c *Client) DocumentHighlight(ctx context.Context, params protocol.DocumentHighlightParams) ([]protocol.DocumentHighlight, error) {
392 var result []protocol.DocumentHighlight
393 err := c.Call(ctx, "textDocument/documentHighlight", params, &result)
394 return result, err
395}
396
397// DocumentSymbol sends a textDocument/documentSymbol request to the LSP server.
398// A request to list all symbols found in a given text document. The request's parameter is of type TextDocumentIdentifier the response is of type SymbolInformation SymbolInformation[] or a Thenable that resolves to such.
399func (c *Client) DocumentSymbol(ctx context.Context, params protocol.DocumentSymbolParams) (protocol.Or_Result_textDocument_documentSymbol, error) {
400 var result protocol.Or_Result_textDocument_documentSymbol
401 err := c.Call(ctx, "textDocument/documentSymbol", params, &result)
402 return result, err
403}
404
405// CodeAction sends a textDocument/codeAction request to the LSP server.
406// A request to provide commands for the given text document and range.
407func (c *Client) CodeAction(ctx context.Context, params protocol.CodeActionParams) ([]protocol.Or_Result_textDocument_codeAction_Item0_Elem, error) {
408 var result []protocol.Or_Result_textDocument_codeAction_Item0_Elem
409 err := c.Call(ctx, "textDocument/codeAction", params, &result)
410 return result, err
411}
412
413// ResolveCodeAction sends a codeAction/resolve request to the LSP server.
414// Request to resolve additional information for a given code action.The request's parameter is of type CodeAction the response is of type CodeAction or a Thenable that resolves to such.
415func (c *Client) ResolveCodeAction(ctx context.Context, params protocol.CodeAction) (protocol.CodeAction, error) {
416 var result protocol.CodeAction
417 err := c.Call(ctx, "codeAction/resolve", params, &result)
418 return result, err
419}
420
421// Symbol sends a workspace/symbol request to the LSP server.
422// A request to list project-wide symbols matching the query string given by the WorkspaceSymbolParams. The response is of type SymbolInformation SymbolInformation[] or a Thenable that resolves to such. Since 3.17.0 - support for WorkspaceSymbol in the returned data. Clients need to advertise support for WorkspaceSymbols via the client capability workspace.symbol.resolveSupport.
423func (c *Client) Symbol(ctx context.Context, params protocol.WorkspaceSymbolParams) (protocol.Or_Result_workspace_symbol, error) {
424 var result protocol.Or_Result_workspace_symbol
425 err := c.Call(ctx, "workspace/symbol", params, &result)
426 return result, err
427}
428
429// ResolveWorkspaceSymbol sends a workspaceSymbol/resolve request to the LSP server.
430// A request to resolve the range inside the workspace symbol's location. Since 3.17.0
431func (c *Client) ResolveWorkspaceSymbol(ctx context.Context, params protocol.WorkspaceSymbol) (protocol.WorkspaceSymbol, error) {
432 var result protocol.WorkspaceSymbol
433 err := c.Call(ctx, "workspaceSymbol/resolve", params, &result)
434 return result, err
435}
436
437// CodeLens sends a textDocument/codeLens request to the LSP server.
438// A request to provide code lens for the given text document.
439func (c *Client) CodeLens(ctx context.Context, params protocol.CodeLensParams) ([]protocol.CodeLens, error) {
440 var result []protocol.CodeLens
441 err := c.Call(ctx, "textDocument/codeLens", params, &result)
442 return result, err
443}
444
445// ResolveCodeLens sends a codeLens/resolve request to the LSP server.
446// A request to resolve a command for a given code lens.
447func (c *Client) ResolveCodeLens(ctx context.Context, params protocol.CodeLens) (protocol.CodeLens, error) {
448 var result protocol.CodeLens
449 err := c.Call(ctx, "codeLens/resolve", params, &result)
450 return result, err
451}
452
453// DocumentLink sends a textDocument/documentLink request to the LSP server.
454// A request to provide document links
455func (c *Client) DocumentLink(ctx context.Context, params protocol.DocumentLinkParams) ([]protocol.DocumentLink, error) {
456 var result []protocol.DocumentLink
457 err := c.Call(ctx, "textDocument/documentLink", params, &result)
458 return result, err
459}
460
461// ResolveDocumentLink sends a documentLink/resolve request to the LSP server.
462// Request to resolve additional information for a given document link. The request's parameter is of type DocumentLink the response is of type DocumentLink or a Thenable that resolves to such.
463func (c *Client) ResolveDocumentLink(ctx context.Context, params protocol.DocumentLink) (protocol.DocumentLink, error) {
464 var result protocol.DocumentLink
465 err := c.Call(ctx, "documentLink/resolve", params, &result)
466 return result, err
467}
468
469// Formatting sends a textDocument/formatting request to the LSP server.
470// A request to format a whole document.
471func (c *Client) Formatting(ctx context.Context, params protocol.DocumentFormattingParams) ([]protocol.TextEdit, error) {
472 var result []protocol.TextEdit
473 err := c.Call(ctx, "textDocument/formatting", params, &result)
474 return result, err
475}
476
477// RangeFormatting sends a textDocument/rangeFormatting request to the LSP server.
478// A request to format a range in a document.
479func (c *Client) RangeFormatting(ctx context.Context, params protocol.DocumentRangeFormattingParams) ([]protocol.TextEdit, error) {
480 var result []protocol.TextEdit
481 err := c.Call(ctx, "textDocument/rangeFormatting", params, &result)
482 return result, err
483}
484
485// RangesFormatting sends a textDocument/rangesFormatting request to the LSP server.
486// A request to format ranges in a document. Since 3.18.0 PROPOSED
487func (c *Client) RangesFormatting(ctx context.Context, params protocol.DocumentRangesFormattingParams) ([]protocol.TextEdit, error) {
488 var result []protocol.TextEdit
489 err := c.Call(ctx, "textDocument/rangesFormatting", params, &result)
490 return result, err
491}
492
493// OnTypeFormatting sends a textDocument/onTypeFormatting request to the LSP server.
494// A request to format a document on type.
495func (c *Client) OnTypeFormatting(ctx context.Context, params protocol.DocumentOnTypeFormattingParams) ([]protocol.TextEdit, error) {
496 var result []protocol.TextEdit
497 err := c.Call(ctx, "textDocument/onTypeFormatting", params, &result)
498 return result, err
499}
500
501// Rename sends a textDocument/rename request to the LSP server.
502// A request to rename a symbol.
503func (c *Client) Rename(ctx context.Context, params protocol.RenameParams) (protocol.WorkspaceEdit, error) {
504 var result protocol.WorkspaceEdit
505 err := c.Call(ctx, "textDocument/rename", params, &result)
506 return result, err
507}
508
509// PrepareRename sends a textDocument/prepareRename request to the LSP server.
510// A request to test and perform the setup necessary for a rename. Since 3.16 - support for default behavior
511func (c *Client) PrepareRename(ctx context.Context, params protocol.PrepareRenameParams) (protocol.PrepareRenameResult, error) {
512 var result protocol.PrepareRenameResult
513 err := c.Call(ctx, "textDocument/prepareRename", params, &result)
514 return result, err
515}
516
517// ExecuteCommand sends a workspace/executeCommand request to the LSP server.
518// A request send from the client to the server to execute a command. The request might return a workspace edit which the client will apply to the workspace.
519func (c *Client) ExecuteCommand(ctx context.Context, params protocol.ExecuteCommandParams) (any, error) {
520 var result any
521 err := c.Call(ctx, "workspace/executeCommand", params, &result)
522 return result, err
523}
524
525// DidChangeWorkspaceFolders sends a workspace/didChangeWorkspaceFolders notification to the LSP server.
526// The workspace/didChangeWorkspaceFolders notification is sent from the client to the server when the workspace folder configuration changes.
527func (c *Client) DidChangeWorkspaceFolders(ctx context.Context, params protocol.DidChangeWorkspaceFoldersParams) error {
528 return c.Notify(ctx, "workspace/didChangeWorkspaceFolders", params)
529}
530
531// WorkDoneProgressCancel sends a window/workDoneProgress/cancel notification to the LSP server.
532// The window/workDoneProgress/cancel notification is sent from the client to the server to cancel a progress initiated on the server side.
533func (c *Client) WorkDoneProgressCancel(ctx context.Context, params protocol.WorkDoneProgressCancelParams) error {
534 return c.Notify(ctx, "window/workDoneProgress/cancel", params)
535}
536
537// DidCreateFiles sends a workspace/didCreateFiles notification to the LSP server.
538// The did create files notification is sent from the client to the server when files were created from within the client. Since 3.16.0
539func (c *Client) DidCreateFiles(ctx context.Context, params protocol.CreateFilesParams) error {
540 return c.Notify(ctx, "workspace/didCreateFiles", params)
541}
542
543// DidRenameFiles sends a workspace/didRenameFiles notification to the LSP server.
544// The did rename files notification is sent from the client to the server when files were renamed from within the client. Since 3.16.0
545func (c *Client) DidRenameFiles(ctx context.Context, params protocol.RenameFilesParams) error {
546 return c.Notify(ctx, "workspace/didRenameFiles", params)
547}
548
549// DidDeleteFiles sends a workspace/didDeleteFiles notification to the LSP server.
550// The will delete files request is sent from the client to the server before files are actually deleted as long as the deletion is triggered from within the client. Since 3.16.0
551func (c *Client) DidDeleteFiles(ctx context.Context, params protocol.DeleteFilesParams) error {
552 return c.Notify(ctx, "workspace/didDeleteFiles", params)
553}
554
555// DidOpenNotebookDocument sends a notebookDocument/didOpen notification to the LSP server.
556// A notification sent when a notebook opens. Since 3.17.0
557func (c *Client) DidOpenNotebookDocument(ctx context.Context, params protocol.DidOpenNotebookDocumentParams) error {
558 return c.Notify(ctx, "notebookDocument/didOpen", params)
559}
560
561// DidChangeNotebookDocument sends a notebookDocument/didChange notification to the LSP server.
562func (c *Client) DidChangeNotebookDocument(ctx context.Context, params protocol.DidChangeNotebookDocumentParams) error {
563 return c.Notify(ctx, "notebookDocument/didChange", params)
564}
565
566// DidSaveNotebookDocument sends a notebookDocument/didSave notification to the LSP server.
567// A notification sent when a notebook document is saved. Since 3.17.0
568func (c *Client) DidSaveNotebookDocument(ctx context.Context, params protocol.DidSaveNotebookDocumentParams) error {
569 return c.Notify(ctx, "notebookDocument/didSave", params)
570}
571
572// DidCloseNotebookDocument sends a notebookDocument/didClose notification to the LSP server.
573// A notification sent when a notebook closes. Since 3.17.0
574func (c *Client) DidCloseNotebookDocument(ctx context.Context, params protocol.DidCloseNotebookDocumentParams) error {
575 return c.Notify(ctx, "notebookDocument/didClose", params)
576}
577
578// Initialized sends a initialized notification to the LSP server.
579// The initialized notification is sent from the client to the server after the client is fully initialized and the server is allowed to send requests from the server to the client.
580func (c *Client) Initialized(ctx context.Context, params protocol.InitializedParams) error {
581 return c.Notify(ctx, "initialized", params)
582}
583
584// Exit sends a exit notification to the LSP server.
585// The exit event is sent from the client to the server to ask the server to exit its process.
586func (c *Client) Exit(ctx context.Context) error {
587 return c.Notify(ctx, "exit", nil)
588}
589
590// DidChangeConfiguration sends a workspace/didChangeConfiguration notification to the LSP server.
591// The configuration change notification is sent from the client to the server when the client's configuration has changed. The notification contains the changed configuration as defined by the language client.
592func (c *Client) DidChangeConfiguration(ctx context.Context, params protocol.DidChangeConfigurationParams) error {
593 return c.Notify(ctx, "workspace/didChangeConfiguration", params)
594}
595
596// DidOpen sends a textDocument/didOpen notification to the LSP server.
597// The document open notification is sent from the client to the server to signal newly opened text documents. The document's truth is now managed by the client and the server must not try to read the document's truth using the document's uri. Open in this sense means it is managed by the client. It doesn't necessarily mean that its content is presented in an editor. An open notification must not be sent more than once without a corresponding close notification send before. This means open and close notification must be balanced and the max open count is one.
598func (c *Client) DidOpen(ctx context.Context, params protocol.DidOpenTextDocumentParams) error {
599 return c.Notify(ctx, "textDocument/didOpen", params)
600}
601
602// DidChange sends a textDocument/didChange notification to the LSP server.
603// The document change notification is sent from the client to the server to signal changes to a text document.
604func (c *Client) DidChange(ctx context.Context, params protocol.DidChangeTextDocumentParams) error {
605 return c.Notify(ctx, "textDocument/didChange", params)
606}
607
608// DidClose sends a textDocument/didClose notification to the LSP server.
609// The document close notification is sent from the client to the server when the document got closed in the client. The document's truth now exists where the document's uri points to (e.g. if the document's uri is a file uri the truth now exists on disk). As with the open notification the close notification is about managing the document's content. Receiving a close notification doesn't mean that the document was open in an editor before. A close notification requires a previous open notification to be sent.
610func (c *Client) DidClose(ctx context.Context, params protocol.DidCloseTextDocumentParams) error {
611 return c.Notify(ctx, "textDocument/didClose", params)
612}
613
614// DidSave sends a textDocument/didSave notification to the LSP server.
615// The document save notification is sent from the client to the server when the document got saved in the client.
616func (c *Client) DidSave(ctx context.Context, params protocol.DidSaveTextDocumentParams) error {
617 return c.Notify(ctx, "textDocument/didSave", params)
618}
619
620// WillSave sends a textDocument/willSave notification to the LSP server.
621// A document will save notification is sent from the client to the server before the document is actually saved.
622func (c *Client) WillSave(ctx context.Context, params protocol.WillSaveTextDocumentParams) error {
623 return c.Notify(ctx, "textDocument/willSave", params)
624}
625
626// DidChangeWatchedFiles sends a workspace/didChangeWatchedFiles notification to the LSP server.
627// The watched files notification is sent from the client to the server when the client detects changes to file watched by the language client.
628func (c *Client) DidChangeWatchedFiles(ctx context.Context, params protocol.DidChangeWatchedFilesParams) error {
629 return c.Notify(ctx, "workspace/didChangeWatchedFiles", params)
630}
631
632// SetTrace sends a $/setTrace notification to the LSP server.
633func (c *Client) SetTrace(ctx context.Context, params protocol.SetTraceParams) error {
634 return c.Notify(ctx, "$/setTrace", params)
635}
636
637// Progress sends a $/progress notification to the LSP server.
638func (c *Client) Progress(ctx context.Context, params protocol.ProgressParams) error {
639 return c.Notify(ctx, "$/progress", params)
640}