Skip to main content

oak_dsv/lsp/
mod.rs

1#![doc = include_str!("readme.md")]
2use crate::{Dsv, language::DsvLanguage};
3use core::range::Range;
4use oak_core::tree::RedNode;
5#[cfg(feature = "lsp")]
6use {futures::Future, oak_lsp::service::LanguageService, oak_lsp::types::Hover as LspHover, oak_vfs::Vfs};
7#[cfg(feature = "lsp")]
8/// Language service implementation for DSV.
9pub struct DsvLanguageService<const LANG: DsvLanguage, V: Vfs> {
10    /// The virtual file system.
11    vfs: V,
12    /// The workspace manager.
13    workspace: oak_lsp::workspace::WorkspaceManager,
14}
15impl<const LANG: DsvLanguage, V: Vfs> DsvLanguageService<LANG, V> {
16    /// Creates a new `DsvLanguageService`.
17    pub fn new(vfs: V) -> Self {
18        Self { vfs, workspace: oak_lsp::workspace::WorkspaceManager::new() }
19    }
20}
21impl<const LANG: DsvLanguage, V: Vfs + Send + Sync + 'static + oak_vfs::WritableVfs> LanguageService for DsvLanguageService<LANG, V> {
22    type Lang = Dsv<LANG>;
23    type Vfs = V;
24    fn vfs(&self) -> &Self::Vfs {
25        &self.vfs
26    }
27    fn workspace(&self) -> &oak_lsp::workspace::WorkspaceManager {
28        &self.workspace
29    }
30    fn get_root(&self, _uri: &str) -> impl Future<Output = Option<RedNode<'_, Dsv<LANG>>>> + Send + '_ {
31        async move { None }
32    }
33    fn hover(&self, _uri: &str, _range: Range<usize>) -> impl Future<Output = Option<LspHover>> + Send + '_ {
34        async move { None }
35    }
36}