Skip to content

Commit

Permalink
feat: add --default-language-config
Browse files Browse the repository at this point in the history
  • Loading branch information
nik-rev committed Dec 5, 2024
1 parent bf32d86 commit 3759165
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
4 changes: 3 additions & 1 deletion helix-term/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub struct Args {
pub log_file: Option<PathBuf>,
pub config_file: Option<PathBuf>,
pub default_config: bool,
pub default_language_config: bool,
pub files: Vec<(PathBuf, Position)>,
pub working_directory: Option<PathBuf>,
}
Expand Down Expand Up @@ -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"),
Expand Down
21 changes: 13 additions & 8 deletions helix-term/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 <file> 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 <file> Specifies a file to use for logging
(default file: {})
Expand Down Expand Up @@ -149,14 +150,18 @@ FLAGS:
}
};

let lang_loader = helix_core::config::user_lang_loader().unwrap_or_else(|err| {
eprintln!("{}", err);
eprintln!("Press <ENTER> 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 <ENTER> 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 =
Expand Down

0 comments on commit 3759165

Please sign in to comment.