Skip to main content

oak_go/
lsp.rs

1//! Go 语言 LSP 服务
2
3use crate::language::GoLanguage;
4use oak_core::tree::RedNode;
5use oak_lsp::LanguageService;
6use oak_vfs::MemoryVfs;
7use std::future::Future;
8
9/// Go 语言服务
10pub struct GoLanguageService {
11    vfs: MemoryVfs,
12    workspace: oak_lsp::workspace::WorkspaceManager,
13}
14
15impl GoLanguageService {
16    /// 创建一个新的 GoLanguageService
17    pub fn new(vfs: MemoryVfs) -> Self {
18        Self { vfs, workspace: oak_lsp::workspace::WorkspaceManager::default() }
19    }
20}
21
22impl LanguageService for GoLanguageService {
23    type Lang = GoLanguage;
24    type Vfs = MemoryVfs;
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<'_, Self::Lang>>> + Send + '_ {
35        async { None }
36    }
37}