1#![doc = include_str!("readme.md")]
2use crate::CssLanguage;
3use oak_core::tree::RedNode;
4#[cfg(feature = "oak-highlight")]
6pub mod highlighter;
7
8#[cfg(feature = "lsp")]
9use {oak_lsp::service::LanguageService, oak_vfs::Vfs, std::future::Future};
10#[cfg(feature = "lsp")]
13#[cfg(feature = "oak-pretty-print")]
14pub mod formatter;
15#[cfg(feature = "lsp")]
17pub struct CssLanguageService<V: Vfs> {
18 vfs: V,
19 workspace: oak_lsp::workspace::WorkspaceManager,
20}
21#[cfg(feature = "lsp")]
22impl<V: Vfs> CssLanguageService<V> {
23 pub fn new(vfs: V) -> Self {
25 Self { vfs, workspace: oak_lsp::workspace::WorkspaceManager::default() }
26 }
27}
28#[cfg(feature = "lsp")]
29impl<V: Vfs + Send + Sync + 'static + oak_vfs::WritableVfs> LanguageService for CssLanguageService<V> {
30 type Lang = CssLanguage;
31 type Vfs = V;
32 fn vfs(&self) -> &Self::Vfs {
33 &self.vfs
34 }
35 fn workspace(&self) -> &oak_lsp::workspace::WorkspaceManager {
36 &self.workspace
37 }
38 fn get_root(&self, uri: &str) -> impl Future<Output = Option<RedNode<'_, CssLanguage>>> + Send + '_ {
39 let source = self.vfs().get_source(uri);
40 async move {
41 let _source = source?;
42 None
44 }
45 }
46}