Remove the async modifier from the workspace_configuration method

This commit is contained in:
Kirill Bulatov 2024-01-23 11:58:17 +02:00
parent 351914f4bd
commit ab8585ee7e
6 changed files with 31 additions and 63 deletions

View file

@ -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<String, String> {

View file

@ -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<String, String> {

View file

@ -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 {

View file

@ -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<LanguageServerBinary> {
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()
})
}
}