mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-22 07:14:50 +01:00
fix: some temporary fixes to make it compile
This commit is contained in:
parent
f854b902a1
commit
7a4e69377d
1 changed files with 34 additions and 31 deletions
|
@ -6,7 +6,7 @@ use nvim_rs::{compat::tokio::Compat, Handler, Neovim};
|
||||||
use nvim_rs::create::tokio::new_parent;
|
use nvim_rs::create::tokio::new_parent;
|
||||||
use tonic::transport::Channel;
|
use tonic::transport::Channel;
|
||||||
|
|
||||||
use crate::proto::{SessionRequest, workspace_client::WorkspaceClient};
|
use crate::proto::{WorkspaceRequest, workspace_client::WorkspaceClient};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct NeovimHandler {
|
pub struct NeovimHandler {
|
||||||
|
@ -44,53 +44,56 @@ impl Handler for NeovimHandler {
|
||||||
}
|
}
|
||||||
let buf = neovim.get_current_buf().await.unwrap();
|
let buf = neovim.get_current_buf().await.unwrap();
|
||||||
let content = buf.get_lines(0, buf.line_count().await.unwrap(), false).await.unwrap().join("\n");
|
let content = buf.get_lines(0, buf.line_count().await.unwrap(), false).await.unwrap().join("\n");
|
||||||
let request = tonic::Request::new(SessionRequest {
|
let request = tonic::Request::new(WorkspaceRequest {
|
||||||
session_key: args[0].to_string(), content: Some(content),
|
session_key: args[0].to_string(),
|
||||||
});
|
});
|
||||||
let mut c = self.client.clone();
|
let mut c = self.client.clone();
|
||||||
let resp = c.create(request).await.unwrap().into_inner();
|
Err(Value::from("[!] Unimplemented"))
|
||||||
if resp.accepted {
|
// let resp = c.create(request).await.unwrap().into_inner();
|
||||||
Ok(Value::from(resp.session_key))
|
// if resp.accepted {
|
||||||
} else {
|
// Ok(Value::from(resp.session_key))
|
||||||
Err(Value::from("[!] rejected"))
|
// } else {
|
||||||
}
|
// Err(Value::from("[!] rejected"))
|
||||||
|
// }
|
||||||
},
|
},
|
||||||
"sync" => {
|
"sync" => {
|
||||||
if args.len() < 1 {
|
if args.len() < 1 {
|
||||||
return Err(Value::from("[!] no session key"));
|
return Err(Value::from("[!] no session key"));
|
||||||
}
|
}
|
||||||
let buf = neovim.get_current_buf().await.unwrap();
|
let buf = neovim.get_current_buf().await.unwrap();
|
||||||
let request = tonic::Request::new(SessionRequest {
|
let request = tonic::Request::new(WorkspaceRequest {
|
||||||
session_key: args[0].to_string(), content: None,
|
session_key: args[0].to_string(),
|
||||||
});
|
});
|
||||||
let mut c = self.client.clone();
|
let mut c = self.client.clone();
|
||||||
let resp = c.sync(request).await.unwrap().into_inner();
|
Err(Value::from("[!] Unimplemented"))
|
||||||
if let Some(content) = resp.content {
|
// let resp = c.sync(request).await.unwrap().into_inner();
|
||||||
buf.set_lines(
|
// if let Some(content) = resp.content {
|
||||||
0,
|
// buf.set_lines(
|
||||||
buf.line_count().await.unwrap(),
|
// 0,
|
||||||
false,
|
// buf.line_count().await.unwrap(),
|
||||||
content.split("\n").map(|s| s.to_string()).collect()
|
// false,
|
||||||
).await.unwrap();
|
// content.split("\n").map(|s| s.to_string()).collect()
|
||||||
Ok(Value::from(""))
|
// ).await.unwrap();
|
||||||
} else {
|
// Ok(Value::from(""))
|
||||||
Err(Value::from("[!] no content"))
|
// } else {
|
||||||
}
|
// Err(Value::from("[!] no content"))
|
||||||
|
// }
|
||||||
},
|
},
|
||||||
"leave" => {
|
"leave" => {
|
||||||
if args.len() < 1 {
|
if args.len() < 1 {
|
||||||
return Err(Value::from("[!] no session key"));
|
return Err(Value::from("[!] no session key"));
|
||||||
}
|
}
|
||||||
let request = tonic::Request::new(SessionRequest {
|
let request = tonic::Request::new(WorkspaceRequest {
|
||||||
session_key: args[0].to_string(), content: None,
|
session_key: args[0].to_string(),
|
||||||
});
|
});
|
||||||
let mut c = self.client.clone();
|
let mut c = self.client.clone();
|
||||||
let resp = c.leave(request).await.unwrap().into_inner();
|
Err(Value::from("[!] Unimplemented"))
|
||||||
if resp.accepted {
|
// let resp = c.leave(request).await.unwrap().into_inner();
|
||||||
Ok(Value::from(format!("closed session #{}", resp.session_key)))
|
// if resp.accepted {
|
||||||
} else {
|
// Ok(Value::from(format!("closed session #{}", resp.session_key)))
|
||||||
Err(Value::from("[!] could not close session"))
|
// } else {
|
||||||
}
|
// Err(Value::from("[!] could not close session"))
|
||||||
|
// }
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
eprintln!("[!] unexpected call");
|
eprintln!("[!] unexpected call");
|
||||||
|
|
Loading…
Reference in a new issue