Add logic for managing language and theme extensions (#7467)
This PR adds the initial support for loading extensions in Zed. ### Extensions Directory Extensions are loaded from the extensions directory. The extensions directory has the following structure: ``` extensions/ installed/ extension-a/ grammars/ languages/ extension-b/ themes/ manifest.json ``` The `manifest.json` file is used internally by Zed to keep track of which extensions are installed. This file should be maintained automatically, and shouldn't require any direct interaction with it. Extensions can provide Tree-sitter grammars, languages, and themes. Release Notes: - N/A --------- Co-authored-by: Marshall <marshall@zed.dev>
This commit is contained in:
parent
6b598a07d9
commit
6edeea7c8a
77 changed files with 1503 additions and 387 deletions
|
@ -47,7 +47,7 @@ use theme::{ActiveTheme, SystemAppearance, ThemeRegistry, ThemeSettings};
|
|||
use util::{
|
||||
async_maybe,
|
||||
http::{self, HttpClient, ZedHttpClient},
|
||||
paths::{self, CRASHES_DIR, CRASHES_RETIRED_DIR, PLUGINS_DIR},
|
||||
paths::{self, CRASHES_DIR, CRASHES_RETIRED_DIR},
|
||||
ResultExt,
|
||||
};
|
||||
use uuid::Uuid;
|
||||
|
@ -173,6 +173,8 @@ fn main() {
|
|||
);
|
||||
assistant::init(cx);
|
||||
|
||||
extension::init(fs.clone(), languages.clone(), ThemeRegistry::global(cx), cx);
|
||||
|
||||
load_user_themes_in_background(fs.clone(), cx);
|
||||
watch_themes(fs.clone(), cx);
|
||||
|
||||
|
@ -976,20 +978,13 @@ fn watch_themes(fs: Arc<dyn fs::Fs>, cx: &mut AppContext) {
|
|||
.detach()
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
async fn watch_languages(fs: Arc<dyn fs::Fs>, languages: Arc<LanguageRegistry>) {
|
||||
let reload_debounce = Duration::from_millis(250);
|
||||
|
||||
let mut events = fs.watch(PLUGINS_DIR.as_ref(), reload_debounce).await;
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
events = futures::stream::select(
|
||||
events,
|
||||
fs.watch("crates/zed/src/languages".as_ref(), reload_debounce)
|
||||
.await,
|
||||
)
|
||||
.boxed();
|
||||
}
|
||||
let mut events = fs
|
||||
.watch("crates/zed/src/languages".as_ref(), reload_debounce)
|
||||
.await;
|
||||
|
||||
while (events.next().await).is_some() {
|
||||
languages.reload();
|
||||
|
@ -1019,3 +1014,6 @@ fn watch_file_types(fs: Arc<dyn fs::Fs>, cx: &mut AppContext) {
|
|||
|
||||
#[cfg(not(debug_assertions))]
|
||||
fn watch_file_types(_fs: Arc<dyn fs::Fs>, _cx: &mut AppContext) {}
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
async fn watch_languages(_fs: Arc<dyn fs::Fs>, _languages: Arc<LanguageRegistry>) {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue