stynx_code_services/lsp/
mod.rs1use async_trait::async_trait;
2use stynx_code_errors::AppResult;
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct Diagnostic {
7 pub file_path: String,
8 pub line: u32,
9 pub col: u32,
10 pub severity: String,
11 pub message: String,
12}
13
14#[derive(Debug, Clone, Serialize, Deserialize)]
15pub struct HoverInfo {
16 pub contents: String,
17}
18
19#[derive(Debug, Clone, Serialize, Deserialize)]
20pub struct Location {
21 pub file_path: String,
22 pub line: u32,
23 pub col: u32,
24}
25
26#[async_trait]
27pub trait LspService: Send + Sync {
28 async fn start_server(&self, language: &str) -> AppResult<()>;
29 async fn diagnostics(&self, file_path: &str) -> AppResult<Vec<Diagnostic>>;
30 async fn hover(&self, file_path: &str, line: u32, col: u32) -> AppResult<Option<HoverInfo>>;
31 async fn goto_definition(&self, file_path: &str, line: u32, col: u32) -> AppResult<Option<Location>>;
32 async fn references(&self, file_path: &str, line: u32, col: u32) -> AppResult<Vec<Location>>;
33 async fn shutdown(&self) -> AppResult<()>;
34}
35
36pub struct StubLspService;
37
38impl StubLspService {
39 pub fn new() -> Self {
40 Self
41 }
42}
43
44#[async_trait]
45impl LspService for StubLspService {
46 async fn start_server(&self, language: &str) -> AppResult<()> {
47 tracing::warn!(language, "LSP not yet initialized");
48 Ok(())
49 }
50
51 async fn diagnostics(&self, _file_path: &str) -> AppResult<Vec<Diagnostic>> {
52 tracing::warn!("LSP not yet initialized");
53 Ok(Vec::new())
54 }
55
56 async fn hover(&self, _file_path: &str, _line: u32, _col: u32) -> AppResult<Option<HoverInfo>> {
57 tracing::warn!("LSP not yet initialized");
58 Ok(None)
59 }
60
61 async fn goto_definition(&self, _file_path: &str, _line: u32, _col: u32) -> AppResult<Option<Location>> {
62 tracing::warn!("LSP not yet initialized");
63 Ok(None)
64 }
65
66 async fn references(&self, _file_path: &str, _line: u32, _col: u32) -> AppResult<Vec<Location>> {
67 tracing::warn!("LSP not yet initialized");
68 Ok(Vec::new())
69 }
70
71 async fn shutdown(&self) -> AppResult<()> {
72 tracing::warn!("LSP not yet initialized");
73 Ok(())
74 }
75}