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