project: Send LSP metadata to remote ServerInfo (#42831)

Closes #39582

Release Notes:

- Added LSP metadata to remote ServerInfo

Here's the before/after:


https://github.com/user-attachments/assets/1057faa5-82af-4975-abad-5e10e139fac1

---------

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
This commit is contained in:
Mayank Verma
2025-11-24 23:16:35 +02:00
committed by GitHub
co-authored by Kirill Bulatov
parent bd2c1027fa
commit 342eba6f22
4 changed files with 136 additions and 45 deletions
+48 -34
View File
@@ -7,12 +7,15 @@ use gpui::{
};
use language::{LanguageServerId, language_settings::SoftWrap};
use lsp::{
LanguageServer, LanguageServerBinary, LanguageServerName, LanguageServerSelector, MessageType,
SetTraceParams, TraceValue, notification::SetTrace,
LanguageServer, LanguageServerName, LanguageServerSelector, MessageType, SetTraceParams,
TraceValue, notification::SetTrace,
};
use project::{
Project,
lsp_store::log_store::{self, Event, LanguageServerKind, LogKind, LogStore, Message},
LanguageServerStatus, Project,
lsp_store::{
LanguageServerBinaryInfo,
log_store::{self, Event, LanguageServerKind, LogKind, LogStore, Message},
},
search::SearchQuery,
};
use proto::toggle_lsp_logs::LogType;
@@ -337,16 +340,28 @@ impl LspLogView {
* Capabilities: {CAPABILITIES}
* Configuration: {CONFIGURATION}",
NAME = info.name,
NAME = info.status.name,
ID = info.id,
BINARY = info
.binary
.as_ref()
.map_or_else(|| "Unknown".to_string(), |binary| format!("{binary:#?}")),
WORKSPACE_FOLDERS = info.workspace_folders.join(", "),
BINARY = info.status.binary.as_ref().map_or_else(
|| "Unknown".to_string(),
|binary| serde_json::to_string_pretty(binary)
.unwrap_or_else(|e| format!("Failed to serialize binary info: {e:#}"))
),
WORKSPACE_FOLDERS = info
.status
.workspace_folders
.iter()
.filter_map(|uri| {
uri.to_file_path()
.ok()
.map(|path| path.to_string_lossy().into_owned())
})
.collect::<Vec<_>>()
.join(", "),
CAPABILITIES = serde_json::to_string_pretty(&info.capabilities)
.unwrap_or_else(|e| format!("Failed to serialize capabilities: {e}")),
CONFIGURATION = info
.status
.configuration
.map(|configuration| serde_json::to_string_pretty(&configuration))
.transpose()
@@ -633,17 +648,12 @@ impl LspLogView {
.or_else(move || {
let capabilities =
lsp_store.lsp_server_capabilities.get(&server_id)?.clone();
let name = lsp_store
.language_server_statuses
.get(&server_id)
.map(|status| status.name.clone())?;
let status = lsp_store.language_server_statuses.get(&server_id)?.clone();
Some(ServerInfo {
id: server_id,
capabilities,
binary: None,
name,
workspace_folders: Vec::new(),
configuration: None,
status,
})
})
})
@@ -1314,10 +1324,7 @@ impl LspLogToolbarItemView {
struct ServerInfo {
id: LanguageServerId,
capabilities: lsp::ServerCapabilities,
binary: Option<LanguageServerBinary>,
name: LanguageServerName,
workspace_folders: Vec<String>,
configuration: Option<serde_json::Value>,
status: LanguageServerStatus,
}
impl ServerInfo {
@@ -1325,18 +1332,25 @@ impl ServerInfo {
Self {
id: server.server_id(),
capabilities: server.capabilities(),
binary: Some(server.binary().clone()),
name: server.name(),
workspace_folders: server
.workspace_folders()
.into_iter()
.filter_map(|path| {
path.to_file_path()
.ok()
.map(|path| path.to_string_lossy().into_owned())
})
.collect::<Vec<_>>(),
configuration: Some(server.configuration().clone()),
status: LanguageServerStatus {
name: server.name(),
pending_work: Default::default(),
has_pending_diagnostic_updates: false,
progress_tokens: Default::default(),
worktree: None,
binary: Some(LanguageServerBinaryInfo {
path: server.binary().path.to_string_lossy().into_owned(),
arguments: server
.binary()
.arguments
.iter()
.map(|arg| arg.to_string_lossy().into_owned())
.collect(),
env: server.binary().env.clone(),
}),
configuration: Some(server.configuration().clone()),
workspace_folders: server.workspace_folders(),
},
}
}
}