fix(mcp): Add missing Cargo.lock, lua bindings, and workspace fixes for tools
This commit is contained in:
1 parent
c1b9767199
commit
185c3c999e
4 files changed
+154
-1
No files matched your search
@@ -1118,6 +1118,31 @@ pub async fn run_mcp_loop(app_name: &str, app_version: &str) {
|
||||
"type": "object",
|
||||
"properties": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "nvim_send_to_terminal",
|
||||
"description": "Send a given command string to a Neovim split terminal.",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"command": { "type": "string" }
|
||||
},
|
||||
"required": ["command"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "nvim_set_preview",
|
||||
"description": "Overlay proposed code changes as Ghost Text. The preview mechanism uses extmarks for inline suggestions.",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"file_path": { "type": "string" },
|
||||
"start_line": { "type": "integer" },
|
||||
"end_line": { "type": "integer" },
|
||||
"preview_content": { "type": "string" }
|
||||
},
|
||||
"required": ["file_path", "start_line", "end_line", "preview_content"]
|
||||
}
|
||||
}
|
||||
]
|
||||
})),
|
||||
@@ -1574,6 +1599,56 @@ pub async fn run_mcp_loop(app_name: &str, app_version: &str) {
|
||||
send_error(id, -32602, "Missing 'code'").await;
|
||||
}
|
||||
}
|
||||
"nvim_send_to_terminal" => {
|
||||
if let Some(cmd) = args.get("command").and_then(|v| v.as_str()) {
|
||||
let escaped_cmd = cmd.replace('\\', "\\\\").replace('"', "\\\"");
|
||||
let lua_code = format!(r#"
|
||||
if _G.gemini and _G.gemini.send_to_terminal then
|
||||
_G.gemini.send_to_terminal("{escaped_cmd}")
|
||||
return "Command sent to terminal"
|
||||
else
|
||||
error("gemini UI not loaded")
|
||||
end
|
||||
"#);
|
||||
handle_lua_result!(id, execute_nvim_lua(&lua_code));
|
||||
} else {
|
||||
send_error(id, -32602, "Missing 'command'").await;
|
||||
}
|
||||
}
|
||||
"nvim_set_preview" => {
|
||||
if let (Some(file), Some(start_line), Some(end_line), Some(preview_content)) = (
|
||||
args.get("file_path").and_then(|v| v.as_str()),
|
||||
args.get("start_line").and_then(|v| v.as_i64()),
|
||||
args.get("end_line").and_then(|v| v.as_i64()),
|
||||
args.get("preview_content").and_then(|v| v.as_str())
|
||||
) {
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
let diff_id = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_millis().to_string();
|
||||
|
||||
let mut lines_str = String::from("{");
|
||||
for line in preview_content.lines() {
|
||||
lines_str.push_str(&format!(r#""{}", "#, line.replace('\\', "\\\\").replace('"', "\\\"")));
|
||||
}
|
||||
lines_str.push('}');
|
||||
|
||||
let escaped_file = file.replace('\\', "\\\\").replace('"', "\\\"");
|
||||
let lua_code = format!(r#"
|
||||
if _G.gemini and _G.gemini.preview_diff then
|
||||
local bufnr = vim.fn.bufnr("{escaped_file}")
|
||||
if bufnr == -1 then
|
||||
bufnr = 0
|
||||
end
|
||||
_G.gemini.preview_diff("{diff_id}", bufnr, {start_line}, {end_line}, {lines_str})
|
||||
return "Preview added"
|
||||
else
|
||||
error("gemini UI not loaded")
|
||||
end
|
||||
"#);
|
||||
handle_lua_result!(id, execute_nvim_lua(&lua_code));
|
||||
} else {
|
||||
send_error(id, -32602, "Missing arguments").await;
|
||||
}
|
||||
}
|
||||
"nvim_get_server_info" => {
|
||||
let os = if cfg!(windows) { "Windows" } else { "Linux" };
|
||||
let exe_path = std::env::current_exe()
|
||||
|
||||
Reference in new issue
Block a user