Remove wasmtime for now
This commit is contained in:
parent
3b90c778b9
commit
073128e4f3
3 changed files with 14 additions and 442 deletions
|
@ -44,7 +44,7 @@ use std::{
|
|||
};
|
||||
use syntax_map::SyntaxSnapshot;
|
||||
use theme::{SyntaxTheme, Theme};
|
||||
use tree_sitter::{self, wasmtime, Query, WasmStore};
|
||||
use tree_sitter::{self, Query};
|
||||
use unicase::UniCase;
|
||||
use util::{http::HttpClient, paths::PathExt};
|
||||
use util::{post_inc, ResultExt, TryFutureExt as _, UnwrapFuture};
|
||||
|
@ -85,14 +85,11 @@ impl LspBinaryStatusSender {
|
|||
|
||||
thread_local! {
|
||||
static PARSER: RefCell<Parser> = {
|
||||
let mut parser = Parser::new();
|
||||
parser.set_wasm_store(WasmStore::new(WASM_ENGINE.clone()).unwrap()).unwrap();
|
||||
RefCell::new(parser)
|
||||
RefCell::new(Parser::new())
|
||||
};
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
pub static ref WASM_ENGINE: wasmtime::Engine = wasmtime::Engine::default();
|
||||
pub static ref NEXT_GRAMMAR_ID: AtomicUsize = Default::default();
|
||||
pub static ref PLAIN_TEXT: Arc<Language> = Arc::new(Language::new(
|
||||
LanguageConfig {
|
||||
|
@ -641,8 +638,8 @@ enum AvailableGrammar {
|
|||
get_queries: fn(&str) -> LanguageQueries,
|
||||
},
|
||||
Wasm {
|
||||
grammar_name: Arc<str>,
|
||||
path: Arc<Path>,
|
||||
_grammar_name: Arc<str>,
|
||||
_path: Arc<Path>,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -742,7 +739,10 @@ impl LanguageRegistry {
|
|||
state.available_languages.push(AvailableLanguage {
|
||||
id: post_inc(&mut state.next_available_language_id),
|
||||
config,
|
||||
grammar: AvailableGrammar::Wasm { grammar_name, path },
|
||||
grammar: AvailableGrammar::Wasm {
|
||||
_grammar_name: grammar_name,
|
||||
_path: path,
|
||||
},
|
||||
lsp_adapters: Vec::new(),
|
||||
loaded: false,
|
||||
});
|
||||
|
@ -876,25 +876,8 @@ impl LanguageRegistry {
|
|||
asset_dir,
|
||||
get_queries,
|
||||
} => (grammar, (get_queries)(asset_dir)),
|
||||
AvailableGrammar::Wasm { grammar_name, path } => {
|
||||
let mut wasm_path = path.join(grammar_name.as_ref());
|
||||
wasm_path.set_extension("wasm");
|
||||
let wasm_bytes = std::fs::read(&wasm_path)?;
|
||||
let grammar = PARSER.with(|parser| {
|
||||
let mut parser = parser.borrow_mut();
|
||||
let mut store = parser.take_wasm_store().unwrap();
|
||||
let grammar =
|
||||
store.load_language(&grammar_name, &wasm_bytes);
|
||||
parser.set_wasm_store(store).unwrap();
|
||||
grammar
|
||||
})?;
|
||||
let mut queries = LanguageQueries::default();
|
||||
if let Ok(contents) = std::fs::read_to_string(
|
||||
&path.join("highlights.scm"),
|
||||
) {
|
||||
queries.highlights = Some(contents.into());
|
||||
}
|
||||
(grammar, queries)
|
||||
AvailableGrammar::Wasm { .. } => {
|
||||
Err(anyhow!("not supported"))?
|
||||
}
|
||||
};
|
||||
Language::new(language.config, Some(grammar))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue