Fix incomplete language names list being used for JSON schema

For now, since initializing the languages themselves is still async,
create a parallel duplicated code path that is synchronous, and
just provided the language names.
This commit is contained in:
Max Brunsfeld 2022-07-13 15:04:03 -07:00
parent cd87c5552e
commit 4775d839d7
3 changed files with 25 additions and 4 deletions

View file

@ -1,5 +1,6 @@
use gpui::executor::Background;
pub use language::*;
use lazy_static::lazy_static;
use rust_embed::RustEmbed;
use std::{borrow::Cow, str, sync::Arc};
@ -17,6 +18,21 @@ mod typescript;
#[exclude = "*.rs"]
struct LanguageDir;
// TODO - Remove this once the `init` function is synchronous again.
lazy_static! {
pub static ref LANGUAGE_NAMES: Vec<String> = LanguageDir::iter()
.filter_map(|path| {
if path.ends_with("config.toml") {
let config = LanguageDir::get(&path)?;
let config = toml::from_slice::<LanguageConfig>(&config.data).ok()?;
Some(config.name.to_string())
} else {
None
}
})
.collect();
}
pub async fn init(languages: Arc<LanguageRegistry>, _executor: Arc<Background>) {
for (name, grammar, lsp_adapter) in [
(