Add --show-explorer cli arg

feature/file-explorer
trivernis 1 year ago
parent 432522e724
commit bd32cb3114
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -21,11 +21,11 @@ use tui::backend::Backend;
use crate::{
args::Args,
commands::apply_workspace_edit,
compositor::{Compositor, Event},
compositor::{self, Compositor, Event},
config::Config,
job::Jobs,
keymap::Keymaps,
ui::{self, overlay::overlayed},
ui::{self, overlay::overlayed, Explorer},
};
use log::{debug, error, warn};
@ -155,7 +155,21 @@ impl Application {
let keys = Box::new(Map::new(Arc::clone(&config), |config: &Config| {
&config.keys
}));
let editor_view = Box::new(ui::EditorView::new(Keymaps::new(keys)));
let mut editor_view = Box::new(ui::EditorView::new(Keymaps::new(keys)));
let mut jobs = Jobs::new();
if args.show_explorer {
let mut context = compositor::Context {
editor: &mut editor,
scroll: None,
jobs: &mut jobs,
};
let mut explorer = Explorer::new(&mut context)?;
explorer.unfocus();
editor_view.explorer = Some(explorer);
}
compositor.push(editor_view);
if args.load_tutor {
@ -244,7 +258,7 @@ impl Application {
syn_loader,
signals,
jobs: Jobs::new(),
jobs,
lsp_progress: LspProgressMap::new(),
last_render: Instant::now(),
};

@ -10,6 +10,7 @@ pub struct Args {
pub health: bool,
pub health_arg: Option<String>,
pub load_tutor: bool,
pub show_explorer: bool,
pub fetch_grammars: bool,
pub build_grammars: bool,
pub split: Option<Layout>,
@ -32,6 +33,7 @@ impl Args {
"--version" => args.display_version = true,
"--help" => args.display_help = true,
"--tutor" => args.load_tutor = true,
"--show-explorer" => args.show_explorer = true,
"--vsplit" => match args.split {
Some(_) => anyhow::bail!("can only set a split once of a specific type"),
None => args.split = Some(Layout::Vertical),

@ -266,7 +266,7 @@ impl Explorer {
self.state.open = true;
}
fn unfocus(&mut self) {
pub fn unfocus(&mut self) {
self.state.focus = false;
}

Loading…
Cancel
Save