tower_lsp_server/server.rs
1use ls_types::{
2 request::{
3 GotoDeclarationParams, GotoDeclarationResponse, GotoImplementationParams,
4 GotoImplementationResponse, GotoTypeDefinitionParams, GotoTypeDefinitionResponse,
5 },
6 *,
7};
8use tracing::{error, warn};
9
10use crate::jsonrpc::{Error, Result};
11
12macro_rules! rpc {
13 // Entrypoint
14 (
15
16 $(#[doc = $trait_docs:literal])*
17 pub trait $name:ident: ($($bounds:tt)+) {
18 $(
19 $(#[doc = $method_docs:literal])*
20 #[rpc(name = $rpc_name:literal)]
21 async fn $rpc_method:ident(&self$(, $rpc_params_ident:ident: $rpc_params:ty)? $(,)?) $(-> $rpc_result:ty)? $($body:block)? $(;)?
22 )+
23 }
24 ) => {
25 $(#[doc = $trait_docs])*
26 pub trait $name: $($bounds)+ {
27 $(
28 rpc!(@method
29 $(#[doc = $method_docs])*,
30 $rpc_method,
31 $($rpc_params_ident: $rpc_params)?,
32 $($rpc_result)?,
33 $($body)?
34 );
35 )+
36 }
37
38 pub mod generated {
39 use crate::jsonrpc::Router;
40 use crate::service::{layers, Client, Pending, ServerState, ExitedError};
41 use ls_types::*;
42 use std::sync::Arc;
43 use super::LanguageServer;
44
45 pub fn register_lsp_methods<S>(
46 mut router: Router<S, ExitedError>,
47 state: Arc<ServerState>,
48 pending: Arc<Pending>,
49 client: Client,
50 ) -> Router<S, ExitedError>
51 where
52 S: LanguageServer,
53 {
54 $(
55 rpc!(@register
56 $rpc_name,
57 $rpc_method,
58 router,
59 state,
60 pending
61 );
62 )+
63
64 router.method(
65 "exit",
66 // this closure is never called
67 |_: &S| std::future::ready(()),
68 layers::Exit::new(state.clone(), pending.clone(), client.clone()),
69 );
70
71 router.method(
72 "$/cancelRequest",
73 move |_: &S, params: CancelParams| {
74 pending.cancel(¶ms.id.into());
75 std::future::ready(())
76 },
77 tower::layer::util::Identity::new(),
78 );
79
80 router
81 }
82 }
83 };
84
85 // `method` fragment: transform methods signatures to add `Send` bound
86 (@method $(#[doc = $method_docs:literal])*, $rpc_method:ident, /* empty params */, $rpc_result:ty, /* empty body */) => {
87 $(#[doc = $method_docs])*
88 fn $rpc_method(&self) -> impl ::std::future::Future<Output = $rpc_result> + Send;
89 };
90 (@method $(#[doc = $method_docs:literal])*, $rpc_method:ident, $rpc_params_ident:ident: $rpc_params:ty, $rpc_result:ty, /* empty body */) => {
91 $(#[doc = $method_docs])*
92 fn $rpc_method(&self, $rpc_params_ident: $rpc_params) -> impl ::std::future::Future<Output = $rpc_result> + Send;
93 };
94 (@method $(#[doc = $method_docs:literal])*, $rpc_method:ident, $rpc_params_ident:ident: $rpc_params:ty, $rpc_result:ty, $body:block) => {
95 $(#[doc = $method_docs])*
96 fn $rpc_method(&self, $rpc_params_ident: $rpc_params) -> impl ::std::future::Future<Output = $rpc_result> + Send { async $body }
97 };
98 (@method $(#[doc = $method_docs:literal])*, $rpc_method:ident, $rpc_params_ident:ident: $rpc_params:ty, /* empty result */, /* empty body */) => {
99 $(#[doc = $method_docs])*
100 fn $rpc_method(&self, $rpc_params_ident: $rpc_params) -> impl ::std::future::Future<Output = ()> + Send;
101 };
102 (@method $(#[doc = $method_docs:literal])*, $rpc_method:ident, $rpc_params_ident:ident: $rpc_params:ty, /* empty result */, $body:block) => {
103 $(#[doc = $method_docs])*
104 fn $rpc_method(&self, $rpc_params_ident: $rpc_params) -> impl ::std::future::Future<Output = ()> + Send { async $body }
105 };
106
107 // `register` fragment: add the method to the tower router
108 (@register $rpc_name:literal, initialize, $router:ident, $state:ident, $pending:ident) => {
109 $router.method(
110 "initialize",
111 S::initialize,
112 layers::Initialize::new($state.clone(), $pending.clone()),
113 )
114 };
115 (@register $rpc_name:literal, shutdown, $router:ident, $state:ident, $pending:ident) => {
116 $router.method(
117 "shutdown",
118 S::shutdown,
119 layers::Shutdown::new($state.clone(), $pending.clone()),
120 )
121 };
122 (@register $rpc_name:literal, $rpc_method:ident, $router:ident, $state:ident, $pending:ident) => {
123 $router.method(
124 $rpc_name,
125 S::$rpc_method,
126 layers::Normal::new($state.clone(), $pending.clone()),
127 )
128 };
129}
130
131rpc! {
132 /// Trait implemented by language server backends.
133 ///
134 /// This interface allows servers adhering to the [Language Server Protocol] to be implemented in a
135 /// safe and easily testable way without exposing the low-level implementation details.
136 ///
137 /// [Language Server Protocol]: https://microsoft.github.io/language-server-protocol/
138 pub trait LanguageServer: (Send + Sync + 'static) {
139 /// The [`initialize`] request is the first request sent from the client to the server.
140 ///
141 /// [`initialize`]: https://microsoft.github.io/language-server-protocol/specification#initialize
142 ///
143 /// This method is guaranteed to only execute once. If the client sends this request to the
144 /// server again, the server will respond with JSON-RPC error code `-32600` (invalid request).
145 #[rpc(name = "initialize")]
146 async fn initialize(&self, params: InitializeParams) -> Result<InitializeResult>;
147
148 /// The [`initialized`] notification is sent from the client to the server after the client
149 /// received the result of the initialize request but before the client sends anything else.
150 ///
151 /// [`initialized`]: https://microsoft.github.io/language-server-protocol/specification#initialized
152 ///
153 /// The server can use the `initialized` notification, for example, to dynamically register
154 /// capabilities with the client.
155 #[rpc(name = "initialized")]
156 async fn initialized(&self, params: InitializedParams) {
157 let _ = params;
158 }
159
160 /// The [`shutdown`] request asks the server to gracefully shut down, but to not exit.
161 ///
162 /// [`shutdown`]: https://microsoft.github.io/language-server-protocol/specification#shutdown
163 ///
164 /// This request is often later followed by an [`exit`] notification, which will cause the
165 /// server to exit immediately.
166 ///
167 /// [`exit`]: https://microsoft.github.io/language-server-protocol/specification#exit
168 ///
169 /// This method is guaranteed to only execute once. If the client sends this request to the
170 /// server again, the server will respond with JSON-RPC error code `-32600` (invalid request).
171 #[rpc(name = "shutdown")]
172 async fn shutdown(&self) -> Result<()>;
173
174 // Document Synchronization
175
176 /// The [`textDocument/didOpen`] notification is sent from the client to the server to signal
177 /// that a new text document has been opened by the client.
178 ///
179 /// [`textDocument/didOpen`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_didOpen
180 ///
181 /// The document's truth is now managed by the client and the server must not try to read the
182 /// document’s truth using the document's URI. "Open" in this sense means it is managed by the
183 /// client. It doesn't necessarily mean that its content is presented in an editor.
184 #[rpc(name = "textDocument/didOpen")]
185 async fn did_open(&self, params: DidOpenTextDocumentParams) {
186 let _ = params;
187 warn!("got a `textDocument/didOpen` notification, but it is not implemented");
188 }
189
190 /// The [`textDocument/didChange`] notification is sent from the client to the server to signal
191 /// changes to a text document.
192 ///
193 /// [`textDocument/didChange`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_didChange
194 ///
195 /// This notification will contain a distinct version tag and a list of edits made to the
196 /// document for the server to interpret.
197 #[rpc(name = "textDocument/didChange")]
198 async fn did_change(&self, params: DidChangeTextDocumentParams) {
199 let _ = params;
200 warn!("got a `textDocument/didChange` notification, but it is not implemented");
201 }
202
203 /// The [`textDocument/willSave`] notification is sent from the client to the server before the
204 /// document is actually saved.
205 ///
206 /// [`textDocument/willSave`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_willSave
207 #[rpc(name = "textDocument/willSave")]
208 async fn will_save(&self, params: WillSaveTextDocumentParams) {
209 let _ = params;
210 warn!("got a `textDocument/willSave` notification, but it is not implemented");
211 }
212
213 /// The [`textDocument/willSaveWaitUntil`] request is sent from the client to the server before
214 /// the document is actually saved.
215 ///
216 /// [`textDocument/willSaveWaitUntil`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_willSaveWaitUntil
217 ///
218 /// The request can return an array of `TextEdit`s which will be applied to the text document
219 /// before it is saved.
220 ///
221 /// Please note that clients might drop results if computing the text edits took too long or if
222 /// a server constantly fails on this request. This is done to keep the save fast and reliable.
223 #[rpc(name = "textDocument/willSaveWaitUntil")]
224 async fn will_save_wait_until(
225 &self,
226 params: WillSaveTextDocumentParams,
227 ) -> Result<Option<Vec<TextEdit>>> {
228 let _ = params;
229 error!("got a `textDocument/willSaveWaitUntil` request, but it is not implemented");
230 Err(Error::method_not_found())
231 }
232
233 /// The [`textDocument/didSave`] notification is sent from the client to the server when the
234 /// document was saved in the client.
235 ///
236 /// [`textDocument/didSave`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_didSave
237 #[rpc(name = "textDocument/didSave")]
238 async fn did_save(&self, params: DidSaveTextDocumentParams) {
239 let _ = params;
240 warn!("got a `textDocument/didSave` notification, but it is not implemented");
241 }
242
243 /// The [`textDocument/didClose`] notification is sent from the client to the server when the
244 /// document got closed in the client.
245 ///
246 /// [`textDocument/didClose`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_didClose
247 ///
248 /// The document's truth now exists where the document's URI points to (e.g. if the document's
249 /// URI is a file URI, the truth now exists on disk).
250 #[rpc(name = "textDocument/didClose")]
251 async fn did_close(&self, params: DidCloseTextDocumentParams) {
252 let _ = params;
253 warn!("got a `textDocument/didClose` notification, but it is not implemented");
254 }
255
256 // Notebook Document Synchronization
257
258 /// The [`notebookDocument/didOpen`] notification is sent from the client to the server when a new notebook document is opened.
259 /// It is only sent for notebooks selected by the `notebookDocumentSync` server capability.
260 ///
261 /// [`notebookDocument/didOpen`]: https://microsoft.github.io/language-server-protocol/specification/#notebookDocument_didChange
262 #[rpc(name = "notebookDocument/didOpen")]
263 async fn notebook_did_open(&self, params: DidOpenNotebookDocumentParams) {
264 let _ = params;
265 warn!("got a `notebookDocument/didOpen` notification, but it is not implemented");
266 }
267
268 /// The [`notebookDocument/didChange`] notification is sent from the client to the server when a notebook document changes.
269 /// It is only sent for notebooks selected by the `notebookDocumentSync` server capability.
270 ///
271 /// [`notebookDocument/didChange`]: https://microsoft.github.io/language-server-protocol/specification#notebookDocument_didChange
272 #[rpc(name = "notebookDocument/didChange")]
273 async fn notebook_did_change(&self, params: DidChangeNotebookDocumentParams) {
274 let _ = params;
275 warn!("got a `notebookDocument/didChange` notification, but it is not implemented");
276 }
277
278 /// The [`notebookDocument/didSave`] notification is sent from the client to the server when a notebook document is saved.
279 /// It is only sent for notebooks selected by the `notebookDocumentSync` server capability.
280 ///
281 /// [`notebookDocument/didSave`]: https://microsoft.github.io/language-server-protocol/specification#notebookDocument_didSave
282 #[rpc(name = "notebookDocument/didSave")]
283 async fn notebook_did_save(&self, params: DidSaveNotebookDocumentParams) {
284 let _ = params;
285 warn!("got a `notebookDocument/didSave` notification, but it is not implemented");
286 }
287
288 /// The [`notebookDocument/didClose`] notification is sent from the client to the server when a notebook document is closed.
289 /// It is only sent for notebooks selected by the `notebookDocumentSync` server capability.
290 ///
291 /// [`notebookDocument/didClose`]: https://microsoft.github.io/language-server-protocol/specification#notebookDocument_didClose
292 #[rpc(name = "notebookDocument/didClose")]
293 async fn notebook_did_close(&self, params: DidCloseNotebookDocumentParams) {
294 let _ = params;
295 warn!("got a `notebookDocument/didClose` notification, but it is not implemented");
296 }
297
298 // Language Features
299
300 /// The [`textDocument/declaration`] request asks the server for the declaration location of a
301 /// symbol at a given text document position.
302 ///
303 /// [`textDocument/declaration`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_declaration
304 ///
305 /// # Compatibility
306 ///
307 /// This request was introduced in specification version 3.14.0.
308 ///
309 /// The [`GotoDeclarationResponse::Link`](ls_types::lsp::GotoDefinitionResponse::Link) return value
310 /// was introduced in specification version 3.14.0 and requires client-side support in order to
311 /// be used. It can be returned if the client set the following field to `true` in the
312 /// [`initialize`](Self::initialize) method:
313 ///
314 /// ```text
315 /// InitializeParams::capabilities::text_document::declaration::link_support
316 /// ```
317 #[rpc(name = "textDocument/declaration")]
318 async fn goto_declaration(
319 &self,
320 params: GotoDeclarationParams,
321 ) -> Result<Option<GotoDeclarationResponse>> {
322 let _ = params;
323 error!("got a `textDocument/declaration` request, but it is not implemented");
324 Err(Error::method_not_found())
325 }
326
327 /// The [`textDocument/definition`] request asks the server for the definition location of a
328 /// symbol at a given text document position.
329 ///
330 /// [`textDocument/definition`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_definition
331 ///
332 /// # Compatibility
333 ///
334 /// The [`GotoDefinitionResponse::Link`](ls_types::lsp::GotoDefinitionResponse::Link) return value
335 /// was introduced in specification version 3.14.0 and requires client-side support in order to
336 /// be used. It can be returned if the client set the following field to `true` in the
337 /// [`initialize`](Self::initialize) method:
338 ///
339 /// ```text
340 /// InitializeParams::capabilities::text_document::definition::link_support
341 /// ```
342 #[rpc(name = "textDocument/definition")]
343 async fn goto_definition(
344 &self,
345 params: GotoDefinitionParams,
346 ) -> Result<Option<GotoDefinitionResponse>> {
347 let _ = params;
348 error!("got a `textDocument/definition` request, but it is not implemented");
349 Err(Error::method_not_found())
350 }
351
352 /// The [`textDocument/typeDefinition`] request asks the server for the type definition location of
353 /// a symbol at a given text document position.
354 ///
355 /// [`textDocument/typeDefinition`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_typeDefinition
356 ///
357 /// # Compatibility
358 ///
359 /// This request was introduced in specification version 3.6.0.
360 ///
361 /// The [`GotoTypeDefinitionResponse::Link`](ls_types::lsp::GotoDefinitionResponse::Link) return
362 /// value was introduced in specification version 3.14.0 and requires client-side support in
363 /// order to be used. It can be returned if the client set the following field to `true` in the
364 /// [`initialize`](Self::initialize) method:
365 ///
366 /// ```text
367 /// InitializeParams::capabilities::text_document::type_definition::link_support
368 /// ```
369 #[rpc(name = "textDocument/typeDefinition")]
370 async fn goto_type_definition(
371 &self,
372 params: GotoTypeDefinitionParams,
373 ) -> Result<Option<GotoTypeDefinitionResponse>> {
374 let _ = params;
375 error!("got a `textDocument/typeDefinition` request, but it is not implemented");
376 Err(Error::method_not_found())
377 }
378
379 /// The [`textDocument/implementation`] request is sent from the client to the server to resolve
380 /// the implementation location of a symbol at a given text document position.
381 ///
382 /// [`textDocument/implementation`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_implementation
383 ///
384 /// # Compatibility
385 ///
386 /// This request was introduced in specification version 3.6.0.
387 ///
388 /// The [`GotoImplementationResponse::Link`](ls_types::lsp::GotoDefinitionResponse::Link)
389 /// return value was introduced in specification version 3.14.0 and requires client-side
390 /// support in order to be used. It can be returned if the client set the following field to
391 /// `true` in the [`initialize`](Self::initialize) method:
392 ///
393 /// ```text
394 /// InitializeParams::capabilities::text_document::implementation::link_support
395 /// ```
396 #[rpc(name = "textDocument/implementation")]
397 async fn goto_implementation(
398 &self,
399 params: GotoImplementationParams,
400 ) -> Result<Option<GotoImplementationResponse>> {
401 let _ = params;
402 error!("got a `textDocument/implementation` request, but it is not implemented");
403 Err(Error::method_not_found())
404 }
405
406 /// The [`textDocument/references`] request is sent from the client to the server to resolve
407 /// project-wide references for the symbol denoted by the given text document position.
408 ///
409 /// [`textDocument/references`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_references
410 #[rpc(name = "textDocument/references")]
411 async fn references(&self, params: ReferenceParams) -> Result<Option<Vec<Location>>> {
412 let _ = params;
413 error!("got a `textDocument/references` request, but it is not implemented");
414 Err(Error::method_not_found())
415 }
416
417 /// The [`textDocument/prepareCallHierarchy`] request is sent from the client to the server to
418 /// return a call hierarchy for the language element of given text document positions.
419 ///
420 /// [`textDocument/prepareCallHierarchy`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_prepareCallHierarchy
421 ///
422 /// The call hierarchy requests are executed in two steps:
423 ///
424 /// 1. First, a call hierarchy item is resolved for the given text document position (this
425 /// method).
426 /// 2. For a call hierarchy item, the incoming or outgoing call hierarchy items are resolved
427 /// inside [`incoming_calls`] and [`outgoing_calls`], respectively.
428 ///
429 /// [`incoming_calls`]: Self::incoming_calls
430 /// [`outgoing_calls`]: Self::outgoing_calls
431 ///
432 /// # Compatibility
433 ///
434 /// This request was introduced in specification version 3.16.0.
435 #[rpc(name = "textDocument/prepareCallHierarchy")]
436 async fn prepare_call_hierarchy(
437 &self,
438 params: CallHierarchyPrepareParams,
439 ) -> Result<Option<Vec<CallHierarchyItem>>> {
440 let _ = params;
441 error!("got a `textDocument/prepareCallHierarchy` request, but it is not implemented");
442 Err(Error::method_not_found())
443 }
444
445 /// The [`callHierarchy/incomingCalls`] request is sent from the client to the server to
446 /// resolve **incoming** calls for a given call hierarchy item.
447 ///
448 /// The request doesn't define its own client and server capabilities. It is only issued if a
449 /// server registers for the [`textDocument/prepareCallHierarchy`] request.
450 ///
451 /// [`callHierarchy/incomingCalls`]: https://microsoft.github.io/language-server-protocol/specification#callHierarchy_incomingCalls
452 /// [`textDocument/prepareCallHierarchy`]: Self::prepare_call_hierarchy
453 ///
454 /// # Compatibility
455 ///
456 /// This request was introduced in specification version 3.16.0.
457 #[rpc(name = "callHierarchy/incomingCalls")]
458 async fn incoming_calls(
459 &self,
460 params: CallHierarchyIncomingCallsParams,
461 ) -> Result<Option<Vec<CallHierarchyIncomingCall>>> {
462 let _ = params;
463 error!("got a `callHierarchy/incomingCalls` request, but it is not implemented");
464 Err(Error::method_not_found())
465 }
466
467 /// The [`callHierarchy/outgoingCalls`] request is sent from the client to the server to
468 /// resolve **outgoing** calls for a given call hierarchy item.
469 ///
470 /// The request doesn't define its own client and server capabilities. It is only issued if a
471 /// server registers for the [`textDocument/prepareCallHierarchy`] request.
472 ///
473 /// [`callHierarchy/outgoingCalls`]: https://microsoft.github.io/language-server-protocol/specification#callHierarchy_outgoingCalls
474 /// [`textDocument/prepareCallHierarchy`]: Self::prepare_call_hierarchy
475 ///
476 /// # Compatibility
477 ///
478 /// This request was introduced in specification version 3.16.0.
479 #[rpc(name = "callHierarchy/outgoingCalls")]
480 async fn outgoing_calls(
481 &self,
482 params: CallHierarchyOutgoingCallsParams,
483 ) -> Result<Option<Vec<CallHierarchyOutgoingCall>>> {
484 let _ = params;
485 error!("got a `callHierarchy/outgoingCalls` request, but it is not implemented");
486 Err(Error::method_not_found())
487 }
488
489 /// The [`textDocument/prepareTypeHierarchy`] request is sent from the client to the server to
490 /// return a type hierarchy for the language element of given text document positions.
491 ///
492 /// [`textDocument/prepareTypeHierarchy`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_prepareTypeHierarchy
493 ///
494 /// Returns `Ok(None)` if the server couldn’t infer a valid type from the position.
495 ///
496 /// The type hierarchy requests are executed in two steps:
497 ///
498 /// 1. First, a type hierarchy item is prepared for the given text document position.
499 /// 2. For a type hierarchy item, the supertype or subtype type hierarchy items are resolved in
500 /// [`supertypes`](Self::supertypes) and [`subtypes`](Self::subtypes), respectively.
501 ///
502 /// # Compatibility
503 ///
504 /// This request was introduced in specification version 3.17.0.
505 #[rpc(name = "textDocument/prepareTypeHierarchy")]
506 async fn prepare_type_hierarchy(
507 &self,
508 params: TypeHierarchyPrepareParams,
509 ) -> Result<Option<Vec<TypeHierarchyItem>>> {
510 let _ = params;
511 error!("got a `textDocument/prepareTypeHierarchy` request, but it is not implemented");
512 Err(Error::method_not_found())
513 }
514
515 /// The [`typeHierarchy/supertypes`] request is sent from the client to the server to resolve
516 /// the **supertypes** for a given type hierarchy item.
517 ///
518 /// Returns `Ok(None)` if the server couldn’t infer a valid type from item in `params`.
519 ///
520 /// The request doesn’t define its own client and server capabilities. It is only issued if a
521 /// server registers for the `textDocument/prepareTypeHierarchy` request.
522 ///
523 /// # Compatibility
524 ///
525 /// This request was introduced in specification version 3.17.0.
526 #[rpc(name = "typeHierarchy/supertypes")]
527 async fn supertypes(
528 &self,
529 params: TypeHierarchySupertypesParams,
530 ) -> Result<Option<Vec<TypeHierarchyItem>>> {
531 let _ = params;
532 error!("got a `typeHierarchy/supertypes` request, but it is not implemented");
533 Err(Error::method_not_found())
534 }
535
536 /// The [`typeHierarchy/subtypes`] request is sent from the client to the server to resolve
537 /// the **subtypes** for a given type hierarchy item.
538 ///
539 /// Returns `Ok(None)` if the server couldn’t infer a valid type from item in `params`.
540 ///
541 /// The request doesn’t define its own client and server capabilities. It is only issued if a
542 /// server registers for the `textDocument/prepareTypeHierarchy` request.
543 ///
544 /// # Compatibility
545 ///
546 /// This request was introduced in specification version 3.17.0.
547 #[rpc(name = "typeHierarchy/subtypes")]
548 async fn subtypes(
549 &self,
550 params: TypeHierarchySubtypesParams,
551 ) -> Result<Option<Vec<TypeHierarchyItem>>> {
552 let _ = params;
553 error!("got a `typeHierarchy/subtypes` request, but it is not implemented");
554 Err(Error::method_not_found())
555 }
556
557 /// The [`textDocument/documentHighlight`] request is sent from the client to the server to
558 /// resolve appropriate highlights for a given text document position.
559 ///
560 /// [`textDocument/documentHighlight`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_documentHighlight
561 ///
562 /// For programming languages, this usually highlights all textual references to the symbol
563 /// scoped to this file.
564 ///
565 /// This request differs slightly from `textDocument/references` in that this one is allowed to
566 /// be more fuzzy.
567 #[rpc(name = "textDocument/documentHighlight")]
568 async fn document_highlight(
569 &self,
570 params: DocumentHighlightParams,
571 ) -> Result<Option<Vec<DocumentHighlight>>> {
572 let _ = params;
573 error!("got a `textDocument/documentHighlight` request, but it is not implemented");
574 Err(Error::method_not_found())
575 }
576
577 /// The [`textDocument/documentLink`] request is sent from the client to the server to request
578 /// the location of links in a document.
579 ///
580 /// A document link is a range in a text document that links to an internal or external
581 /// resource, like another text document or a web site.
582 ///
583 /// [`textDocument/documentLink`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_documentLink
584 ///
585 /// # Compatibility
586 ///
587 /// The [`DocumentLink::tooltip`] field was introduced in specification version 3.15.0 and
588 /// requires client-side support in order to be used. It can be returned if the client set the
589 /// following field to `true` in the [`initialize`](Self::initialize) method:
590 ///
591 /// ```text
592 /// InitializeParams::capabilities::text_document::document_link::tooltip_support
593 /// ```
594 #[rpc(name = "textDocument/documentLink")]
595 async fn document_link(&self, params: DocumentLinkParams) -> Result<Option<Vec<DocumentLink>>> {
596 let _ = params;
597 error!("got a `textDocument/documentLink` request, but it is not implemented");
598 Err(Error::method_not_found())
599 }
600
601 /// The [`documentLink/resolve`] request is sent from the client to the server to resolve the
602 /// target of a given document link.
603 ///
604 /// [`documentLink/resolve`]: https://microsoft.github.io/language-server-protocol/specification#documentLink_resolve
605 ///
606 /// A document link is a range in a text document that links to an internal or external
607 /// resource, like another text document or a web site.
608 #[rpc(name = "documentLink/resolve")]
609 async fn document_link_resolve(&self, params: DocumentLink) -> Result<DocumentLink> {
610 let _ = params;
611 error!("got a `documentLink/resolve` request, but it is not implemented");
612 Err(Error::method_not_found())
613 }
614
615 /// The [`textDocument/hover`] request asks the server for hover information at a given text
616 /// document position.
617 ///
618 /// [`textDocument/hover`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_hover
619 ///
620 /// Such hover information typically includes type signature information and inline
621 /// documentation for the symbol at the given text document position.
622 #[rpc(name = "textDocument/hover")]
623 async fn hover(&self, params: HoverParams) -> Result<Option<Hover>> {
624 let _ = params;
625 error!("got a `textDocument/hover` request, but it is not implemented");
626 Err(Error::method_not_found())
627 }
628
629 /// The [`textDocument/codeLens`] request is sent from the client to the server to compute code
630 /// lenses for a given text document.
631 ///
632 /// [`textDocument/codeLens`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_codeLens
633 #[rpc(name = "textDocument/codeLens")]
634 async fn code_lens(&self, params: CodeLensParams) -> Result<Option<Vec<CodeLens>>> {
635 let _ = params;
636 error!("got a `textDocument/codeLens` request, but it is not implemented");
637 Err(Error::method_not_found())
638 }
639
640 /// The [`codeLens/resolve`] request is sent from the client to the server to resolve the
641 /// command for a given code lens item.
642 ///
643 /// [`codeLens/resolve`]: https://microsoft.github.io/language-server-protocol/specification#codeLens_resolve
644 #[rpc(name = "codeLens/resolve")]
645 async fn code_lens_resolve(&self, params: CodeLens) -> Result<CodeLens> {
646 let _ = params;
647 error!("got a `codeLens/resolve` request, but it is not implemented");
648 Err(Error::method_not_found())
649 }
650
651 /// The [`textDocument/foldingRange`] request is sent from the client to the server to return
652 /// all folding ranges found in a given text document.
653 ///
654 /// [`textDocument/foldingRange`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_foldingRange
655 ///
656 /// # Compatibility
657 ///
658 /// This request was introduced in specification version 3.10.0.
659 #[rpc(name = "textDocument/foldingRange")]
660 async fn folding_range(&self, params: FoldingRangeParams) -> Result<Option<Vec<FoldingRange>>> {
661 let _ = params;
662 error!("got a `textDocument/foldingRange` request, but it is not implemented");
663 Err(Error::method_not_found())
664 }
665
666 /// The [`textDocument/selectionRange`] request is sent from the client to the server to return
667 /// suggested selection ranges at an array of given positions. A selection range is a range
668 /// around the cursor position which the user might be interested in selecting.
669 ///
670 /// [`textDocument/selectionRange`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_selectionRange
671 ///
672 /// A selection range in the return array is for the position in the provided parameters at the
673 /// same index. Therefore `params.positions[i]` must be contained in `result[i].range`.
674 ///
675 /// # Compatibility
676 ///
677 /// This request was introduced in specification version 3.15.0.
678 #[rpc(name = "textDocument/selectionRange")]
679 async fn selection_range(
680 &self,
681 params: SelectionRangeParams,
682 ) -> Result<Option<Vec<SelectionRange>>> {
683 let _ = params;
684 error!("got a `textDocument/selectionRange` request, but it is not implemented");
685 Err(Error::method_not_found())
686 }
687
688 /// The [`textDocument/documentSymbol`] request is sent from the client to the server to
689 /// retrieve all symbols found in a given text document.
690 ///
691 /// [`textDocument/documentSymbol`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_documentSymbol
692 ///
693 /// The returned result is either:
694 ///
695 /// * [`DocumentSymbolResponse::Flat`] which is a flat list of all symbols found in a given
696 /// text document. Then neither the symbol’s location range nor the symbol’s container name
697 /// should be used to infer a hierarchy.
698 /// * [`DocumentSymbolResponse::Nested`] which is a hierarchy of symbols found in a given text
699 /// document.
700 #[rpc(name = "textDocument/documentSymbol")]
701 async fn document_symbol(
702 &self,
703 params: DocumentSymbolParams,
704 ) -> Result<Option<DocumentSymbolResponse>> {
705 let _ = params;
706 error!("got a `textDocument/documentSymbol` request, but it is not implemented");
707 Err(Error::method_not_found())
708 }
709
710 /// The [`textDocument/semanticTokens/full`] request is sent from the client to the server to
711 /// resolve the semantic tokens of a given file.
712 ///
713 /// [`textDocument/semanticTokens/full`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_semanticTokens
714 ///
715 /// Semantic tokens are used to add additional color information to a file that depends on
716 /// language specific symbol information. A semantic token request usually produces a large
717 /// result. The protocol therefore supports encoding tokens with numbers. In addition, optional
718 /// support for deltas is available, i.e. [`semantic_tokens_full_delta`].
719 ///
720 /// [`semantic_tokens_full_delta`]: Self::semantic_tokens_full_delta
721 ///
722 /// # Compatibility
723 ///
724 /// This request was introduced in specification version 3.16.0.
725 #[rpc(name = "textDocument/semanticTokens/full")]
726 async fn semantic_tokens_full(
727 &self,
728 params: SemanticTokensParams,
729 ) -> Result<Option<SemanticTokensResult>> {
730 let _ = params;
731 error!("got a `textDocument/semanticTokens/full` request, but it is not implemented");
732 Err(Error::method_not_found())
733 }
734
735 /// The [`textDocument/semanticTokens/full/delta`] request is sent from the client to the server to
736 /// resolve the semantic tokens of a given file, **returning only the delta**.
737 ///
738 /// [`textDocument/semanticTokens/full/delta`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_semanticTokens
739 ///
740 /// Similar to [`semantic_tokens_full`](Self::semantic_tokens_full), except it returns a
741 /// sequence of [`SemanticTokensEdit`] to transform a previous result into a new result.
742 ///
743 /// # Compatibility
744 ///
745 /// This request was introduced in specification version 3.16.0.
746 #[rpc(name = "textDocument/semanticTokens/full/delta")]
747 async fn semantic_tokens_full_delta(
748 &self,
749 params: SemanticTokensDeltaParams,
750 ) -> Result<Option<SemanticTokensFullDeltaResult>> {
751 let _ = params;
752 error!("got a `textDocument/semanticTokens/full/delta` request, but it is not implemented");
753 Err(Error::method_not_found())
754 }
755
756 /// The [`textDocument/semanticTokens/range`] request is sent from the client to the server to
757 /// resolve the semantic tokens **for the visible range** of a given file.
758 ///
759 /// [`textDocument/semanticTokens/range`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_semanticTokens
760 ///
761 /// When a user opens a file, it can be beneficial to only compute the semantic tokens for the
762 /// visible range (faster rendering of the tokens in the user interface). If a server can
763 /// compute these tokens faster than for the whole file, it can implement this method to handle
764 /// this special case.
765 ///
766 /// See the [`semantic_tokens_full`](Self::semantic_tokens_full) documentation for more
767 /// details.
768 ///
769 /// # Compatibility
770 ///
771 /// This request was introduced in specification version 3.16.0.
772 #[rpc(name = "textDocument/semanticTokens/range")]
773 async fn semantic_tokens_range(
774 &self,
775 params: SemanticTokensRangeParams,
776 ) -> Result<Option<SemanticTokensRangeResult>> {
777 let _ = params;
778 error!("got a `textDocument/semanticTokens/range` request, but it is not implemented");
779 Err(Error::method_not_found())
780 }
781
782 /// The [`textDocument/inlineValue`] request is sent from the client to the server to compute
783 /// inline values for a given text document that may be rendered in the editor at the end of
784 /// lines.
785 ///
786 /// [`textDocument/inlineValue`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_inlineValue
787 ///
788 /// # Compatibility
789 ///
790 /// This request was introduced in specification version 3.17.0.
791 #[rpc(name = "textDocument/inlineValue")]
792 async fn inline_value(&self, params: InlineValueParams) -> Result<Option<Vec<InlineValue>>> {
793 let _ = params;
794 error!("got a `textDocument/inlineValue` request, but it is not implemented");
795 Err(Error::method_not_found())
796 }
797
798 /// The [`textDocument/inlayHint`] request is sent from the client to the server to compute
799 /// inlay hints for a given `(text document, range)` tuple that may be rendered in the editor
800 /// in place with other text.
801 ///
802 /// [`textDocument/inlayHint`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_inlayHint
803 ///
804 /// # Compatibility
805 ///
806 /// This request was introduced in specification version 3.17.0
807 #[rpc(name = "textDocument/inlayHint")]
808 async fn inlay_hint(&self, params: InlayHintParams) -> Result<Option<Vec<InlayHint>>> {
809 let _ = params;
810 error!("got a `textDocument/inlayHint` request, but it is not implemented");
811 Err(Error::method_not_found())
812 }
813
814 /// The [`inlayHint/resolve`] request is sent from the client to the server to resolve
815 /// additional information for a given inlay hint.
816 ///
817 /// [`inlayHint/resolve`]: https://microsoft.github.io/language-server-protocol/specification#inlayHint_resolve
818 ///
819 /// This is usually used to compute the tooltip, location or command properties of an inlay
820 /// hint’s label part to avoid its unnecessary computation during the `textDocument/inlayHint`
821 /// request.
822 ///
823 /// Consider a client announces the `label.location` property as a property that can be
824 /// resolved lazily using the client capability:
825 ///
826 /// ```js
827 /// textDocument.inlayHint.resolveSupport = { properties: ['label.location'] };
828 /// ```
829 ///
830 /// then an inlay hint with a label part, but without a location, must be resolved using the
831 /// `inlayHint/resolve` request before it can be used.
832 ///
833 /// # Compatibility
834 ///
835 /// This request was introduced in specification version 3.17.0
836 #[rpc(name = "inlayHint/resolve")]
837 async fn inlay_hint_resolve(&self, params: InlayHint) -> Result<InlayHint> {
838 let _ = params;
839 error!("got a `inlayHint/resolve` request, but it is not implemented");
840 Err(Error::method_not_found())
841 }
842
843 /// The [`textDocument/moniker`] request is sent from the client to the server to get the
844 /// symbol monikers for a given text document position.
845 ///
846 /// [`textDocument/moniker`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_moniker
847 ///
848 /// An array of `Moniker` types is returned as response to indicate possible monikers at the
849 /// given location. If no monikers can be calculated, `Some(vec![])` or `None` should be
850 /// returned.
851 ///
852 /// # Concept
853 ///
854 /// The Language Server Index Format (LSIF) introduced the concept of _symbol monikers_ to help
855 /// associate symbols across different indexes. This request adds capability for LSP server
856 /// implementations to provide the same symbol moniker information given a text document
857 /// position.
858 ///
859 /// Clients can utilize this method to get the moniker at the current location in a file the
860 /// user is editing and do further code navigation queries in other services that rely on LSIF
861 /// indexes and link symbols together.
862 ///
863 /// # Compatibility
864 ///
865 /// This request was introduced in specification version 3.16.0.
866 #[rpc(name = "textDocument/moniker")]
867 async fn moniker(&self, params: MonikerParams) -> Result<Option<Vec<Moniker>>> {
868 let _ = params;
869 error!("got a `textDocument/moniker` request, but it is not implemented");
870 Err(Error::method_not_found())
871 }
872
873 /// The [`textDocument/completion`] request is sent from the client to the server to compute
874 /// completion items at a given cursor position.
875 ///
876 /// If computing full completion items is expensive, servers can additionally provide a handler
877 /// for the completion item resolve request (`completionItem/resolve`). This request is sent
878 /// when a completion item is selected in the user interface.
879 ///
880 /// [`textDocument/completion`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_completion
881 ///
882 /// # Compatibility
883 ///
884 /// Since 3.16.0, the client can signal that it can resolve more properties lazily. This is
885 /// done using the `completion_item.resolve_support` client capability which lists all
886 /// properties that can be filled in during a `completionItem/resolve` request.
887 ///
888 /// All other properties (usually `sort_text`, `filter_text`, `insert_text`, and `text_edit`)
889 /// must be provided in the `textDocument/completion` response and must not be changed during
890 /// resolve.
891 #[rpc(name = "textDocument/completion")]
892 async fn completion(&self, params: CompletionParams) -> Result<Option<CompletionResponse>> {
893 let _ = params;
894 error!("got a `textDocument/completion` request, but it is not implemented");
895 Err(Error::method_not_found())
896 }
897
898 /// The [`completionItem/resolve`] request is sent from the client to the server to resolve
899 /// additional information for a given completion item.
900 ///
901 /// [`completionItem/resolve`]: https://microsoft.github.io/language-server-protocol/specification#completionItem_resolve
902 #[rpc(name = "completionItem/resolve")]
903 async fn completion_resolve(&self, params: CompletionItem) -> Result<CompletionItem> {
904 let _ = params;
905 error!("got a `completionItem/resolve` request, but it is not implemented");
906 Err(Error::method_not_found())
907 }
908
909 /// The [`textDocument/diagnostic`] request is sent from the client to the server to ask the
910 /// server to compute the diagnostics for a given document.
911 ///
912 /// As with other pull requests, the server is asked to compute the diagnostics for the
913 /// currently synced version of the document.
914 ///
915 /// The request doesn't define its own client and server capabilities. It is only issued if a
916 /// server registers for the [`textDocument/diagnostic`] request.
917 ///
918 /// [`textDocument/diagnostic`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_diagnostic
919 ///
920 /// # Compatibility
921 ///
922 /// This request was introduced in specification version 3.17.0.
923 #[rpc(name = "textDocument/diagnostic")]
924 async fn diagnostic(
925 &self,
926 params: DocumentDiagnosticParams,
927 ) -> Result<DocumentDiagnosticReportResult> {
928 let _ = params;
929 error!("got a `textDocument/diagnostic` request, but it is not implemented");
930 Err(Error::method_not_found())
931 }
932
933 /// The [`workspace/diagnostic`] request is sent from the client to the server to ask the
934 /// server to compute workspace wide diagnostics which previously where pushed from the server
935 /// to the client.
936 ///
937 /// In contrast to the [`textDocument/diagnostic`] request, the workspace request can be
938 /// long-running and is not bound to a specific workspace or document state. If the client
939 /// supports streaming for the workspace diagnostic pull, it is legal to provide a
940 /// `textDocument/diagnostic` report multiple times for the same document URI. The last one
941 /// reported will win over previous reports.
942 ///
943 /// [`textDocument/diagnostic`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_diagnostic
944 ///
945 /// If a client receives a diagnostic report for a document in a workspace diagnostic request
946 /// for which the client also issues individual document diagnostic pull requests, the client
947 /// needs to decide which diagnostics win and should be presented. In general:
948 ///
949 /// * Diagnostics for a higher document version should win over those from a lower document
950 /// version (e.g. note that document versions are steadily increasing).
951 /// * Diagnostics from a document pull should win over diagnostics from a workspace pull.
952 ///
953 /// The request doesn't define its own client and server capabilities. It is only issued if a
954 /// server registers for the [`workspace/diagnostic`] request.
955 ///
956 /// [`workspace/diagnostic`]: https://microsoft.github.io/language-server-protocol/specification#workspace_diagnostic
957 ///
958 /// # Compatibility
959 ///
960 /// This request was introduced in specification version 3.17.0.
961 #[rpc(name = "workspace/diagnostic")]
962 async fn workspace_diagnostic(
963 &self,
964 params: WorkspaceDiagnosticParams,
965 ) -> Result<WorkspaceDiagnosticReportResult> {
966 let _ = params;
967 error!("got a `workspace/diagnostic` request, but it is not implemented");
968 Err(Error::method_not_found())
969 }
970
971 /// The [`textDocument/signatureHelp`] request is sent from the client to the server to request
972 /// signature information at a given cursor position.
973 ///
974 /// [`textDocument/signatureHelp`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_signatureHelp
975 #[rpc(name = "textDocument/signatureHelp")]
976 async fn signature_help(&self, params: SignatureHelpParams) -> Result<Option<SignatureHelp>> {
977 let _ = params;
978 error!("got a `textDocument/signatureHelp` request, but it is not implemented");
979 Err(Error::method_not_found())
980 }
981
982 /// The [`textDocument/codeAction`] request is sent from the client to the server to compute
983 /// commands for a given text document and range. These commands are typically code fixes to
984 /// either fix problems or to beautify/refactor code.
985 ///
986 /// The result of a [`textDocument/codeAction`] request is an array of `Command` literals which
987 /// are typically presented in the user interface.
988 ///
989 /// [`textDocument/codeAction`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_codeAction
990 ///
991 /// To ensure that a server is useful in many clients, the commands specified in a code actions
992 /// should be handled by the server and not by the client (see [`workspace/executeCommand`] and
993 /// `ServerCapabilities::execute_command_provider`). If the client supports providing edits
994 /// with a code action, then the mode should be used.
995 ///
996 /// When the command is selected the server should be contacted again (via the
997 /// [`workspace/executeCommand`] request) to execute the command.
998 ///
999 /// [`workspace/executeCommand`]: https://microsoft.github.io/language-server-protocol/specification#workspace_executeCommand
1000 ///
1001 /// # Compatibility
1002 ///
1003 /// ## Since version 3.16.0
1004 ///
1005 /// A client can offer a server to delay the computation of code action properties during a
1006 /// `textDocument/codeAction` request. This is useful for cases where it is expensive to
1007 /// compute the value of a property (for example, the `edit` property).
1008 ///
1009 /// Clients signal this through the `code_action.resolve_support` client capability which lists
1010 /// all properties a client can resolve lazily. The server capability
1011 /// `code_action_provider.resolve_provider` signals that a server will offer a
1012 /// `codeAction/resolve` route.
1013 ///
1014 /// To help servers uniquely identify a code action in the resolve request, a code action
1015 /// literal may optionally carry a `data` property. This is also guarded by an additional
1016 /// client capability `code_action.data_support`. In general, a client should offer data
1017 /// support if it offers resolve support.
1018 ///
1019 /// It should also be noted that servers shouldn’t alter existing attributes of a code action
1020 /// in a `codeAction/resolve` request.
1021 ///
1022 /// ## Since version 3.8.0
1023 ///
1024 /// Support for [`CodeAction`] literals to enable the following scenarios:
1025 ///
1026 /// * The ability to directly return a workspace edit from the code action request.
1027 /// This avoids having another server roundtrip to execute an actual code action.
1028 /// However server providers should be aware that if the code action is expensive to compute
1029 /// or the edits are huge it might still be beneficial if the result is simply a command and
1030 /// the actual edit is only computed when needed.
1031 ///
1032 /// * The ability to group code actions using a kind. Clients are allowed to ignore that
1033 /// information. However it allows them to better group code action, for example, into
1034 /// corresponding menus (e.g. all refactor code actions into a refactor menu).
1035 #[rpc(name = "textDocument/codeAction")]
1036 async fn code_action(&self, params: CodeActionParams) -> Result<Option<CodeActionResponse>> {
1037 let _ = params;
1038 error!("got a `textDocument/codeAction` request, but it is not implemented");
1039 Err(Error::method_not_found())
1040 }
1041
1042 /// The [`codeAction/resolve`] request is sent from the client to the server to resolve
1043 /// additional information for a given code action.
1044 ///
1045 /// [`codeAction/resolve`]: https://microsoft.github.io/language-server-protocol/specification#codeAction_resolve
1046 ///
1047 /// This is usually used to compute the edit property of a [`CodeAction`] to avoid its
1048 /// unnecessary computation during the [`textDocument/codeAction`](Self::code_action) request.
1049 ///
1050 /// # Compatibility
1051 ///
1052 /// This request was introduced in specification version 3.16.0.
1053 #[rpc(name = "codeAction/resolve")]
1054 async fn code_action_resolve(&self, params: CodeAction) -> Result<CodeAction> {
1055 let _ = params;
1056 error!("got a `codeAction/resolve` request, but it is not implemented");
1057 Err(Error::method_not_found())
1058 }
1059
1060 /// The [`textDocument/documentColor`] request is sent from the client to the server to list
1061 /// all color references found in a given text document. Along with the range, a color value in
1062 /// RGB is returned.
1063 ///
1064 /// [`textDocument/documentColor`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_documentColor
1065 ///
1066 /// Clients can use the result to decorate color references in an editor. For example:
1067 ///
1068 /// * Color boxes showing the actual color next to the reference
1069 /// * Show a color picker when a color reference is edited
1070 ///
1071 /// # Compatibility
1072 ///
1073 /// This request was introduced in specification version 3.6.0.
1074 #[rpc(name = "textDocument/documentColor")]
1075 async fn document_color(&self, params: DocumentColorParams) -> Result<Vec<ColorInformation>> {
1076 let _ = params;
1077 error!("got a `textDocument/documentColor` request, but it is not implemented");
1078 Err(Error::method_not_found())
1079 }
1080
1081 /// The [`textDocument/colorPresentation`] request is sent from the client to the server to
1082 /// obtain a list of presentations for a color value at a given location.
1083 ///
1084 /// [`textDocument/colorPresentation`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_colorPresentation
1085 ///
1086 /// Clients can use the result to:
1087 ///
1088 /// * Modify a color reference
1089 /// * Show in a color picker and let users pick one of the presentations
1090 ///
1091 /// # Compatibility
1092 ///
1093 /// This request was introduced in specification version 3.6.0.
1094 ///
1095 /// This request has no special capabilities and registration options since it is sent as a
1096 /// resolve request for the [`textDocument/documentColor`](Self::document_color) request.
1097 #[rpc(name = "textDocument/colorPresentation")]
1098 async fn color_presentation(
1099 &self,
1100 params: ColorPresentationParams,
1101 ) -> Result<Vec<ColorPresentation>> {
1102 let _ = params;
1103 error!("got a `textDocument/colorPresentation` request, but it is not implemented");
1104 Err(Error::method_not_found())
1105 }
1106
1107 /// The [`textDocument/formatting`] request is sent from the client to the server to format a
1108 /// whole document.
1109 ///
1110 /// [`textDocument/formatting`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_formatting
1111 #[rpc(name = "textDocument/formatting")]
1112 async fn formatting(&self, params: DocumentFormattingParams) -> Result<Option<Vec<TextEdit>>> {
1113 let _ = params;
1114 error!("got a `textDocument/formatting` request, but it is not implemented");
1115 Err(Error::method_not_found())
1116 }
1117
1118 /// The [`textDocument/rangeFormatting`] request is sent from pub(crate) the client to the server to
1119 /// format a given range in a document.
1120 ///
1121 /// [`textDocument/rangeFormatting`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_rangeFormatting
1122 #[rpc(name = "textDocument/rangeFormatting")]
1123 async fn range_formatting(
1124 &self,
1125 params: DocumentRangeFormattingParams,
1126 ) -> Result<Option<Vec<TextEdit>>> {
1127 let _ = params;
1128 error!("got a `textDocument/rangeFormatting` request, but it is not implemented");
1129 Err(Error::method_not_found())
1130 }
1131
1132 /// The [`textDocument/onTypeFormatting`] request is sent from the client to the server to
1133 /// format parts of the document during typing.
1134 ///
1135 /// [`textDocument/onTypeFormatting`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_onTypeFormatting
1136 #[rpc(name = "textDocument/onTypeFormatting")]
1137 async fn on_type_formatting(
1138 &self,
1139 params: DocumentOnTypeFormattingParams,
1140 ) -> Result<Option<Vec<TextEdit>>> {
1141 let _ = params;
1142 error!("got a `textDocument/onTypeFormatting` request, but it is not implemented");
1143 Err(Error::method_not_found())
1144 }
1145
1146 /// The [`textDocument/rename`] request is sent from the client to the server to ask the server
1147 /// to compute a workspace change so that the client can perform a workspace-wide rename of a
1148 /// symbol.
1149 ///
1150 /// [`textDocument/rename`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_rename
1151 #[rpc(name = "textDocument/rename")]
1152 async fn rename(&self, params: RenameParams) -> Result<Option<WorkspaceEdit>> {
1153 let _ = params;
1154 error!("got a `textDocument/rename` request, but it is not implemented");
1155 Err(Error::method_not_found())
1156 }
1157
1158 /// The [`textDocument/prepareRename`] request is sent from the client to the server to setup
1159 /// and test the validity of a rename operation at a given location.
1160 ///
1161 /// [`textDocument/prepareRename`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_prepareRename
1162 ///
1163 /// # Compatibility
1164 ///
1165 /// This request was introduced in specification version 3.12.0.
1166 #[rpc(name = "textDocument/prepareRename")]
1167 async fn prepare_rename(
1168 &self,
1169 params: TextDocumentPositionParams,
1170 ) -> Result<Option<PrepareRenameResponse>> {
1171 let _ = params;
1172 error!("got a `textDocument/prepareRename` request, but it is not implemented");
1173 Err(Error::method_not_found())
1174 }
1175
1176 /// The [`textDocument/linkedEditingRange`] request is sent from the client to the server to
1177 /// return for a given position in a document the range of the symbol at the position and all
1178 /// ranges that have the same content.
1179 ///
1180 /// [`textDocument/linkedEditingRange`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_linkedEditingRange
1181 ///
1182 /// Optionally a word pattern can be returned to describe valid contents.
1183 ///
1184 /// A rename to one of the ranges can be applied to all other ranges if the new content is
1185 /// valid. If no result-specific word pattern is provided, the word pattern from the client's
1186 /// language configuration is used.
1187 ///
1188 /// # Compatibility
1189 ///
1190 /// This request was introduced in specification version 3.16.0.
1191 #[rpc(name = "textDocument/linkedEditingRange")]
1192 async fn linked_editing_range(
1193 &self,
1194 params: LinkedEditingRangeParams,
1195 ) -> Result<Option<LinkedEditingRanges>> {
1196 let _ = params;
1197 error!("got a `textDocument/linkedEditingRange` request, but it is not implemented");
1198 Err(Error::method_not_found())
1199 }
1200
1201 // Workspace Features
1202
1203 /// The [`workspace/symbol`] request is sent from the client to the server to list project-wide
1204 /// symbols matching the given query string.
1205 ///
1206 /// [`workspace/symbol`]: https://microsoft.github.io/language-server-protocol/specification#workspace_symbol
1207 ///
1208 /// # Compatibility
1209 ///
1210 /// Since 3.17.0, servers can also provider a handler for [`workspaceSymbol/resolve`] requests.
1211 /// This allows servers to return workspace symbols without a range for a `workspace/symbol`
1212 /// request. Clients then need to resolve the range when necessary using the
1213 /// `workspaceSymbol/resolve` request.
1214 ///
1215 /// [`workspaceSymbol/resolve`]: Self::symbol_resolve
1216 ///
1217 /// Servers can only use this new model if clients advertise support for it via the
1218 /// `workspace.symbol.resolve_support` capability.
1219 #[rpc(name = "workspace/symbol")]
1220 async fn symbol(
1221 &self,
1222 params: WorkspaceSymbolParams,
1223 ) -> Result<Option<WorkspaceSymbolResponse>> {
1224 let _ = params;
1225 error!("got a `workspace/symbol` request, but it is not implemented");
1226 Err(Error::method_not_found())
1227 }
1228
1229 /// The [`workspaceSymbol/resolve`] request is sent from the client to the server to resolve
1230 /// additional information for a given workspace symbol.
1231 ///
1232 /// [`workspaceSymbol/resolve`]: https://microsoft.github.io/language-server-protocol/specification#workspace_symbolResolve
1233 ///
1234 /// See the [`symbol`](Self::symbol) documentation for more details.
1235 ///
1236 /// # Compatibility
1237 ///
1238 /// This request was introduced in specification version 3.17.0.
1239 #[rpc(name = "workspaceSymbol/resolve")]
1240 async fn symbol_resolve(&self, params: WorkspaceSymbol) -> Result<WorkspaceSymbol> {
1241 let _ = params;
1242 error!("got a `workspaceSymbol/resolve` request, but it is not implemented");
1243 Err(Error::method_not_found())
1244 }
1245
1246 /// The [`workspace/didChangeConfiguration`] notification is sent from the client to the server
1247 /// to signal the change of configuration settings.
1248 ///
1249 /// [`workspace/didChangeConfiguration`]: https://microsoft.github.io/language-server-protocol/specification#workspace_didChangeConfiguration
1250 #[rpc(name = "workspace/didChangeConfiguration")]
1251 async fn did_change_configuration(&self, params: DidChangeConfigurationParams) {
1252 let _ = params;
1253 warn!("got a `workspace/didChangeConfiguration` notification, but it is not implemented");
1254 }
1255
1256 /// The [`workspace/didChangeWorkspaceFolders`] notification is sent from the client to the
1257 /// server to inform about workspace folder configuration changes.
1258 ///
1259 /// [`workspace/didChangeWorkspaceFolders`]: https://microsoft.github.io/language-server-protocol/specification#workspace_didChangeWorkspaceFolders
1260 ///
1261 /// The notification is sent by default if both of these boolean fields were set to `true` in
1262 /// the [`initialize`](Self::initialize) method:
1263 ///
1264 /// * `InitializeParams::capabilities::workspace::workspace_folders`
1265 /// * `InitializeResult::capabilities::workspace::workspace_folders::supported`
1266 ///
1267 /// This notification is also sent if the server has registered itself to receive this
1268 /// notification.
1269 #[rpc(name = "workspace/didChangeWorkspaceFolders")]
1270 async fn did_change_workspace_folders(&self, params: DidChangeWorkspaceFoldersParams) {
1271 let _ = params;
1272 warn!("got a `workspace/didChangeWorkspaceFolders` notification, but it is not implemented");
1273 }
1274
1275 /// The [`workspace/willCreateFiles`] request is sent from the client to the server before
1276 /// files are actually created as long as the creation is triggered from within the client.
1277 ///
1278 /// [`workspace/willCreateFiles`]: https://microsoft.github.io/language-server-protocol/specification#workspace_willCreateFiles
1279 ///
1280 /// The request can return a [`WorkspaceEdit`] which will be applied to workspace before the
1281 /// files are created. Please note that clients might drop results if computing the edit took
1282 /// too long or if a server constantly fails on this request. This is done to keep creates fast
1283 /// and reliable.
1284 ///
1285 /// # Compatibility
1286 ///
1287 /// This request was introduced in specification version 3.16.0.
1288 #[rpc(name = "workspace/willCreateFiles")]
1289 async fn will_create_files(&self, params: CreateFilesParams) -> Result<Option<WorkspaceEdit>> {
1290 let _ = params;
1291 error!("got a `workspace/willCreateFiles` request, but it is not implemented");
1292 Err(Error::method_not_found())
1293 }
1294
1295 /// The [`workspace/didCreateFiles`] request is sent from the client to the server when files
1296 /// were created from within the client.
1297 ///
1298 /// [`workspace/didCreateFiles`]: https://microsoft.github.io/language-server-protocol/specification#workspace_didCreateFiles
1299 #[rpc(name = "workspace/didCreateFiles")]
1300 async fn did_create_files(&self, params: CreateFilesParams) {
1301 let _ = params;
1302 warn!("got a `workspace/didCreateFiles` notification, but it is not implemented");
1303 }
1304
1305 /// The [`workspace/willRenameFiles`] request is sent from the client to the server before
1306 /// files are actually renamed as long as the rename is triggered from within the client.
1307 ///
1308 /// [`workspace/willRenameFiles`]: https://microsoft.github.io/language-server-protocol/specification#workspace_willRenameFiles
1309 ///
1310 /// The request can return a [`WorkspaceEdit`] which will be applied to workspace before the
1311 /// files are renamed. Please note that clients might drop results if computing the edit took
1312 /// too long or if a server constantly fails on this request. This is done to keep creates fast
1313 /// and reliable.
1314 ///
1315 /// # Compatibility
1316 ///
1317 /// This request was introduced in specification version 3.16.0.
1318 #[rpc(name = "workspace/willRenameFiles")]
1319 async fn will_rename_files(&self, params: RenameFilesParams) -> Result<Option<WorkspaceEdit>> {
1320 let _ = params;
1321 error!("got a `workspace/willRenameFiles` request, but it is not implemented");
1322 Err(Error::method_not_found())
1323 }
1324
1325 /// The [`workspace/didRenameFiles`] notification is sent from the client to the server when
1326 /// files were renamed from within the client.
1327 ///
1328 /// [`workspace/didRenameFiles`]: https://microsoft.github.io/language-server-protocol/specification#workspace_didRenameFiles
1329 #[rpc(name = "workspace/didRenameFiles")]
1330 async fn did_rename_files(&self, params: RenameFilesParams) {
1331 let _ = params;
1332 warn!("got a `workspace/didRenameFiles` notification, but it is not implemented");
1333 }
1334
1335 /// The [`workspace/willDeleteFiles`] request is sent from the client to the server before
1336 /// files are actually deleted as long as the deletion is triggered from within the client
1337 /// either by a user action or by applying a workspace edit.
1338 ///
1339 /// [`workspace/willDeleteFiles`]: https://microsoft.github.io/language-server-protocol/specification#workspace_willDeleteFiles
1340 ///
1341 /// The request can return a [`WorkspaceEdit`] which will be applied to workspace before the
1342 /// files are deleted. Please note that clients might drop results if computing the edit took
1343 /// too long or if a server constantly fails on this request. This is done to keep deletions
1344 /// fast and reliable.
1345 ///
1346 /// # Compatibility
1347 ///
1348 /// This request was introduced in specification version 3.16.0.
1349 #[rpc(name = "workspace/willDeleteFiles")]
1350 async fn will_delete_files(&self, params: DeleteFilesParams) -> Result<Option<WorkspaceEdit>> {
1351 let _ = params;
1352 error!("got a `workspace/willDeleteFiles` request, but it is not implemented");
1353 Err(Error::method_not_found())
1354 }
1355
1356 /// The [`workspace/didDeleteFiles`] notification is sent from the client to the server when
1357 /// files were deleted from within the client.
1358 ///
1359 /// [`workspace/didDeleteFiles`]: https://microsoft.github.io/language-server-protocol/specification#workspace_didDeleteFiles
1360 #[rpc(name = "workspace/didDeleteFiles")]
1361 async fn did_delete_files(&self, params: DeleteFilesParams) {
1362 let _ = params;
1363 warn!("got a `workspace/didDeleteFiles` notification, but it is not implemented");
1364 }
1365
1366 /// The [`workspace/didChangeWatchedFiles`] notification is sent from the client to the server
1367 /// when the client detects changes to files watched by the language client.
1368 ///
1369 /// [`workspace/didChangeWatchedFiles`]: https://microsoft.github.io/language-server-protocol/specification#workspace_didChangeWatchedFiles
1370 ///
1371 /// It is recommended that servers register for these file events using the registration
1372 /// mechanism. This can be done here or in the [`initialized`](Self::initialized) method using
1373 /// [`Client::register_capability`](crate::Client::register_capability).
1374 #[rpc(name = "workspace/didChangeWatchedFiles")]
1375 async fn did_change_watched_files(&self, params: DidChangeWatchedFilesParams) {
1376 let _ = params;
1377 warn!("got a `workspace/didChangeWatchedFiles` notification, but it is not implemented");
1378 }
1379
1380 /// The [`workspace/executeCommand`] request is sent from the client to the server to trigger
1381 /// command execution on the server.
1382 ///
1383 /// [`workspace/executeCommand`]: https://microsoft.github.io/language-server-protocol/specification#workspace_executeCommand
1384 ///
1385 /// In most cases, the server creates a [`WorkspaceEdit`] structure and applies the changes to
1386 /// the workspace using `Client::apply_edit()` before returning from this function.
1387 #[rpc(name = "workspace/executeCommand")]
1388 async fn execute_command(&self, params: ExecuteCommandParams) -> Result<Option<LSPAny>> {
1389 let _ = params;
1390 error!("got a `workspace/executeCommand` request, but it is not implemented");
1391 Err(Error::method_not_found())
1392 }
1393
1394 // TODO: Add `work_done_progress_cancel()` here (since 3.15.0) when supported by `tower-lsp-server`
1395 // https://github.com/ebkalderon/tower-lsp/issues/176
1396 }
1397}