1mod key_context_view;
2pub mod lsp_button;
3pub mod lsp_log_view;
4mod syntax_tree_view;
5
6#[cfg(test)]
7mod lsp_log_view_tests;
8
9use gpui::{App, AppContext, Entity};
10
11pub use lsp_log_view::LspLogView;
12pub use syntax_tree_view::{SyntaxTreeToolbarItemView, SyntaxTreeView};
13use ui::{Context, Window};
14use workspace::{Item, ItemHandle, SplitDirection, Workspace};
15
16pub fn init(cx: &mut App) {
17 lsp_log_view::init(false, cx);
18 syntax_tree_view::init(cx);
19 key_context_view::init(cx);
20}
21
22fn get_or_create_tool<T>(
23 workspace: &mut Workspace,
24 destination: SplitDirection,
25 window: &mut Window,
26 cx: &mut Context<Workspace>,
27 new_tool: impl FnOnce(&mut Window, &mut Context<T>) -> T,
28) -> Entity<T>
29where
30 T: Item,
31{
32 if let Some(item) = workspace.item_of_type::<T>(cx) {
33 return item;
34 }
35
36 let new_tool = cx.new(|cx| new_tool(window, cx));
37 match workspace.find_pane_in_direction(destination, cx) {
38 Some(right_pane) => {
39 workspace.add_item(
40 right_pane,
41 new_tool.boxed_clone(),
42 None,
43 true,
44 true,
45 window,
46 cx,
47 );
48 }
49 None => {
50 workspace.split_item(destination, new_tool.boxed_clone(), window, cx);
51 }
52 }
53 new_tool
54}