chore: fix clippy warnings and run rustfmt

This commit is contained in:
Riz Ashraf committed 2026-10-09 00:39:50 +01:00
1 parent fecd8bf33f
commit 3765e6b05d
21 files changed
+420 -369

No files matched your search

+45 -27
View File
@@ -378,14 +378,17 @@ async fn get_nvim_connection() -> Result<mpsc::Sender<NvimRequest>, String> {
{
let conn_lock = NVIM_CONN.lock().await;
if let Some(sender) = conn_lock.as_ref()
&& !sender.is_closed() {
let active_lock = ACTIVE_SOCKET.lock().await;
if let Some(ref current_socket) = *active_lock
&& let Ok(target) = read_active_socket_file().await
&& !target.is_empty() && &target == current_socket {
return Ok(sender.clone());
}
&& !sender.is_closed()
{
let active_lock = ACTIVE_SOCKET.lock().await;
if let Some(ref current_socket) = *active_lock
&& let Ok(target) = read_active_socket_file().await
&& !target.is_empty()
&& &target == current_socket
{
return Ok(sender.clone());
}
}
}
let interactive_socket = get_socket_path().await.ok();
@@ -671,13 +674,14 @@ async fn call_nvim(req: rmpv::Value) -> Result<rmpv::Value, String> {
};
let (reply_tx, reply_rx) = oneshot::channel();
if let Err(_) = tx
if tx
.send(NvimRequest {
msgid,
req,
reply: reply_tx,
})
.await
.is_err()
{
PENDING_REQUESTS.remove(&msgid);
let mut conn = NVIM_CONN.lock().await;
@@ -1341,20 +1345,30 @@ pub async fn run_mcp_loop(app_name: &str, app_version: &str) {
}
"edit" => {
let mut modified_args = args.clone();
if let Some(edits) = modified_args.get_mut("edits").and_then(|v| v.as_array_mut()) {
if let Some(edits) = modified_args
.get_mut("edits")
.and_then(|v| v.as_array_mut())
{
for edit in edits.iter_mut() {
if let Some(content) = edit.get_mut("replacement_content") {
if let Some(s) = content.as_str() {
let lines: Vec<String> = s.split('\n').map(|l| l.trim_end_matches('\r').to_string()).collect();
*content = serde_json::json!(lines);
}
if let Some(content) = edit.get_mut("replacement_content")
&& let Some(s) = content.as_str()
{
let lines: Vec<String> = s
.split('\n')
.map(|l| l.trim_end_matches('\r').to_string())
.collect();
*content = serde_json::json!(lines);
}
}
} else if let Some(content) = modified_args.get_mut("replacement_content") {
if let Some(s) = content.as_str() {
let lines: Vec<String> = s.split('\n').map(|l| l.trim_end_matches('\r').to_string()).collect();
*content = serde_json::json!(lines);
}
} else if let Some(content) =
modified_args.get_mut("replacement_content")
&& let Some(s) = content.as_str()
{
let lines: Vec<String> = s
.split('\n')
.map(|l| l.trim_end_matches('\r').to_string())
.collect();
*content = serde_json::json!(lines);
}
let args_rmp = json_to_rmpv(&modified_args);
let code = "
@@ -1475,11 +1489,14 @@ pub async fn run_mcp_loop(app_name: &str, app_version: &str) {
}
"create_scratch" | "open_buffer" => {
let mut modified_args = args.clone();
if let Some(content) = modified_args.get_mut("content") {
if let Some(s) = content.as_str() {
let lines: Vec<String> = s.split('\n').map(|l| l.trim_end_matches('\r').to_string()).collect();
*content = serde_json::json!(lines);
}
if let Some(content) = modified_args.get_mut("content")
&& let Some(s) = content.as_str()
{
let lines: Vec<String> = s
.split('\n')
.map(|l| l.trim_end_matches('\r').to_string())
.collect();
*content = serde_json::json!(lines);
}
let args_rmp = json_to_rmpv(&modified_args);
let code = "
@@ -1942,9 +1959,10 @@ pub async fn run_mcp_loop(app_name: &str, app_version: &str) {
"highlight" | "clear_highlight" => {
let mut modified_args = args.clone();
if action == "clear_highlight"
&& let Some(obj) = modified_args.as_object_mut() {
obj.insert("clear_only".to_string(), json!(true));
}
&& let Some(obj) = modified_args.as_object_mut()
{
obj.insert("clear_only".to_string(), json!(true));
}
let args_rmp = json_to_rmpv(&modified_args);
let code = "
local args = ...