extern crate neovim;
use futures::StreamExt;
use neovim::{nvim, Value};
use std::process::Stdio;
use tokio::process::Command;
#[tokio::main]
async fn main() {
let mut child = Command::new("/opt/homebrew/bin/nvim")
.arg("--embed")
.arg("--clean")
.arg("-u")
.arg("/Users/lucas/Projects/rust-neovim-ui/neovim/examples/simple.lua")
.arg("/Users/lucas/Projects/rust-neovim-ui/neovim/examples/simple.lua")
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn()
.unwrap();
let stdout = child.stdout.take().unwrap();
let stdin = child.stdin.take().unwrap();
let handler = tokio::spawn({
let mut n = nvim::Nvim::new(stdout, stdin);
n.request(
"nvim_ui_attach",
vec![Value::from(200), Value::from(200), Value::Map(vec![])],
)
.await;
async move {
while let Some(m) = n.next().await {
match m {
neovim::Message::Request { id, method, params } => {
let _ = n.request("nvim_get_api_info", vec![]).await;
}
neovim::Message::Notification { method, params } => {
dbg!(method);
}
_ => {}
}
}
}
});
handler.await.unwrap();
}