1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//! LSP (Language Server Protocol) Integration
//!
//! 提供语言服务器连接状态跟踪,用于 TUI 工具栏显示。
//!
//! # 架构概览
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────┐
//! │ MatrixCode Agent │
//! │ ┌─────────────────────────────────────────────────────┐ │
//! │ │ LSP Manager │ │
//! │ │ ┌──────────────┐ ┌──────────────┐ │ │
//! │ │ │ LspManager │ │ LspServerInfo│ │ │
//! │ │ │ (manager.rs) │ │ (types.rs) │ │ │
//! │ │ └──────────────┘ └──────────────┘ │ │
//! │ └─────────────────────────────────────────────────────┘ │
//! └─────────────────────────────────────────────────────────────┘
//! │
//! ┌───────────────────────────────────────────│─────────────────┐
//! │ Language Servers │ │
//! │ ┌─────────────┐ ┌─────────────┐ ┌───────┴───┐ │
//! │ │ rust-analyzer│ │ typescript │ │ python │ │
//! │ │ LSP Server │ │ LSP Server │ │ LSP │ │
//! │ └─────────────┘ └─────────────┘ └───────────┘ │
//! └─────────────────────────────────────────────────────────────┘
//! ```
//!
//! # 状态颜色
//!
//! - 灰色 (DarkGray):未配置或未启动
//! - 绿色 (Green):已连接,正常工作
//! - 红色 (Red):连接错误
//!
//! # 使用示例
//!
//! ```ignore
//! use matrixcode_core::lsp::{LspManager, LspServerInfo, LspServerStatus};
//!
//! // 创建管理器
//! let manager = LspManager::new();
//!
//! // 添加服务器配置
//! manager.add_server(LspServerConfig::new("rust-analyzer", "rust"));
//!
//! // 获取状态列表(用于 TUI 显示)
//! let infos = manager.server_infos().await;
//! for info in infos {
//! println!("{}: {}", info.name, info.status.label());
//! }
//! ```
// Re-export main types
pub use ;
pub use ;
// ============================================================================
// Dynamic Injection Helpers (for Prompt System)
// ============================================================================
/// Check if LSP context should be injected into system prompt
///
/// Returns true if any server is connected and working properly.
/// This is used by the prompt system to conditionally inject LSP-related guidance.
/// Get active (connected) LSP servers
///
/// Filters servers to only those with Connected status.