From 4f0fa21c04db0aa61074732bce1789c2c7e3955e Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 17 Aug 2023 15:02:33 +0300 Subject: [PATCH] Provide more data to tailwind langserver Tailwind needs user languages and language-to-language-id mappings to start providing completions for those languages. And also it has emmet completions disabled by default, enable them. --- crates/zed/src/languages/tailwind.rs | 35 +++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/crates/zed/src/languages/tailwind.rs b/crates/zed/src/languages/tailwind.rs index 79f65eb5788ecda20dcb890e0ba9d6bb830c2188..0290bf33342d9bb7e649301934fd7f5b724c90ba 100644 --- a/crates/zed/src/languages/tailwind.rs +++ b/crates/zed/src/languages/tailwind.rs @@ -1,10 +1,15 @@ use anyhow::{anyhow, Result}; use async_trait::async_trait; -use futures::StreamExt; +use collections::HashMap; +use futures::{ + future::{self, BoxFuture}, + FutureExt, StreamExt, +}; +use gpui::AppContext; use language::{LanguageServerName, LspAdapter, LspAdapterDelegate}; use lsp::LanguageServerBinary; use node_runtime::NodeRuntime; -use serde_json::json; +use serde_json::{json, Value}; use smol::fs; use std::{ any::Any, @@ -89,9 +94,33 @@ impl LspAdapter for TailwindLspAdapter { async fn initialization_options(&self) -> Option { Some(json!({ - "provideFormatter": true + "provideFormatter": true, + "userLanguages": { + "html": "html", + "css": "css", + "javascript": "javascript", + }, })) } + + fn workspace_configuration(&self, _: &mut AppContext) -> Option> { + Some( + future::ready(json!({ + "tailwindCSS": { + "emmetCompletions": true, + } + })) + .boxed(), + ) + } + + async fn language_ids(&self) -> HashMap { + HashMap::from([ + ("HTML".to_string(), "html".to_string()), + ("CSS".to_string(), "css".to_string()), + ("JavaScript".to_string(), "javascript".to_string()), + ]) + } } async fn get_cached_server_binary(