Skip to content

Commit f127ba8

Browse files
SomeoneToIgnoreprobably-nebVeykril
authored
Remote LSP logs (#37083)
Take 2: #36709 but without the very bad `cfg`-based approach for storing the RPC logs. -------------- Enables LSP log tracing in both remote collab and remote ssh environments. Server logs and server RPC traces can now be viewed remotely, and the LSP button is now shown in such projects too. Closes #28557 Co-Authored-By: Kirill <[email protected]> Co-Authored-By: Lukas <[email protected]> Release Notes: - Enabled LSP log tracing in both remote collab and remote ssh environments --------- Co-authored-by: Ben Kunkle <[email protected]> Co-authored-by: Lukas Wirth <[email protected]>
1 parent 39d86ee commit f127ba8

File tree

22 files changed

+1332
-850
lines changed

22 files changed

+1332
-850
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/collab/migrations.sqlite/20221109000000_test_schema.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ CREATE TABLE "language_servers" (
175175
"project_id" INTEGER NOT NULL REFERENCES projects (id) ON DELETE CASCADE,
176176
"name" VARCHAR NOT NULL,
177177
"capabilities" TEXT NOT NULL,
178+
"worktree_id" BIGINT,
178179
PRIMARY KEY (project_id, id)
179180
);
180181

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE language_servers
2+
ADD COLUMN worktree_id BIGINT;

crates/collab/src/db/queries/projects.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,7 @@ impl Database {
694694
project_id: ActiveValue::set(project_id),
695695
id: ActiveValue::set(server.id as i64),
696696
name: ActiveValue::set(server.name.clone()),
697+
worktree_id: ActiveValue::set(server.worktree_id.map(|id| id as i64)),
697698
capabilities: ActiveValue::set(update.capabilities.clone()),
698699
})
699700
.on_conflict(
@@ -704,6 +705,7 @@ impl Database {
704705
.update_columns([
705706
language_server::Column::Name,
706707
language_server::Column::Capabilities,
708+
language_server::Column::WorktreeId,
707709
])
708710
.to_owned(),
709711
)
@@ -1065,7 +1067,7 @@ impl Database {
10651067
server: proto::LanguageServer {
10661068
id: language_server.id as u64,
10671069
name: language_server.name,
1068-
worktree_id: None,
1070+
worktree_id: language_server.worktree_id.map(|id| id as u64),
10691071
},
10701072
capabilities: language_server.capabilities,
10711073
})

crates/collab/src/db/queries/rooms.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ impl Database {
809809
server: proto::LanguageServer {
810810
id: language_server.id as u64,
811811
name: language_server.name,
812-
worktree_id: None,
812+
worktree_id: language_server.worktree_id.map(|id| id as u64),
813813
},
814814
capabilities: language_server.capabilities,
815815
})

crates/collab/src/db/tables/language_server.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub struct Model {
1010
pub id: i64,
1111
pub name: String,
1212
pub capabilities: String,
13+
pub worktree_id: Option<i64>,
1314
}
1415

1516
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]

crates/collab/src/rpc.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,9 @@ impl Server {
476476
.add_request_handler(forward_mutating_project_request::<proto::GitChangeBranch>)
477477
.add_request_handler(forward_mutating_project_request::<proto::CheckForPushedCommits>)
478478
.add_message_handler(broadcast_project_message_from_host::<proto::AdvertiseContexts>)
479-
.add_message_handler(update_context);
479+
.add_message_handler(update_context)
480+
.add_request_handler(forward_mutating_project_request::<proto::ToggleLspLogs>)
481+
.add_message_handler(broadcast_project_message_from_host::<proto::LanguageServerLog>);
480482

481483
Arc::new(server)
482484
}

crates/language_tools/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ itertools.workspace = true
2424
language.workspace = true
2525
lsp.workspace = true
2626
project.workspace = true
27+
proto.workspace = true
2728
serde_json.workspace = true
2829
settings.workspace = true
2930
theme.workspace = true

crates/language_tools/src/language_tools.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
mod key_context_view;
2-
mod lsp_log;
3-
pub mod lsp_tool;
2+
pub mod lsp_button;
3+
pub mod lsp_log_view;
44
mod syntax_tree_view;
55

66
#[cfg(test)]
7-
mod lsp_log_tests;
7+
mod lsp_log_view_tests;
88

99
use gpui::{App, AppContext, Entity};
1010

11-
pub use lsp_log::{LogStore, LspLogToolbarItemView, LspLogView};
11+
pub use lsp_log_view::LspLogView;
1212
pub use syntax_tree_view::{SyntaxTreeToolbarItemView, SyntaxTreeView};
1313
use ui::{Context, Window};
1414
use workspace::{Item, ItemHandle, SplitDirection, Workspace};
1515

1616
pub fn init(cx: &mut App) {
17-
lsp_log::init(cx);
17+
lsp_log_view::init(true, cx);
1818
syntax_tree_view::init(cx);
1919
key_context_view::init(cx);
2020
}

0 commit comments

Comments
 (0)