Provide `editor.tabSize` in workspace configuration for YAML

Antonio Scandurra created

This fixes a bug that caused the hover popover to display lots of
` ` occurrences.

Change summary

crates/zed/src/languages/yaml.rs | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)

Detailed changes

crates/zed/src/languages/yaml.rs 🔗

@@ -1,12 +1,13 @@
-use std::{any::Any, path::PathBuf, sync::Arc};
-
 use anyhow::{anyhow, Context, Result};
 use async_trait::async_trait;
 use client::http::HttpClient;
-use futures::StreamExt;
-use smol::fs;
-
+use futures::{future::BoxFuture, FutureExt, StreamExt};
+use gpui::MutableAppContext;
 use language::{LanguageServerName, LspAdapter};
+use serde_json::Value;
+use settings::Settings;
+use smol::fs;
+use std::{any::Any, future, path::PathBuf, sync::Arc};
 use util::ResultExt;
 
 use super::installation::{npm_install_packages, npm_package_latest_version};
@@ -90,4 +91,19 @@ impl LspAdapter for YamlLspAdapter {
         .await
         .log_err()
     }
+
+    fn workspace_configuration(
+        &self,
+        cx: &mut MutableAppContext,
+    ) -> Option<BoxFuture<'static, Value>> {
+        let settings = cx.global::<Settings>();
+        Some(
+            future::ready(serde_json::json!({
+                "[yaml]": {
+                    "editor.tabSize": settings.tab_size(Some("YAML"))
+                }
+            }))
+            .boxed(),
+        )
+    }
 }