feat: made nvim client a feature (for now, enabled by default)

This commit is contained in:
əlemi 2022-07-16 03:46:02 +02:00
parent 2195cb28b8
commit ede7a7758c
2 changed files with 9 additions and 23 deletions

View file

@ -3,6 +3,10 @@ name = "codemp"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
[features]
default = ["nvim"]
nvim = []
[[bin]] # Bin to run the CodeMP gRPC server [[bin]] # Bin to run the CodeMP gRPC server
name = "codemp-server" name = "codemp-server"
path = "src/server/main.rs" path = "src/server/main.rs"

View file

@ -1,32 +1,14 @@
pub mod manager;
mod nvim; mod nvim;
use tokio::sync::mpsc; pub mod proto { tonic::include_proto!("workspace"); }
use nvim_rs::create::tokio::new_parent; use proto::workspace_client::WorkspaceClient;
use manager::ConnectionManager;
use nvim::NeovimHandler;
#[tokio::main] #[tokio::main]
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 client = WorkspaceClient::connect("http://[::1]:50051").await?;
//nvim stuff #[cfg(feature = "nvim")]
let handler: NeovimHandler = NeovimHandler::new(tx).await?; crate::nvim::run_nvim_client(client).await.unwrap();
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"),
}
Ok(()) Ok(())
} }