mirror of
https://github.com/hexedtech/codemp.git
synced 2024-12-23 05:14:54 +01:00
fix: remove print, answer with command
Co-authored-by: f-tlm <f-tlm@users.noreply.github.com>
This commit is contained in:
parent
3425c57177
commit
934917ffa2
2 changed files with 10 additions and 8 deletions
|
@ -2,7 +2,7 @@ pub mod manager;
|
|||
mod nvim;
|
||||
|
||||
use tokio::sync::mpsc;
|
||||
use nvim_rs::{create::tokio::new_parent};
|
||||
use nvim_rs::create::tokio::new_parent;
|
||||
|
||||
use manager::ConnectionManager;
|
||||
use nvim::NeovimHandler;
|
||||
|
@ -11,6 +11,7 @@ use nvim::NeovimHandler;
|
|||
async fn main() -> Result<(), Box<(dyn std::error::Error + 'static)>> {
|
||||
let (tx, rx) = mpsc::channel(32);
|
||||
|
||||
//nvim stuff
|
||||
let handler: NeovimHandler = NeovimHandler::new(tx).await?;
|
||||
let (_nvim, io_handler) = new_parent(handler).await;
|
||||
|
||||
|
|
|
@ -5,13 +5,15 @@ use tokio::sync::mpsc;
|
|||
|
||||
use nvim_rs::{compat::tokio::Compat, Handler, Neovim};
|
||||
|
||||
use crate::manager::Command;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct NeovimHandler {
|
||||
tx: mpsc::Sender<i32>,
|
||||
tx: mpsc::Sender<Command>,
|
||||
}
|
||||
|
||||
impl NeovimHandler {
|
||||
pub async fn new(tx: mpsc::Sender<i32>) -> Result<Self, tonic::transport::Error> {
|
||||
pub async fn new(tx: mpsc::Sender<Command>) -> Result<Self, tonic::transport::Error> {
|
||||
Ok(NeovimHandler { tx })
|
||||
}
|
||||
}
|
||||
|
@ -29,11 +31,10 @@ impl Handler for NeovimHandler {
|
|||
match name.as_ref() {
|
||||
"ping" => Ok(Value::from("pong")),
|
||||
"rpc" => {
|
||||
eprintln!("Got 'rpc' from vim");
|
||||
self.tx.send(0).await.unwrap();
|
||||
// let request = tonic::Request::new(SessionRequest {session_id: 0});
|
||||
// let response = self.client.create(request).await.unwrap();
|
||||
Ok(Value::from("sent"))
|
||||
let (cmd, rx) = Command::create_session_cmd("asd".to_string());
|
||||
self.tx.send(cmd).await.unwrap();
|
||||
let resp = rx.await.unwrap();
|
||||
Ok(Value::from(format!("{:?}", resp)))
|
||||
},
|
||||
"buffer" => {
|
||||
let buf = _neovim.create_buf(true, false).await.unwrap();
|
||||
|
|
Loading…
Reference in a new issue