Properly show the binary stats
Co-authored-by: Ben Kunkle <ben@zed.dev> Co-authored-by: Lukas Wirth <lukas@zed.dev>
This commit is contained in:
parent
1cc491a919
commit
13c8d4e052
2 changed files with 77 additions and 25 deletions
|
@ -11,8 +11,8 @@ use gpui::{
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use language::{LanguageServerId, language_settings::SoftWrap};
|
use language::{LanguageServerId, language_settings::SoftWrap};
|
||||||
use lsp::{
|
use lsp::{
|
||||||
IoKind, LanguageServer, LanguageServerName, LanguageServerSelector, MessageType,
|
IoKind, LanguageServer, LanguageServerBinary, LanguageServerName, LanguageServerSelector,
|
||||||
SetTraceParams, TraceValue, notification::SetTrace,
|
MessageType, SetTraceParams, TraceValue, notification::SetTrace,
|
||||||
};
|
};
|
||||||
use project::{Project, WorktreeId, lsp_store::LanguageServerLogType, search::SearchQuery};
|
use project::{Project, WorktreeId, lsp_store::LanguageServerLogType, search::SearchQuery};
|
||||||
use proto::TypedEnvelope;
|
use proto::TypedEnvelope;
|
||||||
|
@ -951,7 +951,7 @@ impl LspLogView {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn editor_for_server_info(
|
fn editor_for_server_info(
|
||||||
server: &LanguageServer,
|
info: ServerInfo,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> (Entity<Editor>, Vec<Subscription>) {
|
) -> (Entity<Editor>, Vec<Subscription>) {
|
||||||
|
@ -966,22 +966,21 @@ impl LspLogView {
|
||||||
* Capabilities: {CAPABILITIES}
|
* Capabilities: {CAPABILITIES}
|
||||||
|
|
||||||
* Configuration: {CONFIGURATION}",
|
* Configuration: {CONFIGURATION}",
|
||||||
NAME = server.name(),
|
NAME = info.name,
|
||||||
ID = server.server_id(),
|
ID = info.id,
|
||||||
BINARY = server.binary(),
|
BINARY = info.binary.as_ref().map_or_else(
|
||||||
WORKSPACE_FOLDERS = server
|
|| "Unknown".to_string(),
|
||||||
.workspace_folders()
|
|bin| bin.path.as_path().to_string_lossy().to_string()
|
||||||
.into_iter()
|
),
|
||||||
.filter_map(|path| path
|
WORKSPACE_FOLDERS = info.workspace_folders.join(", "),
|
||||||
.to_file_path()
|
CAPABILITIES = serde_json::to_string_pretty(&info.capabilities)
|
||||||
.ok()
|
|
||||||
.map(|path| path.to_string_lossy().into_owned()))
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.join(", "),
|
|
||||||
CAPABILITIES = serde_json::to_string_pretty(&server.capabilities())
|
|
||||||
.unwrap_or_else(|e| format!("Failed to serialize capabilities: {e}")),
|
.unwrap_or_else(|e| format!("Failed to serialize capabilities: {e}")),
|
||||||
CONFIGURATION = serde_json::to_string_pretty(server.configuration())
|
CONFIGURATION = info
|
||||||
.unwrap_or_else(|e| format!("Failed to serialize configuration: {e}")),
|
.configuration
|
||||||
|
.map(|configuration| serde_json::to_string_pretty(&configuration))
|
||||||
|
.transpose()
|
||||||
|
.unwrap_or_else(|e| Some(format!("Failed to serialize configuration: {e}")))
|
||||||
|
.unwrap_or_else(|| "Unknown".to_string()),
|
||||||
);
|
);
|
||||||
let editor = initialize_new_editor(server_info, false, window, cx);
|
let editor = initialize_new_editor(server_info, false, window, cx);
|
||||||
let editor_subscription = cx.subscribe(
|
let editor_subscription = cx.subscribe(
|
||||||
|
@ -1247,15 +1246,38 @@ impl LspLogView {
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
// todo! there's no language server for the remote case, hence no server info!
|
let Some(server_info) = self
|
||||||
// BUT we do have the capabilities info within the LspStore.lsp_server_capabilities
|
.project
|
||||||
let lsp_store = self.project.read(cx).lsp_store();
|
.read(cx)
|
||||||
let Some(server) = lsp_store.read(cx).language_server_for_id(server_id) else {
|
.lsp_store()
|
||||||
|
.update(cx, |lsp_store, _| {
|
||||||
|
lsp_store
|
||||||
|
.language_server_for_id(server_id)
|
||||||
|
.as_ref()
|
||||||
|
.map(|language_server| ServerInfo::new(language_server))
|
||||||
|
.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())?;
|
||||||
|
Some(ServerInfo {
|
||||||
|
id: server_id,
|
||||||
|
capabilities,
|
||||||
|
binary: None,
|
||||||
|
name,
|
||||||
|
workspace_folders: Vec::new(),
|
||||||
|
configuration: None,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
self.current_server_id = Some(server_id);
|
self.current_server_id = Some(server_id);
|
||||||
self.active_entry_kind = LogKind::ServerInfo;
|
self.active_entry_kind = LogKind::ServerInfo;
|
||||||
let (editor, editor_subscriptions) = Self::editor_for_server_info(&server, window, cx);
|
let (editor, editor_subscriptions) = Self::editor_for_server_info(server_info, window, cx);
|
||||||
self.editor = editor;
|
self.editor = editor;
|
||||||
self.editor_subscriptions = editor_subscriptions;
|
self.editor_subscriptions = editor_subscriptions;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
|
@ -1870,6 +1892,36 @@ impl LspLogToolbarItemView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ServerInfo {
|
||||||
|
id: LanguageServerId,
|
||||||
|
capabilities: lsp::ServerCapabilities,
|
||||||
|
binary: Option<LanguageServerBinary>,
|
||||||
|
name: LanguageServerName,
|
||||||
|
workspace_folders: Vec<String>,
|
||||||
|
configuration: Option<serde_json::Value>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ServerInfo {
|
||||||
|
fn new(server: &LanguageServer) -> Self {
|
||||||
|
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()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
NewServerLogEntry {
|
NewServerLogEntry {
|
||||||
id: LanguageServerId,
|
id: LanguageServerId,
|
||||||
|
|
|
@ -3488,13 +3488,13 @@ pub struct LspStore {
|
||||||
buffer_store: Entity<BufferStore>,
|
buffer_store: Entity<BufferStore>,
|
||||||
worktree_store: Entity<WorktreeStore>,
|
worktree_store: Entity<WorktreeStore>,
|
||||||
pub languages: Arc<LanguageRegistry>,
|
pub languages: Arc<LanguageRegistry>,
|
||||||
language_server_statuses: BTreeMap<LanguageServerId, LanguageServerStatus>,
|
pub language_server_statuses: BTreeMap<LanguageServerId, LanguageServerStatus>,
|
||||||
active_entry: Option<ProjectEntryId>,
|
active_entry: Option<ProjectEntryId>,
|
||||||
_maintain_workspace_config: (Task<Result<()>>, watch::Sender<()>),
|
_maintain_workspace_config: (Task<Result<()>>, watch::Sender<()>),
|
||||||
_maintain_buffer_languages: Task<()>,
|
_maintain_buffer_languages: Task<()>,
|
||||||
diagnostic_summaries:
|
diagnostic_summaries:
|
||||||
HashMap<WorktreeId, HashMap<Arc<Path>, HashMap<LanguageServerId, DiagnosticSummary>>>,
|
HashMap<WorktreeId, HashMap<Arc<Path>, HashMap<LanguageServerId, DiagnosticSummary>>>,
|
||||||
pub(super) lsp_server_capabilities: HashMap<LanguageServerId, lsp::ServerCapabilities>,
|
pub lsp_server_capabilities: HashMap<LanguageServerId, lsp::ServerCapabilities>,
|
||||||
lsp_document_colors: HashMap<BufferId, DocumentColorData>,
|
lsp_document_colors: HashMap<BufferId, DocumentColorData>,
|
||||||
lsp_code_lens: HashMap<BufferId, CodeLensData>,
|
lsp_code_lens: HashMap<BufferId, CodeLensData>,
|
||||||
running_lsp_requests: HashMap<TypeId, (Global, HashMap<LspRequestId, Task<()>>)>,
|
running_lsp_requests: HashMap<TypeId, (Global, HashMap<LspRequestId, Task<()>>)>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue