Stop sending redundant LSP proto requests (#35581)
Before, each time any LSP feature was used on client remote, it always produced a `proto::` request that always had been sent to the host, from where returned as an empty response. Instead, propagate more language server-related data to the client, `lsp::ServerCapability`, so Zed client can omit certain requests if those are not supported. On top of that, rework the approach Zed uses to query for the data refreshes: before, editors tried to fetch the data when the server start was reported (locally and remotely). Now, a later event is selected: on each `textDocument/didOpen` for the buffer contained in this editor, we will query for new LSP data, reusing the cache if needed. Before, servers could reject unregistered files' LSP queries, or process them slowly when starting up. Now, such refreshes are happening later and should be cached. This requires a collab DB change, to restore server data on rejoin. Release Notes: - Fixed excessive LSP requests sent during remote sessions
This commit is contained in:
parent
5b40b3618f
commit
22473fc611
19 changed files with 793 additions and 351 deletions
|
@ -2154,6 +2154,16 @@ impl LspCommand for GetHover {
|
|||
}
|
||||
}
|
||||
|
||||
impl GetCompletions {
|
||||
pub fn can_resolve_completions(capabilities: &lsp::ServerCapabilities) -> bool {
|
||||
capabilities
|
||||
.completion_provider
|
||||
.as_ref()
|
||||
.and_then(|options| options.resolve_provider)
|
||||
.unwrap_or(false)
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
impl LspCommand for GetCompletions {
|
||||
type Response = CoreCompletionResponse;
|
||||
|
@ -2762,6 +2772,23 @@ impl GetCodeActions {
|
|||
}
|
||||
}
|
||||
|
||||
impl OnTypeFormatting {
|
||||
pub fn supports_on_type_formatting(trigger: &str, capabilities: &ServerCapabilities) -> bool {
|
||||
let Some(on_type_formatting_options) = &capabilities.document_on_type_formatting_provider
|
||||
else {
|
||||
return false;
|
||||
};
|
||||
on_type_formatting_options
|
||||
.first_trigger_character
|
||||
.contains(trigger)
|
||||
|| on_type_formatting_options
|
||||
.more_trigger_character
|
||||
.iter()
|
||||
.flatten()
|
||||
.any(|chars| chars.contains(trigger))
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait(?Send)]
|
||||
impl LspCommand for OnTypeFormatting {
|
||||
type Response = Option<Transaction>;
|
||||
|
@ -2773,20 +2800,7 @@ impl LspCommand for OnTypeFormatting {
|
|||
}
|
||||
|
||||
fn check_capabilities(&self, capabilities: AdapterServerCapabilities) -> bool {
|
||||
let Some(on_type_formatting_options) = &capabilities
|
||||
.server_capabilities
|
||||
.document_on_type_formatting_provider
|
||||
else {
|
||||
return false;
|
||||
};
|
||||
on_type_formatting_options
|
||||
.first_trigger_character
|
||||
.contains(&self.trigger)
|
||||
|| on_type_formatting_options
|
||||
.more_trigger_character
|
||||
.iter()
|
||||
.flatten()
|
||||
.any(|chars| chars.contains(&self.trigger))
|
||||
Self::supports_on_type_formatting(&self.trigger, &capabilities.server_capabilities)
|
||||
}
|
||||
|
||||
fn to_lsp(
|
||||
|
@ -4221,8 +4235,9 @@ impl LspCommand for GetDocumentColor {
|
|||
server_capabilities
|
||||
.server_capabilities
|
||||
.color_provider
|
||||
.as_ref()
|
||||
.is_some_and(|capability| match capability {
|
||||
lsp::ColorProviderCapability::Simple(supported) => supported,
|
||||
lsp::ColorProviderCapability::Simple(supported) => *supported,
|
||||
lsp::ColorProviderCapability::ColorProvider(..) => true,
|
||||
lsp::ColorProviderCapability::Options(..) => true,
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue