oak-wolfram 0.0.11

Wolfram Language parser with support for Mathematica syntax and symbolic computation.
Documentation
#![doc = include_str!("readme.md")]

/// Wolfram syntax highlighter.
pub mod highlighter;

use crate::language::WolframLanguage;
use core::range::Range;
use oak_core::tree::RedNode;
#[cfg(feature = "lsp")]
use {futures::Future, oak_lsp::service::LanguageService, oak_lsp::types::Hover as LspHover, oak_vfs::Vfs};

/// Language service for Wolfram.
#[cfg(feature = "lsp")]
pub struct WolframLanguageService<V: Vfs> {
    /// The virtual file system.
    vfs: V,
    /// The workspace manager for managing document state.
    workspace: oak_lsp::workspace::WorkspaceManager,
}

impl<V: Vfs> WolframLanguageService<V> {
    /// Creates a new `WolframLanguageService`.
    pub fn new(vfs: V) -> Self {
        Self { vfs, workspace: oak_lsp::workspace::WorkspaceManager::new() }
    }
}
impl<V: Vfs + Send + Sync + 'static + oak_vfs::WritableVfs> LanguageService for WolframLanguageService<V> {
    type Lang = WolframLanguage;
    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<'_, WolframLanguage>>> + Send + '_ {
        async move { None }
    }
    fn hover(&self, _uri: &str, _range: Range<usize>) -> impl Future<Output = Option<LspHover>> + Send + '_ {
        async move { None }
    }
}