From 3759165ab212434aa779a387b510f77f747c46a9 Mon Sep 17 00:00:00 2001 From: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com> Date: Thu, 5 Dec 2024 21:48:40 +0000 Subject: [PATCH] feat: add --default-language-config --- helix-term/src/args.rs | 4 +++- helix-term/src/main.rs | 21 +++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/helix-term/src/args.rs b/helix-term/src/args.rs index 23ca768eb774..dfca2cb3c063 100644 --- a/helix-term/src/args.rs +++ b/helix-term/src/args.rs @@ -17,6 +17,7 @@ pub struct Args { pub log_file: Option, pub config_file: Option, pub default_config: bool, + pub default_language_config: bool, pub files: Vec<(PathBuf, Position)>, pub working_directory: Option, } @@ -54,7 +55,8 @@ impl Args { anyhow::bail!("--grammar must be followed by either 'fetch' or 'build'") } }, - "-d" | "--default-config" => args.default_config = true, + "--default-config" => args.default_config = true, + "--default-language-config" => args.default_language_config = true, "-c" | "--config" => match argv.next().as_deref() { Some(path) => args.config_file = Some(path.into()), None => anyhow::bail!("--config must specify a path to read"), diff --git a/helix-term/src/main.rs b/helix-term/src/main.rs index 2cd70c2eed51..fca0b81cd799 100644 --- a/helix-term/src/main.rs +++ b/helix-term/src/main.rs @@ -59,8 +59,9 @@ FLAGS: CATEGORY can be a language or one of 'clipboard', 'languages' or 'all'. 'all' is the default if not specified. -g, --grammar {{fetch|build}} Fetches or builds tree-sitter grammars listed in languages.toml - -d, --default-config Use the default configuration file -c, --config Specifies a file to use for configuration + --default-config Use the default configuration file + --default-language-config Use the default language configuration file -v Increases logging verbosity each use for up to 3 times --log Specifies a file to use for logging (default file: {}) @@ -149,14 +150,18 @@ FLAGS: } }; - let lang_loader = helix_core::config::user_lang_loader().unwrap_or_else(|err| { - eprintln!("{}", err); - eprintln!("Press to continue with default language config"); - use std::io::Read; - // This waits for an enter press. - let _ = std::io::stdin().read(&mut []); + let lang_loader = if args.default_language_config { helix_core::config::default_lang_loader() - }); + } else { + helix_core::config::user_lang_loader().unwrap_or_else(|err| { + eprintln!("{}", err); + eprintln!("Press to continue with default language config"); + use std::io::Read; + // This waits for an enter press. + let _ = std::io::stdin().read(&mut []); + helix_core::config::default_lang_loader() + }) + }; // TODO: use the thread local executor to spawn the application task separately from the work pool let mut app =