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")]
13/// Delphi language service implementation.
14pub struct DelphiLanguageService<V: Vfs> {
15    vfs: V,
16    workspace: oak_lsp::workspace::WorkspaceManager,
17}
18impl<V: Vfs> DelphiLanguageService<V> {
19    /// Creates a new `DelphiLanguageService`.
20    pub fn new(vfs: V) -> Self {
21        Self { vfs, workspace: oak_lsp::workspace::WorkspaceManager::new() }
22    }
23}
24impl<V: Vfs + Send + Sync + 'static + oak_vfs::WritableVfs> LanguageService for DelphiLanguageService<V> {
25    type Lang = DelphiLanguage;
26    type Vfs = V;
27    fn vfs(&self) -> &Self::Vfs {
28        &self.vfs
29    }
30    fn workspace(&self) -> &oak_lsp::workspace::WorkspaceManager {
31        &self.workspace
32    }
33    fn get_root(&self, _uri: &str) -> impl Future<Output = Option<RedNode<'_, DelphiLanguage>>> + Send + '_ {
34        async move { None }
35    }
36    fn hover(&self, _uri: &str, _range: Range<usize>) -> impl Future<Output = Option<LspHover>> + Send + '_ {
37        async move { None }
38    }
39}