Skip to main content

oak_tailwind/lsp/
mod.rs

1#![doc = include_str!("readme.md")]
2#[cfg(feature = "oak-pretty-print")]
3pub mod formatter;
4#[cfg(feature = "oak-highlight")]
5pub mod highlighter;
6
7use crate::language::TailwindLanguage;
8
9#[cfg(feature = "lsp")]
10use {oak_lsp::LanguageService, oak_vfs::MemoryVfs};
11
12#[cfg(feature = "lsp")]
13/// Language service implementation for Tailwind CSS.
14#[cfg(feature = "lsp")]
15pub struct TailwindLanguageService {
16    vfs: MemoryVfs,
17    workspace: oak_lsp::workspace::WorkspaceManager,
18}
19
20#[cfg(feature = "lsp")]
21impl TailwindLanguageService {
22    /// Creates a new `TailwindLanguageService` with the given VFS.
23    pub fn new(vfs: MemoryVfs) -> Self {
24        Self { vfs, workspace: oak_lsp::workspace::WorkspaceManager::default() }
25    }
26}
27
28#[cfg(feature = "lsp")]
29impl LanguageService for TailwindLanguageService {
30    type Lang = TailwindLanguage;
31    type Vfs = MemoryVfs;
32
33    fn vfs(&self) -> &Self::Vfs {
34        &self.vfs
35    }
36
37    fn workspace(&self) -> &oak_lsp::workspace::WorkspaceManager {
38        &self.workspace
39    }
40
41    fn get_root(&self, _uri: &str) -> impl std::future::Future<Output = Option<oak_core::tree::RedNode<'_, TailwindLanguage>>> + Send + '_ {
42        async move { None }
43    }
44
45    fn completion(&self, _uri: &str, _offset: usize) -> impl std::future::Future<Output = Vec<oak_lsp::types::CompletionItem>> + Send + '_ {
46        async move { vec![] }
47    }
48}