diff --git a/Cargo.toml b/Cargo.toml index f75e500..84b8da7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,10 @@ name = "codemp" version = "0.1.0" edition = "2021" +[features] +default = ["nvim"] +nvim = [] + [[bin]] # Bin to run the CodeMP gRPC server name = "codemp-server" path = "src/server/main.rs" diff --git a/src/client/main.rs b/src/client/main.rs index 0c5b745..dabdf72 100644 --- a/src/client/main.rs +++ b/src/client/main.rs @@ -1,32 +1,14 @@ -pub mod manager; mod nvim; -use tokio::sync::mpsc; -use nvim_rs::create::tokio::new_parent; - -use manager::ConnectionManager; -use nvim::NeovimHandler; +pub mod proto { tonic::include_proto!("workspace"); } +use proto::workspace_client::WorkspaceClient; #[tokio::main] async fn main() -> Result<(), Box<(dyn std::error::Error + 'static)>> { - let (tx, rx) = mpsc::channel(32); + let client = WorkspaceClient::connect("http://[::1]:50051").await?; - //nvim stuff - let handler: NeovimHandler = NeovimHandler::new(tx).await?; - let (_nvim, io_handler) = new_parent(handler).await; - - // nvim.call(":echo", vec![Value::from("'***REMOVED***'")]).await.unwrap(); - let mut mngr = ConnectionManager::new("http://[::1]:50051".to_string(), rx).await?; - let _task = tokio::spawn(async move { - mngr.process_packets().await - }); - - // Any error should probably be logged, as stderr is not visible to users. - match io_handler.await { - Err(err) => eprintln!("Error joining IO loop: {:?}", err), - Ok(Err(err)) => eprintln!("Process ended with error: {:?}", err), - Ok(Ok(())) => eprintln!("Finished"), - } + #[cfg(feature = "nvim")] + crate::nvim::run_nvim_client(client).await.unwrap(); Ok(()) }