methods.go 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. // Generated code. Do not edit
  2. package lsp
  3. import (
  4. "context"
  5. "log/slog"
  6. "time"
  7. "github.com/charmbracelet/crush/internal/config"
  8. "github.com/charmbracelet/crush/internal/lsp/protocol"
  9. )
  10. // Implementation sends a textDocument/implementation request to the LSP server.
  11. // 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.
  12. func (c *Client) Implementation(ctx context.Context, params protocol.ImplementationParams) (protocol.Or_Result_textDocument_implementation, error) {
  13. var result protocol.Or_Result_textDocument_implementation
  14. err := c.Call(ctx, "textDocument/implementation", params, &result)
  15. return result, err
  16. }
  17. // TypeDefinition sends a textDocument/typeDefinition request to the LSP server.
  18. // 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.
  19. func (c *Client) TypeDefinition(ctx context.Context, params protocol.TypeDefinitionParams) (protocol.Or_Result_textDocument_typeDefinition, error) {
  20. var result protocol.Or_Result_textDocument_typeDefinition
  21. err := c.Call(ctx, "textDocument/typeDefinition", params, &result)
  22. return result, err
  23. }
  24. // DocumentColor sends a textDocument/documentColor request to the LSP server.
  25. // 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.
  26. func (c *Client) DocumentColor(ctx context.Context, params protocol.DocumentColorParams) ([]protocol.ColorInformation, error) {
  27. var result []protocol.ColorInformation
  28. err := c.Call(ctx, "textDocument/documentColor", params, &result)
  29. return result, err
  30. }
  31. // ColorPresentation sends a textDocument/colorPresentation request to the LSP server.
  32. // 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.
  33. func (c *Client) ColorPresentation(ctx context.Context, params protocol.ColorPresentationParams) ([]protocol.ColorPresentation, error) {
  34. var result []protocol.ColorPresentation
  35. err := c.Call(ctx, "textDocument/colorPresentation", params, &result)
  36. return result, err
  37. }
  38. // FoldingRange sends a textDocument/foldingRange request to the LSP server.
  39. // 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.
  40. func (c *Client) FoldingRange(ctx context.Context, params protocol.FoldingRangeParams) ([]protocol.FoldingRange, error) {
  41. var result []protocol.FoldingRange
  42. err := c.Call(ctx, "textDocument/foldingRange", params, &result)
  43. return result, err
  44. }
  45. // Declaration sends a textDocument/declaration request to the LSP server.
  46. // 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.
  47. func (c *Client) Declaration(ctx context.Context, params protocol.DeclarationParams) (protocol.Or_Result_textDocument_declaration, error) {
  48. var result protocol.Or_Result_textDocument_declaration
  49. err := c.Call(ctx, "textDocument/declaration", params, &result)
  50. return result, err
  51. }
  52. // SelectionRange sends a textDocument/selectionRange request to the LSP server.
  53. // 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.
  54. func (c *Client) SelectionRange(ctx context.Context, params protocol.SelectionRangeParams) ([]protocol.SelectionRange, error) {
  55. var result []protocol.SelectionRange
  56. err := c.Call(ctx, "textDocument/selectionRange", params, &result)
  57. return result, err
  58. }
  59. // PrepareCallHierarchy sends a textDocument/prepareCallHierarchy request to the LSP server.
  60. // 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
  61. func (c *Client) PrepareCallHierarchy(ctx context.Context, params protocol.CallHierarchyPrepareParams) ([]protocol.CallHierarchyItem, error) {
  62. var result []protocol.CallHierarchyItem
  63. err := c.Call(ctx, "textDocument/prepareCallHierarchy", params, &result)
  64. return result, err
  65. }
  66. // IncomingCalls sends a callHierarchy/incomingCalls request to the LSP server.
  67. // A request to resolve the incoming calls for a given CallHierarchyItem. Since 3.16.0
  68. func (c *Client) IncomingCalls(ctx context.Context, params protocol.CallHierarchyIncomingCallsParams) ([]protocol.CallHierarchyIncomingCall, error) {
  69. var result []protocol.CallHierarchyIncomingCall
  70. err := c.Call(ctx, "callHierarchy/incomingCalls", params, &result)
  71. return result, err
  72. }
  73. // OutgoingCalls sends a callHierarchy/outgoingCalls request to the LSP server.
  74. // A request to resolve the outgoing calls for a given CallHierarchyItem. Since 3.16.0
  75. func (c *Client) OutgoingCalls(ctx context.Context, params protocol.CallHierarchyOutgoingCallsParams) ([]protocol.CallHierarchyOutgoingCall, error) {
  76. var result []protocol.CallHierarchyOutgoingCall
  77. err := c.Call(ctx, "callHierarchy/outgoingCalls", params, &result)
  78. return result, err
  79. }
  80. // SemanticTokensFull sends a textDocument/semanticTokens/full request to the LSP server.
  81. // Since 3.16.0
  82. func (c *Client) SemanticTokensFull(ctx context.Context, params protocol.SemanticTokensParams) (protocol.SemanticTokens, error) {
  83. var result protocol.SemanticTokens
  84. err := c.Call(ctx, "textDocument/semanticTokens/full", params, &result)
  85. return result, err
  86. }
  87. // SemanticTokensFullDelta sends a textDocument/semanticTokens/full/delta request to the LSP server.
  88. // Since 3.16.0
  89. func (c *Client) SemanticTokensFullDelta(ctx context.Context, params protocol.SemanticTokensDeltaParams) (protocol.Or_Result_textDocument_semanticTokens_full_delta, error) {
  90. var result protocol.Or_Result_textDocument_semanticTokens_full_delta
  91. err := c.Call(ctx, "textDocument/semanticTokens/full/delta", params, &result)
  92. return result, err
  93. }
  94. // SemanticTokensRange sends a textDocument/semanticTokens/range request to the LSP server.
  95. // Since 3.16.0
  96. func (c *Client) SemanticTokensRange(ctx context.Context, params protocol.SemanticTokensRangeParams) (protocol.SemanticTokens, error) {
  97. var result protocol.SemanticTokens
  98. err := c.Call(ctx, "textDocument/semanticTokens/range", params, &result)
  99. return result, err
  100. }
  101. // LinkedEditingRange sends a textDocument/linkedEditingRange request to the LSP server.
  102. // A request to provide ranges that can be edited together. Since 3.16.0
  103. func (c *Client) LinkedEditingRange(ctx context.Context, params protocol.LinkedEditingRangeParams) (protocol.LinkedEditingRanges, error) {
  104. var result protocol.LinkedEditingRanges
  105. err := c.Call(ctx, "textDocument/linkedEditingRange", params, &result)
  106. return result, err
  107. }
  108. // WillCreateFiles sends a workspace/willCreateFiles request to the LSP server.
  109. // 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
  110. func (c *Client) WillCreateFiles(ctx context.Context, params protocol.CreateFilesParams) (protocol.WorkspaceEdit, error) {
  111. var result protocol.WorkspaceEdit
  112. err := c.Call(ctx, "workspace/willCreateFiles", params, &result)
  113. return result, err
  114. }
  115. // WillRenameFiles sends a workspace/willRenameFiles request to the LSP server.
  116. // 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
  117. func (c *Client) WillRenameFiles(ctx context.Context, params protocol.RenameFilesParams) (protocol.WorkspaceEdit, error) {
  118. var result protocol.WorkspaceEdit
  119. err := c.Call(ctx, "workspace/willRenameFiles", params, &result)
  120. return result, err
  121. }
  122. // WillDeleteFiles sends a workspace/willDeleteFiles request to the LSP server.
  123. // 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
  124. func (c *Client) WillDeleteFiles(ctx context.Context, params protocol.DeleteFilesParams) (protocol.WorkspaceEdit, error) {
  125. var result protocol.WorkspaceEdit
  126. err := c.Call(ctx, "workspace/willDeleteFiles", params, &result)
  127. return result, err
  128. }
  129. // Moniker sends a textDocument/moniker request to the LSP server.
  130. // 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.
  131. func (c *Client) Moniker(ctx context.Context, params protocol.MonikerParams) ([]protocol.Moniker, error) {
  132. var result []protocol.Moniker
  133. err := c.Call(ctx, "textDocument/moniker", params, &result)
  134. return result, err
  135. }
  136. // PrepareTypeHierarchy sends a textDocument/prepareTypeHierarchy request to the LSP server.
  137. // 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
  138. func (c *Client) PrepareTypeHierarchy(ctx context.Context, params protocol.TypeHierarchyPrepareParams) ([]protocol.TypeHierarchyItem, error) {
  139. var result []protocol.TypeHierarchyItem
  140. err := c.Call(ctx, "textDocument/prepareTypeHierarchy", params, &result)
  141. return result, err
  142. }
  143. // Supertypes sends a typeHierarchy/supertypes request to the LSP server.
  144. // A request to resolve the supertypes for a given TypeHierarchyItem. Since 3.17.0
  145. func (c *Client) Supertypes(ctx context.Context, params protocol.TypeHierarchySupertypesParams) ([]protocol.TypeHierarchyItem, error) {
  146. var result []protocol.TypeHierarchyItem
  147. err := c.Call(ctx, "typeHierarchy/supertypes", params, &result)
  148. return result, err
  149. }
  150. // Subtypes sends a typeHierarchy/subtypes request to the LSP server.
  151. // A request to resolve the subtypes for a given TypeHierarchyItem. Since 3.17.0
  152. func (c *Client) Subtypes(ctx context.Context, params protocol.TypeHierarchySubtypesParams) ([]protocol.TypeHierarchyItem, error) {
  153. var result []protocol.TypeHierarchyItem
  154. err := c.Call(ctx, "typeHierarchy/subtypes", params, &result)
  155. return result, err
  156. }
  157. // InlineValue sends a textDocument/inlineValue request to the LSP server.
  158. // 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
  159. func (c *Client) InlineValue(ctx context.Context, params protocol.InlineValueParams) ([]protocol.InlineValue, error) {
  160. var result []protocol.InlineValue
  161. err := c.Call(ctx, "textDocument/inlineValue", params, &result)
  162. return result, err
  163. }
  164. // InlayHint sends a textDocument/inlayHint request to the LSP server.
  165. // 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
  166. func (c *Client) InlayHint(ctx context.Context, params protocol.InlayHintParams) ([]protocol.InlayHint, error) {
  167. var result []protocol.InlayHint
  168. err := c.Call(ctx, "textDocument/inlayHint", params, &result)
  169. return result, err
  170. }
  171. // Resolve sends a inlayHint/resolve request to the LSP server.
  172. // 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
  173. func (c *Client) Resolve(ctx context.Context, params protocol.InlayHint) (protocol.InlayHint, error) {
  174. var result protocol.InlayHint
  175. err := c.Call(ctx, "inlayHint/resolve", params, &result)
  176. return result, err
  177. }
  178. // Diagnostic sends a textDocument/diagnostic request to the LSP server.
  179. // The document diagnostic request definition. Since 3.17.0
  180. func (c *Client) Diagnostic(ctx context.Context, params protocol.DocumentDiagnosticParams) (protocol.DocumentDiagnosticReport, error) {
  181. var result protocol.DocumentDiagnosticReport
  182. err := c.Call(ctx, "textDocument/diagnostic", params, &result)
  183. return result, err
  184. }
  185. // DiagnosticWorkspace sends a workspace/diagnostic request to the LSP server.
  186. // The workspace diagnostic request definition. Since 3.17.0
  187. func (c *Client) DiagnosticWorkspace(ctx context.Context, params protocol.WorkspaceDiagnosticParams) (protocol.WorkspaceDiagnosticReport, error) {
  188. var result protocol.WorkspaceDiagnosticReport
  189. err := c.Call(ctx, "workspace/diagnostic", params, &result)
  190. return result, err
  191. }
  192. // InlineCompletion sends a textDocument/inlineCompletion request to the LSP server.
  193. // 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
  194. func (c *Client) InlineCompletion(ctx context.Context, params protocol.InlineCompletionParams) (protocol.Or_Result_textDocument_inlineCompletion, error) {
  195. var result protocol.Or_Result_textDocument_inlineCompletion
  196. err := c.Call(ctx, "textDocument/inlineCompletion", params, &result)
  197. return result, err
  198. }
  199. // TextDocumentContent sends a workspace/textDocumentContent request to the LSP server.
  200. // 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
  201. func (c *Client) TextDocumentContent(ctx context.Context, params protocol.TextDocumentContentParams) (string, error) {
  202. var result string
  203. err := c.Call(ctx, "workspace/textDocumentContent", params, &result)
  204. return result, err
  205. }
  206. // Initialize sends a initialize request to the LSP server.
  207. // 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.
  208. func (c *Client) Initialize(ctx context.Context, params protocol.ParamInitialize) (protocol.InitializeResult, error) {
  209. var result protocol.InitializeResult
  210. err := c.Call(ctx, "initialize", params, &result)
  211. return result, err
  212. }
  213. // Shutdown sends a shutdown request to the LSP server and cleans up resources.
  214. // 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.
  215. func (c *Client) Shutdown(ctx context.Context) error {
  216. var shutdownErr error
  217. c.shutdownOnce.Do(func() {
  218. cfg := config.Get()
  219. // Step 1: Send shutdown request (expects a response)
  220. if cfg.Options.DebugLSP {
  221. slog.Debug("Sending LSP shutdown request", "name", c.name)
  222. }
  223. shutdownCtx, cancel := context.WithTimeout(ctx, 2*time.Second)
  224. defer cancel()
  225. if err := c.Call(shutdownCtx, "shutdown", nil, nil); err != nil {
  226. // Log but don't fail - server might already be shutting down
  227. slog.Warn("LSP shutdown request failed", "name", c.name, "error", err)
  228. shutdownErr = err
  229. }
  230. // Step 2: Send exit notification (no response expected)
  231. if cfg.Options.DebugLSP {
  232. slog.Debug("Sending LSP exit notification", "name", c.name)
  233. }
  234. if err := c.Notify(ctx, "exit", nil); err != nil {
  235. slog.Warn("LSP exit notification failed", "name", c.name, "error", err)
  236. }
  237. // Step 3: Signal our goroutines to stop
  238. close(c.shutdownChan)
  239. // Step 4: Clean up resources
  240. c.cleanupResources()
  241. // Step 5: Wait for goroutines with timeout
  242. done := make(chan struct{})
  243. go func() {
  244. <-c.stderrDone
  245. <-c.messageHandlerDone
  246. close(done)
  247. }()
  248. select {
  249. case <-done:
  250. if cfg.Options.DebugLSP {
  251. slog.Debug("LSP goroutines stopped cleanly", "name", c.name)
  252. }
  253. case <-time.After(2 * time.Second):
  254. slog.Warn("Timeout waiting for LSP goroutines", "name", c.name)
  255. }
  256. })
  257. return shutdownErr
  258. }
  259. // cleanupResources closes all handlers and cleans up internal state
  260. func (c *Client) cleanupResources() {
  261. // Close all pending request handlers
  262. c.handlersMu.Lock()
  263. for id, ch := range c.handlers {
  264. close(ch)
  265. delete(c.handlers, id)
  266. }
  267. c.handlersMu.Unlock()
  268. // Clear pending requests tracking
  269. c.pendingRequestsMu.Lock()
  270. for id := range c.pendingRequests {
  271. delete(c.pendingRequests, id)
  272. }
  273. c.pendingRequestsMu.Unlock()
  274. // Clear open files
  275. c.openFilesMu.Lock()
  276. for uri := range c.openFiles {
  277. delete(c.openFiles, uri)
  278. }
  279. c.openFilesMu.Unlock()
  280. // Clear diagnostics
  281. c.diagnosticsMu.Lock()
  282. for uri := range c.diagnostics {
  283. delete(c.diagnostics, uri)
  284. }
  285. c.diagnosticsMu.Unlock()
  286. }
  287. // WillSaveWaitUntil sends a textDocument/willSaveWaitUntil request to the LSP server.
  288. // 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.
  289. func (c *Client) WillSaveWaitUntil(ctx context.Context, params protocol.WillSaveTextDocumentParams) ([]protocol.TextEdit, error) {
  290. var result []protocol.TextEdit
  291. err := c.Call(ctx, "textDocument/willSaveWaitUntil", params, &result)
  292. return result, err
  293. }
  294. // Completion sends a textDocument/completion request to the LSP server.
  295. // 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.
  296. func (c *Client) Completion(ctx context.Context, params protocol.CompletionParams) (protocol.Or_Result_textDocument_completion, error) {
  297. var result protocol.Or_Result_textDocument_completion
  298. err := c.Call(ctx, "textDocument/completion", params, &result)
  299. return result, err
  300. }
  301. // ResolveCompletionItem sends a completionItem/resolve request to the LSP server.
  302. // 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.
  303. func (c *Client) ResolveCompletionItem(ctx context.Context, params protocol.CompletionItem) (protocol.CompletionItem, error) {
  304. var result protocol.CompletionItem
  305. err := c.Call(ctx, "completionItem/resolve", params, &result)
  306. return result, err
  307. }
  308. // Hover sends a textDocument/hover request to the LSP server.
  309. // 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.
  310. func (c *Client) Hover(ctx context.Context, params protocol.HoverParams) (protocol.Hover, error) {
  311. var result protocol.Hover
  312. err := c.Call(ctx, "textDocument/hover", params, &result)
  313. return result, err
  314. }
  315. // SignatureHelp sends a textDocument/signatureHelp request to the LSP server.
  316. func (c *Client) SignatureHelp(ctx context.Context, params protocol.SignatureHelpParams) (protocol.SignatureHelp, error) {
  317. var result protocol.SignatureHelp
  318. err := c.Call(ctx, "textDocument/signatureHelp", params, &result)
  319. return result, err
  320. }
  321. // Definition sends a textDocument/definition request to the LSP server.
  322. // 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.
  323. func (c *Client) Definition(ctx context.Context, params protocol.DefinitionParams) (protocol.Or_Result_textDocument_definition, error) {
  324. var result protocol.Or_Result_textDocument_definition
  325. err := c.Call(ctx, "textDocument/definition", params, &result)
  326. return result, err
  327. }
  328. // References sends a textDocument/references request to the LSP server.
  329. // 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.
  330. func (c *Client) References(ctx context.Context, params protocol.ReferenceParams) ([]protocol.Location, error) {
  331. var result []protocol.Location
  332. err := c.Call(ctx, "textDocument/references", params, &result)
  333. return result, err
  334. }
  335. // DocumentHighlight sends a textDocument/documentHighlight request to the LSP server.
  336. // 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.
  337. func (c *Client) DocumentHighlight(ctx context.Context, params protocol.DocumentHighlightParams) ([]protocol.DocumentHighlight, error) {
  338. var result []protocol.DocumentHighlight
  339. err := c.Call(ctx, "textDocument/documentHighlight", params, &result)
  340. return result, err
  341. }
  342. // DocumentSymbol sends a textDocument/documentSymbol request to the LSP server.
  343. // 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.
  344. func (c *Client) DocumentSymbol(ctx context.Context, params protocol.DocumentSymbolParams) (protocol.Or_Result_textDocument_documentSymbol, error) {
  345. var result protocol.Or_Result_textDocument_documentSymbol
  346. err := c.Call(ctx, "textDocument/documentSymbol", params, &result)
  347. return result, err
  348. }
  349. // CodeAction sends a textDocument/codeAction request to the LSP server.
  350. // A request to provide commands for the given text document and range.
  351. func (c *Client) CodeAction(ctx context.Context, params protocol.CodeActionParams) ([]protocol.Or_Result_textDocument_codeAction_Item0_Elem, error) {
  352. var result []protocol.Or_Result_textDocument_codeAction_Item0_Elem
  353. err := c.Call(ctx, "textDocument/codeAction", params, &result)
  354. return result, err
  355. }
  356. // ResolveCodeAction sends a codeAction/resolve request to the LSP server.
  357. // 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.
  358. func (c *Client) ResolveCodeAction(ctx context.Context, params protocol.CodeAction) (protocol.CodeAction, error) {
  359. var result protocol.CodeAction
  360. err := c.Call(ctx, "codeAction/resolve", params, &result)
  361. return result, err
  362. }
  363. // Symbol sends a workspace/symbol request to the LSP server.
  364. // 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.
  365. func (c *Client) Symbol(ctx context.Context, params protocol.WorkspaceSymbolParams) (protocol.Or_Result_workspace_symbol, error) {
  366. var result protocol.Or_Result_workspace_symbol
  367. err := c.Call(ctx, "workspace/symbol", params, &result)
  368. return result, err
  369. }
  370. // ResolveWorkspaceSymbol sends a workspaceSymbol/resolve request to the LSP server.
  371. // A request to resolve the range inside the workspace symbol's location. Since 3.17.0
  372. func (c *Client) ResolveWorkspaceSymbol(ctx context.Context, params protocol.WorkspaceSymbol) (protocol.WorkspaceSymbol, error) {
  373. var result protocol.WorkspaceSymbol
  374. err := c.Call(ctx, "workspaceSymbol/resolve", params, &result)
  375. return result, err
  376. }
  377. // CodeLens sends a textDocument/codeLens request to the LSP server.
  378. // A request to provide code lens for the given text document.
  379. func (c *Client) CodeLens(ctx context.Context, params protocol.CodeLensParams) ([]protocol.CodeLens, error) {
  380. var result []protocol.CodeLens
  381. err := c.Call(ctx, "textDocument/codeLens", params, &result)
  382. return result, err
  383. }
  384. // ResolveCodeLens sends a codeLens/resolve request to the LSP server.
  385. // A request to resolve a command for a given code lens.
  386. func (c *Client) ResolveCodeLens(ctx context.Context, params protocol.CodeLens) (protocol.CodeLens, error) {
  387. var result protocol.CodeLens
  388. err := c.Call(ctx, "codeLens/resolve", params, &result)
  389. return result, err
  390. }
  391. // DocumentLink sends a textDocument/documentLink request to the LSP server.
  392. // A request to provide document links
  393. func (c *Client) DocumentLink(ctx context.Context, params protocol.DocumentLinkParams) ([]protocol.DocumentLink, error) {
  394. var result []protocol.DocumentLink
  395. err := c.Call(ctx, "textDocument/documentLink", params, &result)
  396. return result, err
  397. }
  398. // ResolveDocumentLink sends a documentLink/resolve request to the LSP server.
  399. // 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.
  400. func (c *Client) ResolveDocumentLink(ctx context.Context, params protocol.DocumentLink) (protocol.DocumentLink, error) {
  401. var result protocol.DocumentLink
  402. err := c.Call(ctx, "documentLink/resolve", params, &result)
  403. return result, err
  404. }
  405. // Formatting sends a textDocument/formatting request to the LSP server.
  406. // A request to format a whole document.
  407. func (c *Client) Formatting(ctx context.Context, params protocol.DocumentFormattingParams) ([]protocol.TextEdit, error) {
  408. var result []protocol.TextEdit
  409. err := c.Call(ctx, "textDocument/formatting", params, &result)
  410. return result, err
  411. }
  412. // RangeFormatting sends a textDocument/rangeFormatting request to the LSP server.
  413. // A request to format a range in a document.
  414. func (c *Client) RangeFormatting(ctx context.Context, params protocol.DocumentRangeFormattingParams) ([]protocol.TextEdit, error) {
  415. var result []protocol.TextEdit
  416. err := c.Call(ctx, "textDocument/rangeFormatting", params, &result)
  417. return result, err
  418. }
  419. // RangesFormatting sends a textDocument/rangesFormatting request to the LSP server.
  420. // A request to format ranges in a document. Since 3.18.0 PROPOSED
  421. func (c *Client) RangesFormatting(ctx context.Context, params protocol.DocumentRangesFormattingParams) ([]protocol.TextEdit, error) {
  422. var result []protocol.TextEdit
  423. err := c.Call(ctx, "textDocument/rangesFormatting", params, &result)
  424. return result, err
  425. }
  426. // OnTypeFormatting sends a textDocument/onTypeFormatting request to the LSP server.
  427. // A request to format a document on type.
  428. func (c *Client) OnTypeFormatting(ctx context.Context, params protocol.DocumentOnTypeFormattingParams) ([]protocol.TextEdit, error) {
  429. var result []protocol.TextEdit
  430. err := c.Call(ctx, "textDocument/onTypeFormatting", params, &result)
  431. return result, err
  432. }
  433. // Rename sends a textDocument/rename request to the LSP server.
  434. // A request to rename a symbol.
  435. func (c *Client) Rename(ctx context.Context, params protocol.RenameParams) (protocol.WorkspaceEdit, error) {
  436. var result protocol.WorkspaceEdit
  437. err := c.Call(ctx, "textDocument/rename", params, &result)
  438. return result, err
  439. }
  440. // PrepareRename sends a textDocument/prepareRename request to the LSP server.
  441. // A request to test and perform the setup necessary for a rename. Since 3.16 - support for default behavior
  442. func (c *Client) PrepareRename(ctx context.Context, params protocol.PrepareRenameParams) (protocol.PrepareRenameResult, error) {
  443. var result protocol.PrepareRenameResult
  444. err := c.Call(ctx, "textDocument/prepareRename", params, &result)
  445. return result, err
  446. }
  447. // ExecuteCommand sends a workspace/executeCommand request to the LSP server.
  448. // 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.
  449. func (c *Client) ExecuteCommand(ctx context.Context, params protocol.ExecuteCommandParams) (any, error) {
  450. var result any
  451. err := c.Call(ctx, "workspace/executeCommand", params, &result)
  452. return result, err
  453. }
  454. // DidChangeWorkspaceFolders sends a workspace/didChangeWorkspaceFolders notification to the LSP server.
  455. // The workspace/didChangeWorkspaceFolders notification is sent from the client to the server when the workspace folder configuration changes.
  456. func (c *Client) DidChangeWorkspaceFolders(ctx context.Context, params protocol.DidChangeWorkspaceFoldersParams) error {
  457. return c.Notify(ctx, "workspace/didChangeWorkspaceFolders", params)
  458. }
  459. // WorkDoneProgressCancel sends a window/workDoneProgress/cancel notification to the LSP server.
  460. // The window/workDoneProgress/cancel notification is sent from the client to the server to cancel a progress initiated on the server side.
  461. func (c *Client) WorkDoneProgressCancel(ctx context.Context, params protocol.WorkDoneProgressCancelParams) error {
  462. return c.Notify(ctx, "window/workDoneProgress/cancel", params)
  463. }
  464. // DidCreateFiles sends a workspace/didCreateFiles notification to the LSP server.
  465. // 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
  466. func (c *Client) DidCreateFiles(ctx context.Context, params protocol.CreateFilesParams) error {
  467. return c.Notify(ctx, "workspace/didCreateFiles", params)
  468. }
  469. // DidRenameFiles sends a workspace/didRenameFiles notification to the LSP server.
  470. // 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
  471. func (c *Client) DidRenameFiles(ctx context.Context, params protocol.RenameFilesParams) error {
  472. return c.Notify(ctx, "workspace/didRenameFiles", params)
  473. }
  474. // DidDeleteFiles sends a workspace/didDeleteFiles notification to the LSP server.
  475. // 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
  476. func (c *Client) DidDeleteFiles(ctx context.Context, params protocol.DeleteFilesParams) error {
  477. return c.Notify(ctx, "workspace/didDeleteFiles", params)
  478. }
  479. // DidOpenNotebookDocument sends a notebookDocument/didOpen notification to the LSP server.
  480. // A notification sent when a notebook opens. Since 3.17.0
  481. func (c *Client) DidOpenNotebookDocument(ctx context.Context, params protocol.DidOpenNotebookDocumentParams) error {
  482. return c.Notify(ctx, "notebookDocument/didOpen", params)
  483. }
  484. // DidChangeNotebookDocument sends a notebookDocument/didChange notification to the LSP server.
  485. func (c *Client) DidChangeNotebookDocument(ctx context.Context, params protocol.DidChangeNotebookDocumentParams) error {
  486. return c.Notify(ctx, "notebookDocument/didChange", params)
  487. }
  488. // DidSaveNotebookDocument sends a notebookDocument/didSave notification to the LSP server.
  489. // A notification sent when a notebook document is saved. Since 3.17.0
  490. func (c *Client) DidSaveNotebookDocument(ctx context.Context, params protocol.DidSaveNotebookDocumentParams) error {
  491. return c.Notify(ctx, "notebookDocument/didSave", params)
  492. }
  493. // DidCloseNotebookDocument sends a notebookDocument/didClose notification to the LSP server.
  494. // A notification sent when a notebook closes. Since 3.17.0
  495. func (c *Client) DidCloseNotebookDocument(ctx context.Context, params protocol.DidCloseNotebookDocumentParams) error {
  496. return c.Notify(ctx, "notebookDocument/didClose", params)
  497. }
  498. // Initialized sends a initialized notification to the LSP server.
  499. // 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.
  500. func (c *Client) Initialized(ctx context.Context, params protocol.InitializedParams) error {
  501. return c.Notify(ctx, "initialized", params)
  502. }
  503. // Exit sends a exit notification to the LSP server.
  504. // The exit event is sent from the client to the server to ask the server to exit its process.
  505. func (c *Client) Exit(ctx context.Context) error {
  506. return c.Notify(ctx, "exit", nil)
  507. }
  508. // DidChangeConfiguration sends a workspace/didChangeConfiguration notification to the LSP server.
  509. // 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.
  510. func (c *Client) DidChangeConfiguration(ctx context.Context, params protocol.DidChangeConfigurationParams) error {
  511. return c.Notify(ctx, "workspace/didChangeConfiguration", params)
  512. }
  513. // DidOpen sends a textDocument/didOpen notification to the LSP server.
  514. // 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.
  515. func (c *Client) DidOpen(ctx context.Context, params protocol.DidOpenTextDocumentParams) error {
  516. return c.Notify(ctx, "textDocument/didOpen", params)
  517. }
  518. // DidChange sends a textDocument/didChange notification to the LSP server.
  519. // The document change notification is sent from the client to the server to signal changes to a text document.
  520. func (c *Client) DidChange(ctx context.Context, params protocol.DidChangeTextDocumentParams) error {
  521. return c.Notify(ctx, "textDocument/didChange", params)
  522. }
  523. // DidClose sends a textDocument/didClose notification to the LSP server.
  524. // 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.
  525. func (c *Client) DidClose(ctx context.Context, params protocol.DidCloseTextDocumentParams) error {
  526. return c.Notify(ctx, "textDocument/didClose", params)
  527. }
  528. // DidSave sends a textDocument/didSave notification to the LSP server.
  529. // The document save notification is sent from the client to the server when the document got saved in the client.
  530. func (c *Client) DidSave(ctx context.Context, params protocol.DidSaveTextDocumentParams) error {
  531. return c.Notify(ctx, "textDocument/didSave", params)
  532. }
  533. // WillSave sends a textDocument/willSave notification to the LSP server.
  534. // A document will save notification is sent from the client to the server before the document is actually saved.
  535. func (c *Client) WillSave(ctx context.Context, params protocol.WillSaveTextDocumentParams) error {
  536. return c.Notify(ctx, "textDocument/willSave", params)
  537. }
  538. // DidChangeWatchedFiles sends a workspace/didChangeWatchedFiles notification to the LSP server.
  539. // The watched files notification is sent from the client to the server when the client detects changes to file watched by the language client.
  540. func (c *Client) DidChangeWatchedFiles(ctx context.Context, params protocol.DidChangeWatchedFilesParams) error {
  541. return c.Notify(ctx, "workspace/didChangeWatchedFiles", params)
  542. }
  543. // SetTrace sends a $/setTrace notification to the LSP server.
  544. func (c *Client) SetTrace(ctx context.Context, params protocol.SetTraceParams) error {
  545. return c.Notify(ctx, "$/setTrace", params)
  546. }
  547. // Progress sends a $/progress notification to the LSP server.
  548. func (c *Client) Progress(ctx context.Context, params protocol.ProgressParams) error {
  549. return c.Notify(ctx, "$/progress", params)
  550. }