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.
This commit is contained in:
Kirill Bulatov 2023-08-17 15:02:33 +03:00
parent e54f16f372
commit 4f0fa21c04

View file

@ -1,10 +1,15 @@
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use async_trait::async_trait; 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 language::{LanguageServerName, LspAdapter, LspAdapterDelegate};
use lsp::LanguageServerBinary; use lsp::LanguageServerBinary;
use node_runtime::NodeRuntime; use node_runtime::NodeRuntime;
use serde_json::json; use serde_json::{json, Value};
use smol::fs; use smol::fs;
use std::{ use std::{
any::Any, any::Any,
@ -89,9 +94,33 @@ impl LspAdapter for TailwindLspAdapter {
async fn initialization_options(&self) -> Option<serde_json::Value> { async fn initialization_options(&self) -> Option<serde_json::Value> {
Some(json!({ Some(json!({
"provideFormatter": true "provideFormatter": true,
"userLanguages": {
"html": "html",
"css": "css",
"javascript": "javascript",
},
})) }))
} }
fn workspace_configuration(&self, _: &mut AppContext) -> Option<BoxFuture<'static, Value>> {
Some(
future::ready(json!({
"tailwindCSS": {
"emmetCompletions": true,
}
}))
.boxed(),
)
}
async fn language_ids(&self) -> HashMap<String, String> {
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( async fn get_cached_server_binary(