1pub mod components;
2mod jupyter_settings;
3pub mod kernels;
4pub mod notebook;
5mod outputs;
6mod repl_editor;
7mod repl_sessions_ui;
8mod repl_store;
9mod session;
10
11use std::{sync::Arc, time::Duration};
12
13use async_dispatcher::{Dispatcher, Runnable, set_dispatcher};
14use gpui::{App, PlatformDispatcher};
15use project::Fs;
16pub use runtimelib::ExecutionState;
17use settings::Settings as _;
18
19pub use crate::jupyter_settings::JupyterSettings;
20pub use crate::kernels::{Kernel, KernelSpecification, KernelStatus};
21pub use crate::repl_editor::*;
22pub use crate::repl_sessions_ui::{
23 ClearOutputs, Interrupt, ReplSessionsPage, Restart, Run, Sessions, Shutdown,
24};
25use crate::repl_store::ReplStore;
26pub use crate::session::Session;
27
28pub const KERNEL_DOCS_URL: &str = "https://zed.dev/docs/repl#changing-kernels";
29
30pub fn init(fs: Arc<dyn Fs>, cx: &mut App) {
31 set_dispatcher(zed_dispatcher(cx));
32 JupyterSettings::register(cx);
33 ::editor::init_settings(cx);
34 repl_sessions_ui::init(cx);
35 ReplStore::init(fs, cx);
36}
37
38fn zed_dispatcher(cx: &mut App) -> impl Dispatcher {
39 struct ZedDispatcher {
40 dispatcher: Arc<dyn PlatformDispatcher>,
41 }
42
43 // PlatformDispatcher is _super_ close to the same interface we put in
44 // async-dispatcher, except for the task label in dispatch. Later we should
45 // just make that consistent so we have this dispatcher ready to go for
46 // other crates in Zed.
47 impl Dispatcher for ZedDispatcher {
48 fn dispatch(&self, runnable: Runnable) {
49 self.dispatcher.dispatch(runnable, None)
50 }
51
52 fn dispatch_after(&self, duration: Duration, runnable: Runnable) {
53 self.dispatcher.dispatch_after(duration, runnable);
54 }
55 }
56
57 ZedDispatcher {
58 dispatcher: cx.background_executor().dispatcher.clone(),
59 }
60}