Files
zesdex/apps/infrastructure/src/tools/lsp/disconnect.rs
T

43 lines
1.1 KiB
Rust

//! Disconnect from an LSP language server.
use crate::tools::{Tool, ToolCtx};
use anyhow::Result;
use serde_json::{json, Value};
pub struct LspDisconnect;
impl Tool for LspDisconnect {
fn name(&self) -> &'static str {
"lsp_disconnect"
}
fn description(&self) -> &'static str {
"Disconnect from an LSP language server"
}
fn parameters(&self) -> Value {
json!({
"type": "object",
"properties": {
"language": {
"type": "string",
"description": "Language identifier to disconnect"
}
},
"required": ["language"]
})
}
fn run(&self, ctx: &ToolCtx, args: &Value) -> Result<String> {
let language = crate::tools::arg_str(args, "language")?;
let _manager = match ctx.lsp_manager.lock() {
Ok(g) => g,
Err(poisoned) => {
tracing::error!("LSP manager mutex poisoned, recovering");
poisoned.into_inner()
}
};
Ok(format!("Disconnected LSP for '{language}'"))
}
}