Initial impl of NodeRuntime w/JSON borked and a deadlock :)

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
Julia 2023-03-26 23:59:49 -04:00
parent 1a2e509e35
commit c72d33e029
20 changed files with 435 additions and 375 deletions

View file

@ -1,5 +1,8 @@
use anyhow::Context;
use client::http::HttpClient;
use gpui::executor::Background;
pub use language::*;
use node_runtime::NodeRuntime;
use rust_embed::RustEmbed;
use std::{borrow::Cow, str, sync::Arc};
use theme::ThemeRegistry;
@ -12,14 +15,13 @@ mod installation;
mod json;
mod language_plugin;
mod lua;
mod node_runtime;
mod python;
mod ruby;
mod rust;
mod typescript;
mod yaml;
pub use installation::ensure_node_installation_dir;
// 1. Add tree-sitter-{language} parser to zed crate
// 2. Create a language directory in zed/crates/zed/src/languages and add the language to init function below
// 3. Add config.toml to the newly created language directory using existing languages as a template
@ -34,7 +36,14 @@ pub use installation::ensure_node_installation_dir;
#[exclude = "*.rs"]
struct LanguageDir;
pub fn init(languages: Arc<LanguageRegistry>, themes: Arc<ThemeRegistry>) {
pub fn init(
http: Arc<dyn HttpClient>,
background: Arc<Background>,
languages: Arc<LanguageRegistry>,
themes: Arc<ThemeRegistry>,
) {
let node_runtime = NodeRuntime::new(http, background);
for (name, grammar, lsp_adapter) in [
(
"c",
@ -65,6 +74,7 @@ pub fn init(languages: Arc<LanguageRegistry>, themes: Arc<ThemeRegistry>) {
"json",
tree_sitter_json::language(),
Some(Arc::new(json::JsonLspAdapter::new(
node_runtime.clone(),
languages.clone(),
themes.clone(),
))),
@ -77,7 +87,9 @@ pub fn init(languages: Arc<LanguageRegistry>, themes: Arc<ThemeRegistry>) {
(
"python",
tree_sitter_python::language(),
Some(Arc::new(python::PythonLspAdapter)),
Some(Arc::new(python::PythonLspAdapter::new(
node_runtime.clone(),
))),
),
(
"rust",
@ -92,22 +104,28 @@ pub fn init(languages: Arc<LanguageRegistry>, themes: Arc<ThemeRegistry>) {
(
"tsx",
tree_sitter_typescript::language_tsx(),
Some(Arc::new(typescript::TypeScriptLspAdapter)),
Some(Arc::new(typescript::TypeScriptLspAdapter::new(
node_runtime.clone(),
))),
),
(
"typescript",
tree_sitter_typescript::language_typescript(),
Some(Arc::new(typescript::TypeScriptLspAdapter)),
Some(Arc::new(typescript::TypeScriptLspAdapter::new(
node_runtime.clone(),
))),
),
(
"javascript",
tree_sitter_typescript::language_tsx(),
Some(Arc::new(typescript::TypeScriptLspAdapter)),
Some(Arc::new(typescript::TypeScriptLspAdapter::new(
node_runtime.clone(),
))),
),
(
"html",
tree_sitter_html::language(),
Some(Arc::new(html::HtmlLspAdapter)),
Some(Arc::new(html::HtmlLspAdapter::new(node_runtime.clone()))),
),
(
"ruby",
@ -137,7 +155,7 @@ pub fn init(languages: Arc<LanguageRegistry>, themes: Arc<ThemeRegistry>) {
(
"yaml",
tree_sitter_yaml::language(),
Some(Arc::new(yaml::YamlLspAdapter)),
Some(Arc::new(yaml::YamlLspAdapter::new(node_runtime.clone()))),
),
] {
languages.register(name, load_config(name), grammar, lsp_adapter, load_queries);