Skip to main content

oak_delphi/lsp/
mod.rs

1#![doc = include_str!("readme.md")]
2#[cfg(feature = "oak-highlight")]
3pub mod highlighter;
4
5#[cfg(feature = "lsp")]
6use {futures::Future, oak_lsp::service::LanguageService, oak_lsp::types::Hover as LspHover, oak_vfs::Vfs};
7#[cfg(feature = "oak-pretty-print")]
8pub mod formatter;
9use crate::language::DelphiLanguage;
10use core::range::Range;
11use oak_core::tree::RedNode;
12#[cfg(feature = "lsp")]
13pub struct DelphiLanguageService<V: Vfs> {
14    vfs: V,
15    workspace: oak_lsp::workspace::WorkspaceManager,
16}
17impl<V: Vfs> DelphiLanguageService<V> {
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 DelphiLanguageService<V> {
23    type Lang = DelphiLanguage;
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<'_, DelphiLanguage>>> + 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}