use std::path::PathBuf;
use std::sync::Arc;
use crate::BufferId;
#[derive(Debug, Clone)]
pub struct TextChange {
pub start_line: u32,
pub start_col: u32,
pub end_line: u32,
pub end_col: u32,
pub text: String,
}
#[derive(Clone, Eq, Hash, PartialEq, Debug)]
pub struct ServerKey {
pub language: String,
pub root: PathBuf,
}
#[derive(Debug)]
pub enum LspCommand {
AttachBuffer {
id: BufferId,
path: PathBuf,
language_id: String,
text: String,
},
DetachBuffer { id: BufferId },
NotifyChange {
id: BufferId,
full_text: Arc<String>,
},
NotifyChangeIncremental {
id: BufferId,
changes: Vec<TextChange>,
},
NotifySave { id: BufferId },
Cancel { request_id: i64 },
Request {
request_id: i64,
buffer_id: crate::BufferId,
method: String,
params: serde_json::Value,
},
ServerExited { key: ServerKey },
ShutdownAll,
}
#[derive(Debug, Clone)]
pub struct RpcError {
pub code: i64,
pub message: String,
}
#[derive(Debug)]
pub enum LspEvent {
ServerInitialized {
key: ServerKey,
capabilities: serde_json::Value,
},
ServerExited {
key: ServerKey,
status: std::process::ExitStatus,
},
Notification {
key: ServerKey,
method: String,
params: serde_json::Value,
},
Response {
request_id: i64,
result: Result<serde_json::Value, RpcError>,
},
}