See language server status on remote (#17912)

Release Notes:

- ssh-remoting: Show LSP status in status bar

Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
Conrad Irwin 2024-09-16 17:05:26 -06:00 committed by GitHub
parent 243629cce8
commit e7d18ef359
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 41 additions and 22 deletions

1
Cargo.lock generated
View file

@ -9069,6 +9069,7 @@ dependencies = [
"shellexpand 2.1.2",
"smol",
"toml 0.8.19",
"util",
"worktree",
]

View file

@ -3314,6 +3314,12 @@ impl LspStore {
}
cx.emit(LspStoreEvent::DiskBasedDiagnosticsStarted { language_server_id });
cx.emit(LspStoreEvent::LanguageServerUpdate {
language_server_id,
message: proto::update_language_server::Variant::DiskBasedDiagnosticsUpdating(
Default::default(),
),
})
}
pub fn disk_based_diagnostics_finished(
@ -3328,6 +3334,12 @@ impl LspStore {
}
cx.emit(LspStoreEvent::DiskBasedDiagnosticsFinished { language_server_id });
cx.emit(LspStoreEvent::LanguageServerUpdate {
language_server_id,
message: proto::update_language_server::Variant::DiskBasedDiagnosticsUpdated(
Default::default(),
),
})
}
// After saving a buffer using a language server that doesn't provide a disk-based progress token,

View file

@ -2188,32 +2188,11 @@ impl Project {
cx.emit(Event::DiskBasedDiagnosticsStarted {
language_server_id: *language_server_id,
});
if self.is_local_or_ssh() {
self.enqueue_buffer_ordered_message(BufferOrderedMessage::LanguageServerUpdate {
language_server_id: *language_server_id,
message: proto::update_language_server::Variant::DiskBasedDiagnosticsUpdating(
Default::default(),
),
})
.ok();
}
}
LspStoreEvent::DiskBasedDiagnosticsFinished { language_server_id } => {
cx.emit(Event::DiskBasedDiagnosticsFinished {
language_server_id: *language_server_id,
});
if self.is_local_or_ssh() {
self.enqueue_buffer_ordered_message(
BufferOrderedMessage::LanguageServerUpdate {
language_server_id: *language_server_id,
message:
proto::update_language_server::Variant::DiskBasedDiagnosticsUpdated(
Default::default(),
),
},
)
.ok();
}
}
LspStoreEvent::LanguageServerUpdate {
language_server_id,

View file

@ -37,6 +37,7 @@ shellexpand.workspace = true
smol.workspace = true
worktree.workspace = true
language.workspace = true
util.workspace = true
[dev-dependencies]
client = { workspace = true, features = ["test-support"] }

View file

@ -7,7 +7,7 @@ use project::{
project_settings::SettingsObserver,
search::SearchQuery,
worktree_store::WorktreeStore,
LspStore, ProjectPath, WorktreeId,
LspStore, LspStoreEvent, ProjectPath, WorktreeId,
};
use remote::SshSession;
use rpc::{
@ -19,6 +19,7 @@ use std::{
path::{Path, PathBuf},
sync::{atomic::AtomicUsize, Arc},
};
use util::ResultExt;
use worktree::Worktree;
pub struct HeadlessProject {
@ -73,6 +74,8 @@ impl HeadlessProject {
lsp_store
});
cx.subscribe(&lsp_store, Self::on_lsp_store_event).detach();
cx.subscribe(
&buffer_store,
|_this, _buffer_store, event, cx| match event {
@ -141,6 +144,29 @@ impl HeadlessProject {
}
}
fn on_lsp_store_event(
&mut self,
_lsp_store: Model<LspStore>,
event: &LspStoreEvent,
_cx: &mut ModelContext<Self>,
) {
match event {
LspStoreEvent::LanguageServerUpdate {
language_server_id,
message,
} => {
self.session
.send(proto::UpdateLanguageServer {
project_id: SSH_PROJECT_ID,
language_server_id: language_server_id.to_proto(),
variant: Some(message.clone()),
})
.log_err();
}
_ => {}
}
}
pub async fn handle_add_worktree(
this: Model<Self>,
message: TypedEnvelope<proto::AddWorktree>,