Fix remote clients unable to query custom, lsp_ext, commands (#27775)

Closes https://github.com/zed-industries/zed/issues/20583
Closes https://github.com/zed-industries/zed/issues/27133

A preparation for rust-analyzer's LSP tasks fetching, ensures all remote
clients are able to query custom, lsp_ext, commands.

Release Notes:

- Fixed remote clients unable to query custom, lsp_ext, commands
This commit is contained in:
Kirill Bulatov 2025-03-31 19:13:09 +03:00 committed by GitHub
parent c8a9a74e6a
commit e1e8c1786e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 430 additions and 140 deletions

View file

@ -3425,6 +3425,7 @@ impl LspStore {
client.add_entity_request_handler(Self::handle_apply_additional_edits_for_completion);
client.add_entity_request_handler(Self::handle_register_buffer_with_language_servers);
client.add_entity_request_handler(Self::handle_rename_project_entry);
client.add_entity_request_handler(Self::handle_language_server_id_for_name);
client.add_entity_request_handler(Self::handle_lsp_command::<GetCodeActions>);
client.add_entity_request_handler(Self::handle_lsp_command::<GetCompletions>);
client.add_entity_request_handler(Self::handle_lsp_command::<GetHover>);
@ -3436,8 +3437,13 @@ impl LspStore {
client.add_entity_request_handler(Self::handle_lsp_command::<GetReferences>);
client.add_entity_request_handler(Self::handle_lsp_command::<PrepareRename>);
client.add_entity_request_handler(Self::handle_lsp_command::<PerformRename>);
client.add_entity_request_handler(Self::handle_lsp_command::<lsp_ext_command::ExpandMacro>);
client.add_entity_request_handler(Self::handle_lsp_command::<LinkedEditingRange>);
client.add_entity_request_handler(Self::handle_lsp_command::<lsp_ext_command::ExpandMacro>);
client.add_entity_request_handler(Self::handle_lsp_command::<lsp_ext_command::OpenDocs>);
client.add_entity_request_handler(
Self::handle_lsp_command::<lsp_ext_command::SwitchSourceHeader>,
);
}
pub fn as_remote(&self) -> Option<&RemoteLspStore> {
@ -6986,6 +6992,34 @@ impl LspStore {
Ok(proto::Ack {})
}
async fn handle_language_server_id_for_name(
lsp_store: Entity<Self>,
envelope: TypedEnvelope<proto::LanguageServerIdForName>,
mut cx: AsyncApp,
) -> Result<proto::LanguageServerIdForNameResponse> {
let buffer_id = BufferId::new(envelope.payload.buffer_id)?;
let name = &envelope.payload.name;
lsp_store
.update(&mut cx, |lsp_store, cx| {
let buffer = lsp_store.buffer_store.read(cx).get_existing(buffer_id)?;
let server_id = buffer.update(cx, |buffer, cx| {
lsp_store
.language_servers_for_local_buffer(buffer, cx)
.find_map(|(adapter, server)| {
if adapter.name.0.as_ref() == name {
Some(server.server_id())
} else {
None
}
})
});
Ok(server_id)
})?
.map(|server_id| proto::LanguageServerIdForNameResponse {
server_id: server_id.map(|id| id.to_proto()),
})
}
async fn handle_rename_project_entry(
this: Entity<Self>,
envelope: TypedEnvelope<proto::RenameProjectEntry>,