From ab8585ee7ec0f69ce40755b71b9deb0b3ba62936 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 23 Jan 2024 11:58:17 +0200 Subject: [PATCH] Remove the `async` modifier from the `workspace_configuration` method --- crates/language/src/language.rs | 12 ++++-------- crates/project/src/project.rs | 21 +++++++++------------ crates/zed/src/languages/json.rs | 10 ++++------ crates/zed/src/languages/tailwind.rs | 16 ++++------------ crates/zed/src/languages/typescript.rs | 13 +++---------- crates/zed/src/languages/yaml.rs | 22 +++++++--------------- 6 files changed, 31 insertions(+), 63 deletions(-) diff --git a/crates/language/src/language.rs b/crates/language/src/language.rs index c7327b63d7..1033198bab 100644 --- a/crates/language/src/language.rs +++ b/crates/language/src/language.rs @@ -23,7 +23,7 @@ use async_trait::async_trait; use collections::{HashMap, HashSet}; use futures::{ channel::{mpsc, oneshot}, - future::{BoxFuture, Shared}, + future::Shared, FutureExt, TryFutureExt as _, }; use gpui::{AppContext, AsyncAppContext, BackgroundExecutor, Task}; @@ -216,11 +216,7 @@ impl CachedLspAdapter { self.adapter.code_action_kinds() } - pub fn workspace_configuration( - &self, - workspace_root: &Path, - cx: &mut AppContext, - ) -> BoxFuture<'static, Value> { + pub fn workspace_configuration(&self, workspace_root: &Path, cx: &mut AppContext) -> Value { self.adapter.workspace_configuration(workspace_root, cx) } @@ -345,8 +341,8 @@ pub trait LspAdapter: 'static + Send + Sync { None } - fn workspace_configuration(&self, _: &Path, _: &mut AppContext) -> BoxFuture<'static, Value> { - futures::future::ready(serde_json::json!({})).boxed() + fn workspace_configuration(&self, _: &Path, _: &mut AppContext) -> Value { + serde_json::json!({}) } /// Returns a list of code actions supported by a given LspAdapter diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 1f5a5a8c64..285d86742b 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -664,7 +664,7 @@ impl Project { next_diagnostic_group_id: Default::default(), supplementary_language_servers: HashMap::default(), language_servers: Default::default(), - language_server_ids: Default::default(), + language_server_ids: HashMap::default(), language_server_statuses: Default::default(), last_workspace_edits_by_language_server: Default::default(), buffers_being_formatted: Default::default(), @@ -752,7 +752,7 @@ impl Project { }, supplementary_language_servers: HashMap::default(), language_servers: Default::default(), - language_server_ids: Default::default(), + language_server_ids: HashMap::default(), language_server_statuses: response .payload .language_servers @@ -2700,7 +2700,7 @@ impl Project { }); cx.spawn(move |this, mut cx| async move { - while let Some(_) = settings_changed_rx.next().await { + while let Some(()) = settings_changed_rx.next().await { let servers: Vec<_> = this.update(&mut cx, |this, _| { this.language_servers .values() @@ -2714,9 +2714,8 @@ impl Project { })?; for (adapter, server) in servers { - let workspace_config = cx - .update(|cx| adapter.workspace_configuration(server.root_path(), cx))? - .await; + let workspace_config = + cx.update(|cx| adapter.workspace_configuration(server.root_path(), cx))?; server .notify::( lsp::DidChangeConfigurationParams { @@ -3020,9 +3019,8 @@ impl Project { server_id: LanguageServerId, cx: &mut AsyncAppContext, ) -> Result> { - let workspace_config = cx - .update(|cx| adapter.workspace_configuration(worktree_path, cx))? - .await; + let workspace_config = + cx.update(|cx| adapter.workspace_configuration(worktree_path, cx))?; let language_server = pending_server.task.await?; language_server @@ -3056,9 +3054,8 @@ impl Project { let adapter = adapter.clone(); let worktree_path = worktree_path.clone(); async move { - let workspace_config = cx - .update(|cx| adapter.workspace_configuration(&worktree_path, cx))? - .await; + let workspace_config = + cx.update(|cx| adapter.workspace_configuration(&worktree_path, cx))?; Ok(params .items .into_iter() diff --git a/crates/zed/src/languages/json.rs b/crates/zed/src/languages/json.rs index 162d4c9fdb..19af72f7c6 100644 --- a/crates/zed/src/languages/json.rs +++ b/crates/zed/src/languages/json.rs @@ -2,7 +2,7 @@ use anyhow::{anyhow, Result}; use async_trait::async_trait; use collections::HashMap; use feature_flags::FeatureFlagAppExt; -use futures::{future::BoxFuture, FutureExt, StreamExt}; +use futures::StreamExt; use gpui::AppContext; use language::{LanguageRegistry, LanguageServerName, LspAdapter, LspAdapterDelegate}; use lsp::LanguageServerBinary; @@ -13,7 +13,6 @@ use smol::fs; use std::{ any::Any, ffi::OsString, - future, path::{Path, PathBuf}, sync::Arc, }; @@ -107,7 +106,7 @@ impl LspAdapter for JsonLspAdapter { &self, _workspace_root: &Path, cx: &mut AppContext, - ) -> BoxFuture<'static, serde_json::Value> { + ) -> serde_json::Value { let action_names = cx.all_action_names(); let staff_mode = cx.is_staff(); let language_names = &self.languages.language_names(); @@ -119,7 +118,7 @@ impl LspAdapter for JsonLspAdapter { cx, ); - future::ready(serde_json::json!({ + serde_json::json!({ "json": { "format": { "enable": true, @@ -138,8 +137,7 @@ impl LspAdapter for JsonLspAdapter { } ] } - })) - .boxed() + }) } async fn language_ids(&self) -> HashMap { diff --git a/crates/zed/src/languages/tailwind.rs b/crates/zed/src/languages/tailwind.rs index 0dfa700b01..5c39ee0efd 100644 --- a/crates/zed/src/languages/tailwind.rs +++ b/crates/zed/src/languages/tailwind.rs @@ -1,10 +1,7 @@ use anyhow::{anyhow, Result}; use async_trait::async_trait; use collections::HashMap; -use futures::{ - future::{self, BoxFuture}, - FutureExt, StreamExt, -}; +use futures::StreamExt; use gpui::AppContext; use language::{LanguageServerName, LspAdapter, LspAdapterDelegate}; use lsp::LanguageServerBinary; @@ -107,17 +104,12 @@ impl LspAdapter for TailwindLspAdapter { })) } - fn workspace_configuration( - &self, - _workspace_root: &Path, - _: &mut AppContext, - ) -> BoxFuture<'static, Value> { - future::ready(json!({ + fn workspace_configuration(&self, _workspace_root: &Path, _: &mut AppContext) -> Value { + json!({ "tailwindCSS": { "emmetCompletions": true, } - })) - .boxed() + }) } async fn language_ids(&self) -> HashMap { diff --git a/crates/zed/src/languages/typescript.rs b/crates/zed/src/languages/typescript.rs index de25f2ead8..133e9095c0 100644 --- a/crates/zed/src/languages/typescript.rs +++ b/crates/zed/src/languages/typescript.rs @@ -3,7 +3,6 @@ use async_compression::futures::bufread::GzipDecoder; use async_tar::Archive; use async_trait::async_trait; use collections::HashMap; -use futures::{future::BoxFuture, FutureExt}; use gpui::AppContext; use language::{LanguageServerName, LspAdapter, LspAdapterDelegate}; use lsp::{CodeActionKind, LanguageServerBinary}; @@ -13,7 +12,6 @@ use smol::{fs, io::BufReader, stream::StreamExt}; use std::{ any::Any, ffi::OsString, - future, path::{Path, PathBuf}, sync::Arc, }; @@ -212,12 +210,8 @@ impl EsLintLspAdapter { #[async_trait] impl LspAdapter for EsLintLspAdapter { - fn workspace_configuration( - &self, - workspace_root: &Path, - _: &mut AppContext, - ) -> BoxFuture<'static, Value> { - future::ready(json!({ + fn workspace_configuration(&self, workspace_root: &Path, _: &mut AppContext) -> Value { + json!({ "": { "validate": "on", "rulesCustomizations": [], @@ -230,8 +224,7 @@ impl LspAdapter for EsLintLspAdapter { .unwrap_or_else(|| workspace_root.as_os_str()), }, } - })) - .boxed() + }) } async fn name(&self) -> LanguageServerName { diff --git a/crates/zed/src/languages/yaml.rs b/crates/zed/src/languages/yaml.rs index fbed9ba78f..6f29f62f8e 100644 --- a/crates/zed/src/languages/yaml.rs +++ b/crates/zed/src/languages/yaml.rs @@ -1,6 +1,6 @@ use anyhow::{anyhow, Result}; use async_trait::async_trait; -use futures::{future::BoxFuture, FutureExt, StreamExt}; +use futures::StreamExt; use gpui::AppContext; use language::{ language_settings::all_language_settings, LanguageServerName, LspAdapter, LspAdapterDelegate, @@ -12,7 +12,6 @@ use smol::fs; use std::{ any::Any, ffi::OsString, - future, path::{Path, PathBuf}, sync::Arc, }; @@ -93,24 +92,17 @@ impl LspAdapter for YamlLspAdapter { ) -> Option { get_cached_server_binary(container_dir, &*self.node).await } - fn workspace_configuration( - &self, - _workspace_root: &Path, - cx: &mut AppContext, - ) -> BoxFuture<'static, Value> { - let tab_size = all_language_settings(None, cx) - .language(Some("YAML")) - .tab_size; - - future::ready(serde_json::json!({ + fn workspace_configuration(&self, _workspace_root: &Path, cx: &mut AppContext) -> Value { + serde_json::json!({ "yaml": { "keyOrdering": false }, "[yaml]": { - "editor.tabSize": tab_size, + "editor.tabSize": all_language_settings(None, cx) + .language(Some("YAML")) + .tab_size, } - })) - .boxed() + }) } }