clangd: Implement switch source/header extension (#14646)

Release Notes:

- Added switch source/header action for clangd language server (fixes
[#12801](https://github.com/zed-industries/zed/issues/12801)).

Note: I'm new to both rust and this codebase. I started my
implementation by copying how rust analyzer's "expand macro" LSP
extension is implemented. I don't yet understand some of the code I
copied (mostly the way to get the `server_to_query` in `clangd_ext.rs`
and the whole proto implementation).

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
This commit is contained in:
Thorben Kröger 2024-08-21 21:15:08 +02:00 committed by GitHub
parent 96bcceed40
commit f85ca387a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 286 additions and 55 deletions

View file

@ -131,7 +131,7 @@ message Envelope {
UpdateUserPlan update_user_plan = 234;
UpdateDiffBase update_diff_base = 104;
AcceptTermsOfService accept_terms_of_service = 239;
AcceptTermsOfServiceResponse accept_terms_of_service_response = 240; // current max
AcceptTermsOfServiceResponse accept_terms_of_service_response = 240;
OnTypeFormatting on_type_formatting = 105;
OnTypeFormattingResponse on_type_formatting_response = 106;
@ -264,15 +264,18 @@ message Envelope {
GetSignatureHelp get_signature_help = 217;
GetSignatureHelpResponse get_signature_help_response = 218;
ListRemoteDirectory list_remote_directory = 219;
ListRemoteDirectoryResponse list_remote_directory_response = 220;
UpdateDevServerProject update_dev_server_project = 221;
AddWorktree add_worktree = 222;
AddWorktreeResponse add_worktree_response = 223;
GetLlmToken get_llm_token = 235;
GetLlmTokenResponse get_llm_token_response = 236;
LspExtSwitchSourceHeader lsp_ext_switch_source_header = 241;
LspExtSwitchSourceHeaderResponse lsp_ext_switch_source_header_response = 242; // current max
}
reserved 158 to 161;
@ -2076,6 +2079,15 @@ message LspExtExpandMacroResponse {
string expansion = 2;
}
message LspExtSwitchSourceHeader {
uint64 project_id = 1;
uint64 buffer_id = 2;
}
message LspExtSwitchSourceHeaderResponse {
string target_file = 1;
}
message SetRoomParticipantRole {
uint64 room_id = 1;
uint64 user_id = 2;

View file

@ -406,6 +406,8 @@ messages!(
(UpdateContext, Foreground),
(SynchronizeContexts, Foreground),
(SynchronizeContextsResponse, Foreground),
(LspExtSwitchSourceHeader, Background),
(LspExtSwitchSourceHeaderResponse, Background),
(AddWorktree, Foreground),
(AddWorktreeResponse, Foreground),
);
@ -528,6 +530,7 @@ request_messages!(
(OpenContext, OpenContextResponse),
(CreateContext, CreateContextResponse),
(SynchronizeContexts, SynchronizeContextsResponse),
(LspExtSwitchSourceHeader, LspExtSwitchSourceHeaderResponse),
(AddWorktree, AddWorktreeResponse),
);
@ -597,6 +600,7 @@ entity_messages!(
CreateContext,
UpdateContext,
SynchronizeContexts,
LspExtSwitchSourceHeader
);
entity_messages!(