Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Send lsp_types::InitializeParams with Zed version (#7216)
Kirill Bulatov944a1f8fb0f1
diff --git a/Cargo.lock b/Cargo.lockindex 14affc3281c..ed428585bfb 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -2425,6 +2425,7 @@ dependencies = ["postage","project","rand 0.8.5",+ "release_channel","rich_text","rpc","schemars",@@ -4021,6 +4022,7 @@ dependencies = ["language","lsp","project",+ "release_channel","serde","serde_json","settings",@@ -4265,6 +4267,7 @@ dependencies = ["lsp-types","parking_lot 0.11.2","postage",+ "release_channel","serde","serde_derive","serde_json",@@ -5819,6 +5822,7 @@ dependencies = ["pretty_assertions","rand 0.8.5","regex",+ "release_channel","rpc","schemars","serde",@@ -5883,6 +5887,7 @@ dependencies = ["picker","postage","project",+ "release_channel","serde_json","settings","smol",@@ -9443,6 +9448,7 @@ dependencies = ["parking_lot 0.11.2","project","regex",+ "release_channel","search","serde","serde_derive",diff --git a/crates/copilot/src/copilot.rs b/crates/copilot/src/copilot.rsindex 16f941d16f7..d4d7539a05c 100644--- a/crates/copilot/src/copilot.rs+++ b/crates/copilot/src/copilot.rs@@ -445,7 +445,7 @@ impl Copilot {).detach();- let server = server.initialize(Default::default()).await?;+ let server = cx.update(|cx| server.initialize(None, cx))?.await?;let status = server.request::<request::CheckStatus>(request::CheckStatusParams {diff --git a/crates/editor/Cargo.toml b/crates/editor/Cargo.tomlindex b5067afbf24..3e6b4d709c1 100644--- a/crates/editor/Cargo.toml+++ b/crates/editor/Cargo.toml@@ -79,6 +79,7 @@ language = { path = "../language", features = ["test-support"] }lsp = { path = "../lsp", features = ["test-support"] }multi_buffer = { path = "../multi_buffer", features = ["test-support"] }project = { path = "../project", features = ["test-support"] }+release_channel = { path = "../release_channel" }rand.workspace = truesettings = { path = "../settings", features = ["test-support"] }text = { path = "../text", features = ["test-support"] }diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rsindex 297ee0770bf..6b23e13d15b 100644--- a/crates/editor/src/editor_tests.rs+++ b/crates/editor/src/editor_tests.rs@@ -8392,6 +8392,7 @@ pub(crate) fn init_test(cx: &mut TestAppContext, f: fn(&mut AllLanguageSettingsClet store = SettingsStore::test(cx);cx.set_global(store);theme::init(theme::LoadThemes::JustBase, cx);+ release_channel::init("0.0.0", cx);client::init_settings(cx);language::init(cx);Project::init_settings(cx);diff --git a/crates/editor/src/inlay_hint_cache.rs b/crates/editor/src/inlay_hint_cache.rsindex 71e039a843f..ae5a0ef9a31 100644--- a/crates/editor/src/inlay_hint_cache.rs+++ b/crates/editor/src/inlay_hint_cache.rs@@ -3216,6 +3216,7 @@ pub mod tests {let settings_store = SettingsStore::test(cx);cx.set_global(settings_store);theme::init(theme::LoadThemes::JustBase, cx);+ release_channel::init("0.0.0", cx);client::init_settings(cx);language::init(cx);Project::init_settings(cx);diff --git a/crates/language_tools/Cargo.toml b/crates/language_tools/Cargo.tomlindex d32677fd6e9..769509aa6bf 100644--- a/crates/language_tools/Cargo.toml+++ b/crates/language_tools/Cargo.toml@@ -30,6 +30,7 @@ workspace = { path = "../workspace" }[dev-dependencies]client = { path = "../client", features = ["test-support"] }editor = { path = "../editor", features = ["test-support"] }+release_channel = { path = "../release_channel" }env_logger.workspace = truegpui = { path = "../gpui", features = ["test-support"] }unindent.workspace = truediff --git a/crates/language_tools/src/lsp_log_tests.rs b/crates/language_tools/src/lsp_log_tests.rsindex 14683ae8069..24b23df8803 100644--- a/crates/language_tools/src/lsp_log_tests.rs+++ b/crates/language_tools/src/lsp_log_tests.rs@@ -100,6 +100,7 @@ fn init_test(cx: &mut gpui::TestAppContext) {let settings_store = SettingsStore::test(cx);cx.set_global(settings_store);theme::init(theme::LoadThemes::JustBase, cx);+ release_channel::init("0.0.0", cx);language::init(cx);client::init_settings(cx);Project::init_settings(cx);diff --git a/crates/lsp/Cargo.toml b/crates/lsp/Cargo.tomlindex f43c8a4bd88..c1fdd7b1076 100644--- a/crates/lsp/Cargo.toml+++ b/crates/lsp/Cargo.toml@@ -27,6 +27,7 @@ serde_derive.workspace = trueserde_json.workspace = truesmol.workspace = trueutil = { path = "../util" }+release_channel = { path = "../release_channel" }[dev-dependencies]async-pipe = { git = "https://github.com/zed-industries/async-pipe-rs", rev = "82d00a04211cf4e1236029aa03e6b6ce2a74c553" }diff --git a/crates/lsp/src/lsp.rs b/crates/lsp/src/lsp.rsindex 65da2bc7dcd..0d88e1507c7 100644--- a/crates/lsp/src/lsp.rs+++ b/crates/lsp/src/lsp.rs@@ -5,7 +5,7 @@ pub use lsp_types::*;use anyhow::{anyhow, Context, Result};use collections::HashMap;use futures::{channel::oneshot, io::BufWriter, AsyncRead, AsyncWrite, FutureExt};-use gpui::{AsyncAppContext, BackgroundExecutor, Task};+use gpui::{AppContext, AsyncAppContext, BackgroundExecutor, Task};use parking_lot::Mutex;use postage::{barrier, prelude::Stream};use serde::{de::DeserializeOwned, Deserialize, Serialize};@@ -450,7 +450,11 @@ impl LanguageServer {/// Note that `options` is used directly to construct [`InitializeParams`], which is why it is owned.////// [LSP Specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#initialize)- pub async fn initialize(mut self, options: Option<Value>) -> Result<Arc<Self>> {+ pub fn initialize(+ mut self,+ options: Option<Value>,+ cx: &AppContext,+ ) -> Task<Result<Arc<Self>>> {let root_uri = Url::from_file_path(&self.root_path).unwrap();#[allow(deprecated)]let params = InitializeParams {@@ -579,18 +583,25 @@ impl LanguageServer {uri: root_uri,name: Default::default(),}]),- client_info: None,+ client_info: Some(ClientInfo {+ name: release_channel::ReleaseChannel::global(cx)+ .display_name()+ .to_string(),+ version: Some(release_channel::AppVersion::global(cx).to_string()),+ }),locale: None,};- let response = self.request::<request::Initialize>(params).await?;- if let Some(info) = response.server_info {- self.name = info.name;- }- self.capabilities = response.capabilities;+ cx.spawn(|_| async move {+ let response = self.request::<request::Initialize>(params).await?;+ if let Some(info) = response.server_info {+ self.name = info.name;+ }+ self.capabilities = response.capabilities;- self.notify::<notification::Initialized>(InitializedParams {})?;- Ok(Arc::new(self))+ self.notify::<notification::Initialized>(InitializedParams {})?;+ Ok(Arc::new(self))+ })}/// Sends a shutdown request to the language server process and prepares the [`LanguageServer`] to be dropped.@@ -1213,6 +1224,9 @@ mod tests {#[gpui::test]async fn test_fake(cx: &mut TestAppContext) {+ cx.update(|cx| {+ release_channel::init("0.0.0", cx);+ });let (server, mut fake) =FakeLanguageServer::new("the-lsp".to_string(), Default::default(), cx.to_async());@@ -1229,7 +1243,7 @@ mod tests {}).detach();- let server = server.initialize(None).await.unwrap();+ let server = cx.update(|cx| server.initialize(None, cx)).await.unwrap();server.notify::<notification::DidOpenTextDocument>(DidOpenTextDocumentParams {text_document: TextDocumentItem::new(diff --git a/crates/prettier/src/prettier.rs b/crates/prettier/src/prettier.rsindex 61bcf9c9b35..b029aefb70a 100644--- a/crates/prettier/src/prettier.rs+++ b/crates/prettier/src/prettier.rs@@ -195,11 +195,11 @@ impl Prettier {},Path::new("/"),None,- cx,+ cx.clone(),).context("prettier server creation")?;- let server = executor- .spawn(server.initialize(None))+ let server = cx+ .update(|cx| executor.spawn(server.initialize(None, cx)))?.await.context("prettier server initialization")?;Ok(Self::Real(RealPrettier {diff --git a/crates/project/Cargo.toml b/crates/project/Cargo.tomlindex 78e9625afb4..1854feb8fe4 100644--- a/crates/project/Cargo.toml+++ b/crates/project/Cargo.toml@@ -75,6 +75,7 @@ fs = { path = "../fs", features = ["test-support"] }git2.workspace = truegpui = { path = "../gpui", features = ["test-support"] }language = { path = "../language", features = ["test-support"] }+release_channel = { path = "../release_channel" }lsp = { path = "../lsp", features = ["test-support"] }prettier = { path = "../prettier", features = ["test-support"] }pretty_assertions.workspace = truediff --git a/crates/project/src/project.rs b/crates/project/src/project.rsindex fdd273059bb..0788594222d 100644--- a/crates/project/src/project.rs+++ b/crates/project/src/project.rs@@ -3130,7 +3130,9 @@ impl Project {(None, override_options) => initialization_options = override_options,_ => {}}- let language_server = language_server.initialize(initialization_options).await?;+ let language_server = cx+ .update(|cx| language_server.initialize(initialization_options, cx))?+ .await?;language_server.notify::<lsp::notification::DidChangeConfiguration>(diff --git a/crates/project/src/project_tests.rs b/crates/project/src/project_tests.rsindex e90d3237127..2e222c24fb2 100644--- a/crates/project/src/project_tests.rs+++ b/crates/project/src/project_tests.rs@@ -4380,6 +4380,7 @@ fn init_test(cx: &mut gpui::TestAppContext) {cx.update(|cx| {let settings_store = SettingsStore::test(cx);cx.set_global(settings_store);+ release_channel::init("0.0.0", cx);language::init(cx);Project::init_settings(cx);});diff --git a/crates/project_symbols/Cargo.toml b/crates/project_symbols/Cargo.tomlindex 27d36ea99af..2b3027a0894 100644--- a/crates/project_symbols/Cargo.toml+++ b/crates/project_symbols/Cargo.toml@@ -33,6 +33,7 @@ gpui = { path = "../gpui", features = ["test-support"] }language = { path = "../language", features = ["test-support"] }lsp = { path = "../lsp", features = ["test-support"] }project = { path = "../project", features = ["test-support"] }+release_channel = { path = "../release_channel" }settings = { path = "../settings", features = ["test-support"] }theme = { path = "../theme", features = ["test-support"] }workspace = { path = "../workspace", features = ["test-support"] }diff --git a/crates/project_symbols/src/project_symbols.rs b/crates/project_symbols/src/project_symbols.rsindex 3d3e2328954..8aa7fac3594 100644--- a/crates/project_symbols/src/project_symbols.rs+++ b/crates/project_symbols/src/project_symbols.rs@@ -392,6 +392,7 @@ mod tests {let store = SettingsStore::test(cx);cx.set_global(store);theme::init(theme::LoadThemes::JustBase, cx);+ release_channel::init("0.0.0", cx);language::init(cx);Project::init_settings(cx);workspace::init_settings(cx);diff --git a/crates/vim/Cargo.toml b/crates/vim/Cargo.tomlindex c5b6ec07325..84151118496 100644--- a/crates/vim/Cargo.toml+++ b/crates/vim/Cargo.toml@@ -43,6 +43,7 @@ zed_actions = { path = "../zed_actions" }editor = { path = "../editor", features = ["test-support"] }futures.workspace = truegpui = { path = "../gpui", features = ["test-support"] }+release_channel = { path = "../release_channel" }indoc.workspace = truelanguage = { path = "../language", features = ["test-support"] }lsp = { path = "../lsp", features = ["test-support"] }diff --git a/crates/vim/src/test/vim_test_context.rs b/crates/vim/src/test/vim_test_context.rsindex 0e41f5a0368..70334d70d49 100644--- a/crates/vim/src/test/vim_test_context.rs+++ b/crates/vim/src/test/vim_test_context.rs@@ -23,6 +23,7 @@ impl VimTestContext {search::init(cx);let settings = SettingsStore::test(cx);cx.set_global(settings);+ release_channel::init("0.0.0", cx);command_palette::init(cx);crate::init(cx);});