Skip to main content

oak_cmd/lsp/
mod.rs

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