Start moving code from Zed to plugin

This commit is contained in:
Isaac Clayton 2022-06-03 15:03:30 +02:00
parent 7dd3114a7a
commit b84948711c
2 changed files with 18 additions and 9 deletions

View File

@ -10,7 +10,13 @@ use smol::fs;
use std::{any::Any, path::PathBuf, sync::Arc};
use util::{ResultExt, TryFutureExt};
pub fn new_json() {}
pub fn new_json() -> LanguagePluginLspAdapter {
let plugin = WasmPlugin {
source_bytes: include_bytes!("../../../../plugins/bin/json_language.wasm").to_vec(),
store_data: (),
};
LanguagePluginLspAdapter::new(plugin)
}
pub struct LanguagePluginLspAdapter {
runtime: Mutex<Wasm<()>>,
@ -47,14 +53,12 @@ impl LspAdapter for LanguagePluginLspAdapter {
self.runtime.lock().call("fetch_latest_server_version", ());
async move {
if let Ok((language_version, server_version)) = versions {
Ok(Box::new(Versions {
versions.map(|(language_version, server_version)| {
Box::new(Versions {
language_version,
server_version,
}) as Box<_>)
} else {
panic!()
}
}) as Box<_>
})
}
.boxed()
}

View File

@ -1,6 +1,11 @@
use plugin::prelude::*;
#[bind]
pub fn add(a: (f64, f64)) -> f64 {
a.0 + a.1
pub fn name(_: ()) -> &'static str {
"vscode-json-languageserver"
}
#[bind]
pub fn server_args(_: ()) -> Vec<String> {
vec!["--stdio".into()]
}