fix: remove print, answer with command

Co-authored-by: f-tlm <f-tlm@users.noreply.github.com>
This commit is contained in:
əlemi 2022-07-13 01:55:04 +02:00
parent 3425c57177
commit 934917ffa2
2 changed files with 10 additions and 8 deletions

View file

@ -2,7 +2,7 @@ pub mod manager;
mod nvim; mod nvim;
use tokio::sync::mpsc; use tokio::sync::mpsc;
use nvim_rs::{create::tokio::new_parent}; use nvim_rs::create::tokio::new_parent;
use manager::ConnectionManager; use manager::ConnectionManager;
use nvim::NeovimHandler; use nvim::NeovimHandler;
@ -11,6 +11,7 @@ use nvim::NeovimHandler;
async fn main() -> Result<(), Box<(dyn std::error::Error + 'static)>> { async fn main() -> Result<(), Box<(dyn std::error::Error + 'static)>> {
let (tx, rx) = mpsc::channel(32); let (tx, rx) = mpsc::channel(32);
//nvim stuff
let handler: NeovimHandler = NeovimHandler::new(tx).await?; let handler: NeovimHandler = NeovimHandler::new(tx).await?;
let (_nvim, io_handler) = new_parent(handler).await; let (_nvim, io_handler) = new_parent(handler).await;

View file

@ -5,13 +5,15 @@ use tokio::sync::mpsc;
use nvim_rs::{compat::tokio::Compat, Handler, Neovim}; use nvim_rs::{compat::tokio::Compat, Handler, Neovim};
use crate::manager::Command;
#[derive(Clone)] #[derive(Clone)]
pub struct NeovimHandler { pub struct NeovimHandler {
tx: mpsc::Sender<i32>, tx: mpsc::Sender<Command>,
} }
impl NeovimHandler { 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 }) Ok(NeovimHandler { tx })
} }
} }
@ -29,11 +31,10 @@ impl Handler for NeovimHandler {
match name.as_ref() { match name.as_ref() {
"ping" => Ok(Value::from("pong")), "ping" => Ok(Value::from("pong")),
"rpc" => { "rpc" => {
eprintln!("Got 'rpc' from vim"); let (cmd, rx) = Command::create_session_cmd("asd".to_string());
self.tx.send(0).await.unwrap(); self.tx.send(cmd).await.unwrap();
// let request = tonic::Request::new(SessionRequest {session_id: 0}); let resp = rx.await.unwrap();
// let response = self.client.create(request).await.unwrap(); Ok(Value::from(format!("{:?}", resp)))
Ok(Value::from("sent"))
}, },
"buffer" => { "buffer" => {
let buf = _neovim.create_buf(true, false).await.unwrap(); let buf = _neovim.create_buf(true, false).await.unwrap();