Skip to main content

oak_liquid/lsp/
mod.rs

1/// LSP module for Liquid
2///
3/// This module provides LSP (Language Server Protocol) support for Liquid templates.
4
5#[cfg(feature = "oak-highlight")]
6pub mod highlighter;
7
8#[cfg(feature = "lsp")]
9use {oak_lsp::LanguageService, oak_vfs::MemoryVfs};
10
11#[cfg(feature = "oak-pretty-print")]
12pub mod formatter;
13
14use crate::language::LiquidLanguage;
15
16/// Liquid language service.
17#[cfg(feature = "lsp")]
18pub struct LiquidLanguageService {
19    vfs: MemoryVfs,
20    workspace: oak_lsp::workspace::WorkspaceManager,
21}
22
23#[cfg(feature = "lsp")]
24impl LiquidLanguageService {
25    /// Creates a new language service.
26    pub fn new(vfs: MemoryVfs) -> Self {
27        Self { vfs, workspace: oak_lsp::workspace::WorkspaceManager::default() }
28    }
29}
30
31#[cfg(feature = "lsp")]
32impl LanguageService for LiquidLanguageService {
33    type Lang = LiquidLanguage;
34    type Vfs = MemoryVfs;
35
36    fn vfs(&self) -> &Self::Vfs {
37        &self.vfs
38    }
39
40    fn workspace(&self) -> &oak_lsp::workspace::WorkspaceManager {
41        &self.workspace
42    }
43
44    fn get_root(&self, _uri: &str) -> impl std::future::Future<Output = Option<oak_core::tree::RedNode<'_, LiquidLanguage>>> + Send + '_ {
45        async move { None }
46    }
47}