1use serde::{Deserialize, Serialize};
4use std::collections::HashMap;
5
6#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct LspServerConfig {
9 pub language: String,
11 pub extensions: Vec<String>,
13 pub executable: String,
15 pub args: Vec<String>,
17 pub env: HashMap<String, String>,
19 pub init_options: Option<serde_json::Value>,
21 pub enabled: bool,
23 pub timeout_ms: u64,
25 pub max_restarts: u32,
27 pub idle_timeout_ms: u64,
29 pub output_mapping: Option<OutputMappingConfig>,
31}
32
33#[derive(Debug, Clone, Serialize, Deserialize)]
35pub struct OutputMappingConfig {
36 pub completion: Option<CompletionMappingRules>,
38 pub diagnostics: Option<DiagnosticsMappingRules>,
40 pub hover: Option<HoverMappingRules>,
42 pub custom_transforms: Option<HashMap<String, String>>,
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48pub struct CompletionMappingRules {
49 pub items_path: String,
51 pub field_mappings: HashMap<String, String>,
53 pub transform: Option<String>,
55}
56
57#[derive(Debug, Clone, Serialize, Deserialize)]
59pub struct DiagnosticsMappingRules {
60 pub items_path: String,
62 pub field_mappings: HashMap<String, String>,
64 pub transform: Option<String>,
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
70pub struct HoverMappingRules {
71 pub content_path: String,
73 pub field_mappings: HashMap<String, String>,
75 pub transform: Option<String>,
77}
78
79#[derive(Debug, Clone, Serialize, Deserialize, Default)]
81pub struct LspServerRegistry {
82 pub servers: HashMap<String, Vec<LspServerConfig>>,
84 pub global: GlobalLspSettings,
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90pub struct GlobalLspSettings {
91 pub max_processes: usize,
93 pub default_timeout_ms: u64,
95 pub enable_fallback: bool,
97 pub health_check_interval_ms: u64,
99}
100
101impl Default for GlobalLspSettings {
102 fn default() -> Self {
103 Self {
104 max_processes: 5,
105 default_timeout_ms: 5000,
106 enable_fallback: true,
107 health_check_interval_ms: 30000,
108 }
109 }
110}
111
112
113
114#[derive(Debug, Clone, Copy, PartialEq, Eq)]
116pub enum ClientState {
117 Stopped,
119 Starting,
121 Running,
123 Unhealthy,
125 ShuttingDown,
127 Crashed,
129}
130
131#[derive(Debug, Clone)]
133pub enum HealthStatus {
134 Healthy { latency: std::time::Duration },
136 Unhealthy { reason: String },
138}
139
140#[derive(Debug, Clone)]
142pub enum ResultSource {
143 External { server: String },
145 Internal,
147 Merged { sources: Vec<String> },
149}
150
151pub struct ExternalLspResult<T> {
153 pub data: T,
155 pub source: ResultSource,
157 pub latency: std::time::Duration,
159}
160
161#[derive(Debug, Clone)]
163pub struct MergeConfig {
164 pub include_internal: bool,
166 pub deduplicate: bool,
168}
169
170impl Default for MergeConfig {
171 fn default() -> Self {
172 Self {
173 include_internal: true,
174 deduplicate: true,
175 }
176 }
177}