diff --git a/crates/languages/src/tailwind.rs b/crates/languages/src/tailwind.rs index f872b5a56a219bf0895c5ce85e14627876c13001..ab93ed74a3ae2b3d9132a294c82138fa5f432da1 100644 --- a/crates/languages/src/tailwind.rs +++ b/crates/languages/src/tailwind.rs @@ -158,26 +158,25 @@ impl LspAdapter for TailwindLspAdapter { .unwrap_or_default() })?; - // We need to set this to null if it's not set, because tailwindcss-languageserver - // will check whether it's an object and if it is (even if it's empty) it will - // ignore the `userLanguages` from the initialization options. - let include_languages = tailwind_user_settings - .get("includeLanguages") - .cloned() - .unwrap_or(Value::Null); - - let experimental = tailwind_user_settings - .get("experimental") - .cloned() - .unwrap_or_else(|| json!([])); - - Ok(json!({ + let mut configuration = json!({ "tailwindCSS": { "emmetCompletions": true, - "includeLanguages": include_languages, - "experimental": experimental, } - })) + }); + + if let Some(experimental) = tailwind_user_settings.get("experimental").cloned() { + configuration["tailwindCSS"]["experimental"] = experimental; + } + + if let Some(class_attributes) = tailwind_user_settings.get("classAttributes").cloned() { + configuration["tailwindCSS"]["classAttributes"] = class_attributes; + } + + if let Some(include_languages) = tailwind_user_settings.get("includeLanguages").cloned() { + configuration["tailwindCSS"]["includeLanguages"] = include_languages; + } + + Ok(configuration) } fn language_ids(&self) -> HashMap {