Merge branch 'main' into unborked-git-zed2-diagnostics-view

This commit is contained in:
Julia 2023-11-17 14:18:36 -05:00
commit 3655a96e54
128 changed files with 16288 additions and 2752 deletions

View file

@ -11,7 +11,7 @@ path = "src/zed2.rs"
doctest = false
[[bin]]
name = "Zed"
name = "Zed2"
path = "src/main.rs"
[dependencies]
@ -23,11 +23,10 @@ ai = { package = "ai2", path = "../ai2"}
call = { package = "call2", path = "../call2" }
# channel = { path = "../channel" }
cli = { path = "../cli" }
# collab_ui = { path = "../collab_ui" }
collab_ui = { package = "collab_ui2", path = "../collab_ui2" }
collections = { path = "../collections" }
command_palette = { package="command_palette2", path = "../command_palette2" }
# component_test = { path = "../component_test" }
# context_menu = { path = "../context_menu" }
client = { package = "client2", path = "../client2" }
# clock = { path = "../clock" }
copilot = { package = "copilot2", path = "../copilot2" }
@ -66,7 +65,7 @@ feature_flags = { package = "feature_flags2", path = "../feature_flags2" }
sum_tree = { path = "../sum_tree" }
shellexpand = "2.1.0"
text = { package = "text2", path = "../text2" }
# terminal_view = { path = "../terminal_view" }
terminal_view = { package = "terminal_view2", path = "../terminal_view2" }
theme = { package = "theme2", path = "../theme2" }
# theme_selector = { path = "../theme_selector" }
util = { path = "../util" }

View file

