Add static Runnables (#8009)

Part of #7108

This PR includes just the static runnables part. We went with **not**
having a dedicated panel for runnables.
This is just a 1st PR out of N, as we want to start exploring the
dynamic runnables front. Still, all that work is going to happen once
this gets merged.

Release Notes:

- Added initial, static Runnables support to Zed. Such runnables are defined in
`runnables.json` file (accessible via `zed: open runnables` action) and
they can be spawned with `runnables: spawn` action.

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
Co-authored-by: Pitor <pitor@zed.dev>
Co-authored-by: Beniamin <beniamin@zagan.be>
This commit is contained in:
Piotr Osiewicz 2024-02-19 17:41:43 +01:00 committed by GitHub
parent ca251babcd
commit f17d0b5729
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 1394 additions and 275 deletions

View file

@ -22,8 +22,11 @@ use project_panel::ProjectPanel;
use quick_action_bar::QuickActionBar;
use release_channel::{AppCommitSha, ReleaseChannel};
use rope::Rope;
use runnable::static_source::StaticSource;
use search::project_search::ProjectSearchBar;
use settings::{initial_local_settings_content, KeymapFile, Settings, SettingsStore};
use settings::{
initial_local_settings_content, watch_config_file, KeymapFile, Settings, SettingsStore,
};
use std::{borrow::Cow, ops::Deref, path::Path, sync::Arc};
use terminal_view::terminal_panel::{self, TerminalPanel};
use util::{
@ -54,6 +57,7 @@ actions!(
OpenDefaultKeymap,
OpenDefaultSettings,
OpenKeymap,
OpenRunnables,
OpenLicenses,
OpenLocalSettings,
OpenLog,
@ -151,6 +155,20 @@ pub fn initialize_workspace(app_state: Arc<AppState>, cx: &mut AppContext) {
.unwrap_or(true)
});
let project = workspace.project().clone();
if project.read(cx).is_local() {
let runnables_file_rx = watch_config_file(
&cx.background_executor(),
app_state.fs.clone(),
paths::RUNNABLES.clone(),
);
let source = StaticSource::new(runnables_file_rx, cx);
project.update(cx, |project, cx| {
project
.runnable_inventory()
.update(cx, |inventory, cx| inventory.add_source(source, cx))
});
}
cx.spawn(|workspace_handle, mut cx| async move {
let project_panel = ProjectPanel::load(workspace_handle.clone(), cx.clone());
let terminal_panel = TerminalPanel::load(workspace_handle.clone(), cx.clone());
@ -254,6 +272,15 @@ pub fn initialize_workspace(app_state: Arc<AppState>, cx: &mut AppContext) {
);
},
)
.register_action(
move |_: &mut Workspace, _: &OpenRunnables, cx: &mut ViewContext<Workspace>| {
open_settings_file(
&paths::RUNNABLES,
|| settings::initial_runnables_content().as_ref().into(),
cx,
);
},
)
.register_action(open_local_settings_file)
.register_action(
move |workspace: &mut Workspace,