Fix issue with host function binding

This commit is contained in:
Isaac Clayton 2022-06-09 10:22:53 +02:00
parent 96c2559d2c
commit 7266dff537
2 changed files with 39 additions and 52 deletions

View file

@ -13,12 +13,12 @@ use std::{any::Any, path::PathBuf, sync::Arc};
use util::{ResultExt, TryFutureExt};
pub async fn new_json(executor: Arc<Background>) -> Result<PluginLspAdapter> {
let plugin = WasiPluginBuilder::new_with_default_ctx()
let plugin = WasiPluginBuilder::new_with_default_ctx()?
.host_function("command", |command: String| {
// TODO: actual thing
std::process::Command::new(command).output().unwrap();
Some("Hello".to_string())
})
})?
.init(include_bytes!("../../../../plugins/bin/json_language.wasm"))
.await?;
PluginLspAdapter::new(plugin, executor).await