on master help sign in
Add --edit-config flag to directly open config.toml (#1771)

Co-authored-by: Gokul Soumya <gokulps15@gmail.com>

commit8d7a25b4d49ef5cd7f5d85585d60e52bdc2bc0c5 authorJoe <Josephharrisonlim@gmail.com> dateWed 9 Mar 2022, 13:34 (5 years ago) parent3f603b2
4 files changed+8
book/src/configuration.md+2 helix-term/src/application.rs+3 helix-term/src/args.rs+2 helix-term/src/main.rs+1
book/src/configuration.md+2
@@ -5,6 +5,8 @@ To override global configuration parameters, create a `config.toml` file located
55* Linux and Mac: `~/.config/helix/config.toml`
66* Windows: `%AppData%\helix\config.toml`
77
8+> Note: You may use `hx --edit-config` to create and edit the `config.toml` file.
9+
810Example config:
911
1012```toml
helix-term/src/application.rs+3
@@ -113,6 +113,9 @@ impl Application {
113113 editor.open(path, Action::VerticalSplit)?;
114114 // Unset path to prevent accidentally saving to the original tutor file.
115115 doc_mut!(editor).set_path(None)?;
116+ } else if args.edit_config {
117+ let path = conf_dir.join("config.toml");
118+ editor.open(path, Action::VerticalSplit)?;
116119 } else if !args.files.is_empty() {
117120 let first = &args.files[0].0; // we know it's not empty
118121 if first.is_dir() {
helix-term/src/args.rs+2
@@ -11,6 +11,7 @@ pub struct Args {
1111 pub load_tutor: bool,
1212 pub verbosity: u64,
1313 pub files: Vec<(PathBuf, Position)>,
14+ pub edit_config: bool,
1415}
1516
1617impl Args {
@@ -26,6 +27,7 @@ impl Args {
2627 "--version" => args.display_version = true,
2728 "--help" => args.display_help = true,
2829 "--tutor" => args.load_tutor = true,
30+ "--edit-config" => args.edit_config = true,
2931 "--health" => {
3032 args.health = true;
3133 args.health_arg = argv.next_if(|opt| !opt.starts_with('-'));
helix-term/src/main.rs+1
@@ -60,6 +60,7 @@ ARGS:
6060
6161FLAGS:
6262 -h, --help Prints help information
63+ --edit-config Opens the helix config file
6364 --tutor Loads the tutorial
6465 --health [LANG] Checks for potential errors in editor setup
6566 If given, checks for config errors in language LANG