Skip to main content

oak_xml/lsp/
mod.rs

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