Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
lsp: Add support for dynamic registration of rename capability (#25610)
Piotr Osiewicz3db18ff05324
diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rsindex d277697f8bb..806350bb363 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::<lsp::RenameOptions>(+ 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)