#![doc = include_str!("readme.md")]
use crate::CssLanguage;
use oak_core::tree::RedNode;
#[cfg(feature = "oak-highlight")]
pub mod highlighter;
#[cfg(feature = "lsp")]
use {oak_lsp::service::LanguageService, oak_vfs::Vfs, std::future::Future};
#[cfg(feature = "lsp")]
#[cfg(feature = "oak-pretty-print")]
pub mod formatter;
#[cfg(feature = "lsp")]
pub struct CssLanguageService<V: Vfs> {
vfs: V,
workspace: oak_lsp::workspace::WorkspaceManager,
}
#[cfg(feature = "lsp")]
impl<V: Vfs> CssLanguageService<V> {
pub fn new(vfs: V) -> Self {
Self { vfs, workspace: oak_lsp::workspace::WorkspaceManager::default() }
}
}
#[cfg(feature = "lsp")]
impl<V: Vfs + Send + Sync + 'static + oak_vfs::WritableVfs> LanguageService for CssLanguageService<V> {
type Lang = CssLanguage;
type Vfs = V;
fn vfs(&self) -> &Self::Vfs {
&self.vfs
}
fn workspace(&self) -> &oak_lsp::workspace::WorkspaceManager {
&self.workspace
}
fn get_root(&self, uri: &str) -> impl Future<Output = Option<RedNode<'_, CssLanguage>>> + Send + '_ {
let source = self.vfs().get_source(uri);
async move {
let _source = source?;
None
}
}
}