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:
Kirill Bulatov 2025-08-05 16:36:05 +03:00 committed by GitHub
parent 5b40b3618f
commit 22473fc611
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 793 additions and 351 deletions

View file

@ -71,6 +71,7 @@ message RejoinedProject {
repeated WorktreeMetadata worktrees = 2;
repeated Collaborator collaborators = 3;
repeated LanguageServer language_servers = 4;
repeated string language_server_capabilities = 5;
}
message LeaveRoom {}
@ -199,6 +200,7 @@ message JoinProjectResponse {
repeated WorktreeMetadata worktrees = 2;
repeated Collaborator collaborators = 3;
repeated LanguageServer language_servers = 4;
repeated string language_server_capabilities = 8;
ChannelRole role = 6;
reserved 7;
}

View file

@ -518,6 +518,7 @@ message LanguageServer {
message StartLanguageServer {
uint64 project_id = 1;
LanguageServer server = 2;
string capabilities = 3;
}
message UpdateDiagnosticSummary {
@ -545,6 +546,7 @@ message UpdateLanguageServer {
LspDiskBasedDiagnosticsUpdated disk_based_diagnostics_updated = 7;
StatusUpdate status_update = 9;
RegisteredForBuffer registered_for_buffer = 10;
ServerMetadataUpdated metadata_updated = 11;
}
}
@ -597,6 +599,11 @@ enum ServerBinaryStatus {
message RegisteredForBuffer {
string buffer_abs_path = 1;
uint64 buffer_id = 2;
}
message ServerMetadataUpdated {
optional string capabilities = 1;
}
message LanguageServerLog {