lsp_adapter.rs

 1use gpui::SharedString;
 2use serde::{Deserialize, Serialize};
 3
 4/// Converts a value into an LSP position.
 5pub trait ToLspPosition {
 6    /// Converts the value into an LSP position.
 7    fn to_lsp_position(self) -> lsp::Position;
 8}
 9
10/// Context provided to LSP adapters when a user responds to a ShowMessageRequest prompt.
11/// This allows adapters to intercept preference selections (like "Always" or "Never")
12/// and potentially persist them to Zed's settings.
13#[derive(Debug, Clone)]
14pub struct PromptResponseContext {
15    /// The original message shown to the user
16    pub message: String,
17    /// The action (button) the user selected
18    pub selected_action: lsp::MessageActionItem,
19}
20
21#[derive(Clone, Debug, PartialEq, Eq)]
22pub enum LanguageServerStatusUpdate {
23    Binary(BinaryStatus),
24    Health(ServerHealth, Option<SharedString>),
25}
26
27#[derive(Debug, PartialEq, Eq, Deserialize, Serialize, Clone, Copy)]
28#[serde(rename_all = "camelCase")]
29pub enum ServerHealth {
30    Ok,
31    Warning,
32    Error,
33}
34
35#[derive(Clone, Debug, PartialEq, Eq)]
36pub enum BinaryStatus {
37    None,
38    CheckingForUpdate,
39    Downloading,
40    Starting,
41    Stopping,
42    Stopped,
43    Failed { error: String },
44}