From 3db18ff05324290d842771fa86baa490a79ca40c Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Wed, 26 Feb 2025 00:54:29 +0100 Subject: [PATCH] lsp: Add support for dynamic registration of rename capability (#25610) While looking at Biome LSP implementation I've noticed that they register their rename capability dynamically, which we don't handle. Release Notes: - N/A --- crates/project/src/lsp_store.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index d277697f8bb51bb003e7c7ba2fdc84824dc9ba24..806350bb36310a62047a1168c6088ffb73998520 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -663,6 +663,30 @@ impl LocalLspStore { "workspace/didChangeConfiguration" => { // Ignore payload since we notify clients of setting changes unconditionally, relying on them pulling the latest settings. } + "textDocument/rename" => { + this.update(&mut cx, |this, _| { + if let Some(server) = this.language_server_for_id(server_id) + { + let options = reg + .register_options + .map(|options| { + serde_json::from_value::( + options, + ) + }) + .transpose()?; + let options = match options { + None => OneOf::Left(true), + Some(options) => OneOf::Right(options), + }; + + server.update_capabilities(|capabilities| { + capabilities.rename_provider = Some(options); + }) + } + anyhow::Ok(()) + })??; + } _ => log::warn!("unhandled capability registration: {reg:?}"), } } @@ -689,6 +713,9 @@ impl LocalLspStore { Some(()) })?; } + "workspace/didChangeConfiguration" => { + // Ignore payload since we notify clients of setting changes unconditionally, relying on them pulling the latest settings. + } "textDocument/rename" => { this.update(&mut cx, |this, _| { if let Some(server) = this.language_server_for_id(server_id)