1#![doc = include_str!("readme.md")]
2use crate::language::CmdLanguage;
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
8#[cfg(feature = "lsp")]
9pub struct CmdLanguageService<V: Vfs> {
11 vfs: V,
12 workspace: oak_lsp::workspace::WorkspaceManager,
13}
14
15#[cfg(feature = "lsp")]
16impl<V: Vfs> CmdLanguageService<V> {
17 pub fn new(vfs: V) -> Self {
19 Self { vfs, workspace: oak_lsp::workspace::WorkspaceManager::new() }
20 }
21}
22
23#[cfg(feature = "lsp")]
24impl<V: Vfs + Send + Sync + 'static + oak_vfs::WritableVfs> LanguageService for CmdLanguageService<V> {
25 type Lang = CmdLanguage;
26 type Vfs = V;
27
28 fn vfs(&self) -> &Self::Vfs {
29 &self.vfs
30 }
31
32 fn workspace(&self) -> &oak_lsp::workspace::WorkspaceManager {
33 &self.workspace
34 }
35
36 fn get_root(&self, _uri: &str) -> impl Future<Output = Option<RedNode<'_, CmdLanguage>>> + Send + '_ {
37 async move { None }
38 }
39
40 fn hover(&self, _uri: &str, _range: Range<usize>) -> impl Future<Output = Option<LspHover>> + Send + '_ {
41 async move { None }
42 }
43}