@ -107,7 +107,7 @@ impl LspAdapter for JsonLspAdapter {
&self,
cx: &mut AppContext,
) -> BoxFuture<'static, serde_json::Value> {
let action_names = gpui::all_action_names();
let action_names = cx.all_action_names();
let staff_mode = cx.is_staff();
let language_names = &self.languages.language_names();
let settings_schema = cx.global::<SettingsStore>().json_schema(

View file

@ -50,8 +50,8 @@ use util::{
use uuid::Uuid;
use workspace::{AppState, WorkspaceStore};
use zed2::{
build_window_options, ensure_only_instance, handle_cli_connection, init_zed_actions,
initialize_workspace, languages, Assets, IsOnlyInstance, OpenListener, OpenRequest,
build_window_options, ensure_only_instance, handle_cli_connection, initialize_workspace,
languages, Assets, IsOnlyInstance, OpenListener, OpenRequest,
};
mod open_listener;
@ -140,8 +140,7 @@ fn main() {
cx.set_global(client.clone());
theme::init(cx);
// context_menu::init(cx);
theme::init(theme::LoadThemes::All, cx);
project::Project::init(&client, cx);
client::init(&client, cx);
command_palette::init(cx);
@ -177,7 +176,6 @@ fn main() {
user_store,
fs,
build_window_options,
initialize_workspace,
// background_actions: todo!("ask Mikayla"),
workspace_store,
node_runtime,
@ -200,7 +198,7 @@ fn main() {
// search::init(cx);
// semantic_index::init(fs.clone(), http.clone(), languages.clone(), cx);
// vim::init(cx);
// terminal_view::init(cx);
terminal_view::init(cx);
// journal2::init(app_state.clone(), cx);
// language_selector::init(cx);
@ -208,13 +206,13 @@ fn main() {
// activity_indicator::init(cx);
// language_tools::init(cx);
call::init(app_state.client.clone(), app_state.user_store.clone(), cx);
// collab_ui::init(&app_state, cx);
collab_ui::init(&app_state, cx);
// feedback::init(cx);
// welcome::init(cx);
// zed::init(&app_state, cx);
// cx.set_menus(menus::menus());
init_zed_actions(app_state.clone(), cx);
initialize_workspace(app_state.clone(), cx);
if stdout_is_a_pty() {
cx.activate(true);

View file

@ -10,16 +10,17 @@ pub use assets::*;
use collections::VecDeque;
use editor::{Editor, MultiBuffer};
use gpui::{
actions, point, px, AppContext, AsyncWindowContext, Context, PromptLevel, Task,
TitlebarOptions, ViewContext, VisualContext, WeakView, WindowBounds, WindowKind, WindowOptions,
actions, point, px, AppContext, Context, PromptLevel, TitlebarOptions, ViewContext,
VisualContext, WindowBounds, WindowKind, WindowOptions,
};
pub use only_instance::*;
pub use open_listener::*;
use anyhow::{anyhow, Context as _, Result};
use anyhow::{anyhow, Context as _};
use project_panel::ProjectPanel;
use settings::{initial_local_settings_content, Settings};
use std::{borrow::Cow, ops::Deref, sync::Arc};
use terminal_view::terminal_panel::TerminalPanel;
use util::{
asset_str,
channel::ReleaseChannel,
@ -86,8 +87,147 @@ pub fn build_window_options(
}
}
pub fn init_zed_actions(app_state: Arc<AppState>, cx: &mut AppContext) {
cx.observe_new_views(move |workspace: &mut Workspace, _cx| {
pub fn initialize_workspace(app_state: Arc<AppState>, cx: &mut AppContext) {
cx.observe_new_views(move |workspace: &mut Workspace, cx| {
let workspace_handle = cx.view().clone();
cx.subscribe(&workspace_handle, {
move |workspace, _, event, cx| {
if let workspace::Event::PaneAdded(pane) = event {
pane.update(cx, |pane, cx| {
pane.toolbar().update(cx, |toolbar, cx| {
// todo!()
// let breadcrumbs = cx.add_view(|_| Breadcrumbs::new(workspace));
// toolbar.add_item(breadcrumbs, cx);
// let buffer_search_bar = cx.add_view(BufferSearchBar::new);
// toolbar.add_item(buffer_search_bar.clone(), cx);
// let quick_action_bar = cx.add_view(|_| {
// QuickActionBar::new(buffer_search_bar, workspace)
// });
// toolbar.add_item(quick_action_bar, cx);
let diagnostic_editor_controls =
cx.build_view(|_| diagnostics::ToolbarControls::new());
// toolbar.add_item(diagnostic_editor_controls, cx);
// let project_search_bar = cx.add_view(|_| ProjectSearchBar::new());
// toolbar.add_item(project_search_bar, cx);
// let submit_feedback_button =
// cx.add_view(|_| SubmitFeedbackButton::new());
// toolbar.add_item(submit_feedback_button, cx);
// let feedback_info_text = cx.add_view(|_| FeedbackInfoText::new());
// toolbar.add_item(feedback_info_text, cx);
// let lsp_log_item =
// cx.add_view(|_| language_tools::LspLogToolbarItemView::new());
// toolbar.add_item(lsp_log_item, cx);
// let syntax_tree_item = cx
// .add_view(|_| language_tools::SyntaxTreeToolbarItemView::new());
// toolbar.add_item(syntax_tree_item, cx);
})
});
}
}
})
.detach();
// cx.emit(workspace2::Event::PaneAdded(
// workspace.active_pane().clone(),
// ));
// let collab_titlebar_item =
// cx.add_view(|cx| CollabTitlebarItem::new(workspace, &workspace_handle, cx));
// workspace.set_titlebar_item(collab_titlebar_item.into_any(), cx);
// let copilot =
// cx.add_view(|cx| copilot_button::CopilotButton::new(app_state.fs.clone(), cx));
let diagnostic_summary =
cx.build_view(|cx| diagnostics::items::DiagnosticIndicator::new(workspace, cx));
// let activity_indicator = activity_indicator::ActivityIndicator::new(
// workspace,
// app_state.languages.clone(),
// cx,
// );
// let active_buffer_language =
// cx.add_view(|_| language_selector::ActiveBufferLanguage::new(workspace));
// let vim_mode_indicator = cx.add_view(|cx| vim::ModeIndicator::new(cx));
// let feedback_button = cx.add_view(|_| {
// feedback::deploy_feedback_button::DeployFeedbackButton::new(workspace)
// });
// let cursor_position = cx.add_view(|_| editor::items::CursorPosition::new());
workspace.status_bar().update(cx, |status_bar, cx| {
// status_bar.add_left_item(diagnostic_summary, cx);
// status_bar.add_left_item(activity_indicator, cx);
// status_bar.add_right_item(feedback_button, cx);
// status_bar.add_right_item(copilot, cx);
// status_bar.add_right_item(active_buffer_language, cx);
// status_bar.add_right_item(vim_mode_indicator, cx);
// status_bar.add_right_item(cursor_position, cx);
});
// auto_update::notify_of_any_new_update(cx.weak_handle(), cx);
// vim::observe_keystrokes(cx);
// cx.on_window_should_close(|workspace, cx| {
// if let Some(task) = workspace.close(&Default::default(), cx) {
// task.detach_and_log_err(cx);
// }
// false
// });
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());
// let assistant_panel = AssistantPanel::load(workspace_handle.clone(), cx.clone());
let channels_panel =
collab_ui::collab_panel::CollabPanel::load(workspace_handle.clone(), cx.clone());
// let chat_panel =
// collab_ui::chat_panel::ChatPanel::load(workspace_handle.clone(), cx.clone());
// let notification_panel = collab_ui::notification_panel::NotificationPanel::load(
// workspace_handle.clone(),
// cx.clone(),
// );
let (
project_panel,
terminal_panel,
// assistant_panel,
channels_panel,
// chat_panel,
// notification_panel,
) = futures::try_join!(
project_panel,
terminal_panel,
// assistant_panel,
channels_panel,
// chat_panel,
// notification_panel,
)?;
workspace_handle.update(&mut cx, |workspace, cx| {
let project_panel_position = project_panel.position(cx);
workspace.add_panel(project_panel, cx);
workspace.add_panel(terminal_panel, cx);
// workspace.add_panel(assistant_panel, cx);
workspace.add_panel(channels_panel, cx);
// workspace.add_panel(chat_panel, cx);
// workspace.add_panel(notification_panel, cx);
// if !was_deserialized
// && workspace
// .project()
// .read(cx)
// .visible_worktrees(cx)
// .any(|tree| {
// tree.read(cx)
// .root_entry()
// .map_or(false, |entry| entry.is_dir())
// })
// {
// workspace.toggle_dock(project_panel_position, cx);
// }
// cx.focus_self();
})
})
.detach();
workspace
.register_action(about)
.register_action(|_, _: &Hide, cx| {
@ -291,154 +431,6 @@ pub fn init_zed_actions(app_state: Arc<AppState>, cx: &mut AppContext) {
.detach();
}
pub fn initialize_workspace(
workspace_handle: WeakView<Workspace>,
was_deserialized: bool,
app_state: Arc<AppState>,
cx: AsyncWindowContext,
) -> Task<Result<()>> {
cx.spawn(|mut cx| async move {
workspace_handle.update(&mut cx, |workspace, cx| {
let workspace_handle = cx.view().clone();
cx.subscribe(&workspace_handle, {
move |workspace, _, event, cx| {
if let workspace::Event::PaneAdded(pane) = event {
pane.update(cx, |pane, cx| {
pane.toolbar().update(cx, |toolbar, cx| {
// todo!()
// let breadcrumbs = cx.add_view(|_| Breadcrumbs::new(workspace));
// toolbar.add_item(breadcrumbs, cx);
// let buffer_search_bar = cx.add_view(BufferSearchBar::new);
// toolbar.add_item(buffer_search_bar.clone(), cx);
// let quick_action_bar = cx.add_view(|_| {
// QuickActionBar::new(buffer_search_bar, workspace)
// });
// toolbar.add_item(quick_action_bar, cx);
let diagnostic_editor_controls =
cx.build_view(|_| diagnostics::ToolbarControls::new());
// toolbar.add_item(diagnostic_editor_controls, cx);
// let project_search_bar = cx.add_view(|_| ProjectSearchBar::new());
// toolbar.add_item(project_search_bar, cx);
// let submit_feedback_button =
// cx.add_view(|_| SubmitFeedbackButton::new());
// toolbar.add_item(submit_feedback_button, cx);
// let feedback_info_text = cx.add_view(|_| FeedbackInfoText::new());
// toolbar.add_item(feedback_info_text, cx);
// let lsp_log_item =
// cx.add_view(|_| language_tools::LspLogToolbarItemView::new());
// toolbar.add_item(lsp_log_item, cx);
// let syntax_tree_item = cx
// .add_view(|_| language_tools::SyntaxTreeToolbarItemView::new());
// toolbar.add_item(syntax_tree_item, cx);
})
});
}
}
})
.detach();
// cx.emit(workspace2::Event::PaneAdded(
// workspace.active_pane().clone(),
// ));
// let collab_titlebar_item =
// cx.add_view(|cx| CollabTitlebarItem::new(workspace, &workspace_handle, cx));
// workspace.set_titlebar_item(collab_titlebar_item.into_any(), cx);
// let copilot =
// cx.add_view(|cx| copilot_button::CopilotButton::new(app_state.fs.clone(), cx));
let diagnostic_summary =
cx.build_view(|cx| diagnostics::items::DiagnosticIndicator::new(workspace, cx));
// let activity_indicator = activity_indicator::ActivityIndicator::new(
// workspace,
// app_state.languages.clone(),
// cx,
// );
// let active_buffer_language =
// cx.add_view(|_| language_selector::ActiveBufferLanguage::new(workspace));
// let vim_mode_indicator = cx.add_view(|cx| vim::ModeIndicator::new(cx));
// let feedback_button = cx.add_view(|_| {
// feedback::deploy_feedback_button::DeployFeedbackButton::new(workspace)
// });
// let cursor_position = cx.add_view(|_| editor::items::CursorPosition::new());
workspace.status_bar().update(cx, |status_bar, cx| {
// status_bar.add_left_item(diagnostic_summary, cx);
// status_bar.add_left_item(activity_indicator, cx);
// status_bar.add_right_item(feedback_button, cx);
// status_bar.add_right_item(copilot, cx);
// status_bar.add_right_item(active_buffer_language, cx);
// status_bar.add_right_item(vim_mode_indicator, cx);
// status_bar.add_right_item(cursor_position, cx);
});
// auto_update::notify_of_any_new_update(cx.weak_handle(), cx);
// vim::observe_keystrokes(cx);
// cx.on_window_should_close(|workspace, cx| {
// if let Some(task) = workspace.close(&Default::default(), cx) {
// task.detach_and_log_err(cx);
// }
// false
// });
})?;
let project_panel = ProjectPanel::load(workspace_handle.clone(), cx.clone());
// let terminal_panel = TerminalPanel::load(workspace_handle.clone(), cx.clone());
// let assistant_panel = AssistantPanel::load(workspace_handle.clone(), cx.clone());
// let channels_panel =
// collab_ui::collab_panel::CollabPanel::load(workspace_handle.clone(), cx.clone());
// let chat_panel =
// collab_ui::chat_panel::ChatPanel::load(workspace_handle.clone(), cx.clone());
// let notification_panel = collab_ui::notification_panel::NotificationPanel::load(
// workspace_handle.clone(),
// cx.clone(),
// );
let (
project_panel,
// terminal_panel,
// assistant_panel,
// channels_panel,
// chat_panel,
// notification_panel,
) = futures::try_join!(
project_panel,
// terminal_panel,
// assistant_panel,
// channels_panel,
// chat_panel,
// notification_panel,
)?;
workspace_handle.update(&mut cx, |workspace, cx| {
let project_panel_position = project_panel.position(cx);
workspace.add_panel(project_panel, cx);
// workspace.add_panel(terminal_panel, cx);
// workspace.add_panel(assistant_panel, cx);
// workspace.add_panel(channels_panel, cx);
// workspace.add_panel(chat_panel, cx);
// workspace.add_panel(notification_panel, cx);
// if !was_deserialized
// && workspace
// .project()
// .read(cx)
// .visible_worktrees(cx)
// .any(|tree| {
// tree.read(cx)
// .root_entry()
// .map_or(false, |entry| entry.is_dir())
// })
// {
workspace.toggle_dock(project_panel_position, cx);
// }
// cx.focus_self();
})?;
Ok(())
})
}
fn about(_: &mut Workspace, _: &About, cx: &mut gpui::ViewContext<Workspace>) {
let app_name = cx.global::<ReleaseChannel>().display_name();
let version = env!("CARGO_PKG_VERSION");