Add flag to open the file explorer on startup

Signed-off-by: trivernis <trivernis@protonmail.com>
change-detection
trivernis 2 years ago
parent a864b63b0f
commit 0725aa1046
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -15,8 +15,9 @@ And others I forgot about...
# Applied Changes
- Changed opening the window popup from `ctrl + w` to `ctrl + v`
- Added an auto select for files in the tree explorer when jumping through opened buffers
- Added an auto highlight for files in the tree explorer when jumping through opened buffers
- Changed some default settings (enabling bufferline, indent guides, the embedded explorer, cursor modes etc.)
- Added a `--show-explorer` cli flag to open the file explorer on startup (useful for embedded explorer mode)
- - -

@ -12,11 +12,11 @@ use serde_json::json;
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::{error, warn};
@ -153,7 +153,19 @@ 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)));
if args.show_explorer {
let mut jobs = Jobs::new();
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(overlayed(explorer));
}
compositor.push(editor_view);
if args.load_tutor {

@ -17,6 +17,7 @@ pub struct Args {
pub log_file: Option<PathBuf>,
pub config_file: Option<PathBuf>,
pub files: Vec<(PathBuf, Position)>,
pub show_explorer: bool,
}
impl Args {
@ -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" => args.split = Some(Layout::Vertical),
"--hsplit" => args.split = Some(Layout::Horizontal),
"--health" => {

@ -72,6 +72,7 @@ FLAGS:
-V, --version Prints version information
--vsplit Splits all given files vertically into different windows
--hsplit Splits all given files horizontally into different windows
--show-explorer Opens the explorer on startup
",
env!("CARGO_PKG_NAME"),
env!("VERSION_AND_GIT_HASH"),

Loading…
Cancel
Save