diff --git a/Cargo.lock b/Cargo.lock index 14affc3281cdf60e56474e861e12c2319af74eb7..ed428585bfb75549a53b348fa569e8a52bb95ea4 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.rs index 16f941d16f7f9ea19bea8a10609f9b394e14da5e..d4d7539a05c680a86c0393d41b85a71d3c5f45f4 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::CheckStatusParams { diff --git a/crates/editor/Cargo.toml b/crates/editor/Cargo.toml index b5067afbf24e00cf3b43771b486190f2395c3d98..3e6b4d709c1dd912d98b864740500b43c860772d 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 = true settings = { 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.rs index 297ee0770bf40dd750917c194a01faac1c65a116..6b23e13d15bb64ba3678234071d2fafb02661bed 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 AllLanguageSettingsC let 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.rs index 71e039a843f49618a65d7ce3f734c92195444228..ae5a0ef9a3115c2f1410c69517a5cdd971b5e62b 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.toml index d32677fd6e9aef5cf1129b3711c548d593f7e80e..769509aa6bfc9300d3ba1dbec75575421d26c4a1 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 = true gpui = { path = "../gpui", features = ["test-support"] } unindent.workspace = true diff --git a/crates/language_tools/src/lsp_log_tests.rs b/crates/language_tools/src/lsp_log_tests.rs index 14683ae8069771b730c4e008c19801b669160154..24b23df88035f68caf9e49c807d56ca463b6e369 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.toml index f43c8a4bd88a0619de7af870857b8687580e8bf7..c1fdd7b10765a54aa9f31bc7a6833bfd95f5af63 100644 --- a/crates/lsp/Cargo.toml +++ b/crates/lsp/Cargo.toml @@ -27,6 +27,7 @@ serde_derive.workspace = true serde_json.workspace = true smol.workspace = true util = { 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.rs index 65da2bc7dcddfb78e2373d5f056e8f1c5aba5389..0d88e1507c7e9c70337a98b05fbb34e26b9acfdd 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) -> Result> { + pub fn initialize( + mut self, + options: Option, + cx: &AppContext, + ) -> Task>> { 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::(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::(params).await?; + if let Some(info) = response.server_info { + self.name = info.name; + } + self.capabilities = response.capabilities; - self.notify::(InitializedParams {})?; - Ok(Arc::new(self)) + self.notify::(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::(DidOpenTextDocumentParams { text_document: TextDocumentItem::new( diff --git a/crates/prettier/src/prettier.rs b/crates/prettier/src/prettier.rs index 61bcf9c9b3520993b09ed6110723fa5a7631b1ca..b029aefb70ad4fa0c5c69dade6e77f2495ae5a4b 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.toml index 78e9625afb40c0e94fe30c4bc6ac92d4f181628c..1854feb8fe4e25cfa76ac22350a0b1accfab0ebb 100644 --- a/crates/project/Cargo.toml +++ b/crates/project/Cargo.toml @@ -75,6 +75,7 @@ fs = { path = "../fs", features = ["test-support"] } git2.workspace = true gpui = { 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 = true diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index fdd273059bbf139f75286b0c01472d4019a56640..0788594222d4662904264473ddaedf4b9db227f3 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::( diff --git a/crates/project/src/project_tests.rs b/crates/project/src/project_tests.rs index e90d3237127efa3b29d75ee110a7bbd27caa6de9..2e222c24fb2976a999c07285dd199c0edc89e1fa 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.toml index 27d36ea99af7e52f5eab86c3a9a63dd20c68063e..2b3027a08942f80e1dc6b83041a224dee2349442 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.rs index 3d3e2328954d628d9c61cef7d0fb2c49f27464cf..8aa7fac3594b48aee782fd8337e13cabeb8a1df2 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.toml index c5b6ec07325112ac6e62cd8ab45ce98ba84c72fa..8415111849632575e6fca51cc62af40383aa470e 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 = true gpui = { path = "../gpui", features = ["test-support"] } +release_channel = { path = "../release_channel" } indoc.workspace = true language = { 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.rs index 0e41f5a03687f2c16cd79e21cb33c6abab6476b5..70334d70d497b0c5e447118e98cd7111a66ff61c 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); });