on master help sign in
Add --edit-config flag to directly open config.toml (#1771)
8d7a25bJoe
book/src/configuration.md+2
@@ -5,6 +5,8 @@ To override global configuration parameters, create a `config.toml` file located
5* Linux and Mac: `~/.config/helix/config.toml`
5* Linux and Mac: `~/.config/helix/config.toml`
6* Windows: `%AppData%\helix\config.toml`
6* Windows: `%AppData%\helix\config.toml`
7
7
8+> Note: You may use `hx --edit-config` to create and edit the `config.toml` file.
9+
8Example config:
10Example config:
9
11
10```toml
12```toml
helix-term/src/application.rs+3
@@ -113,6 +113,9 @@ impl Application {
113 editor.open(path, Action::VerticalSplit)?;
113 editor.open(path, Action::VerticalSplit)?;
114 // Unset path to prevent accidentally saving to the original tutor file.
114 // Unset path to prevent accidentally saving to the original tutor file.
115 doc_mut!(editor).set_path(None)?;
115 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)?;
116 } else if !args.files.is_empty() {
119 } else if !args.files.is_empty() {
117 let first = &args.files[0].0; // we know it's not empty
120 let first = &args.files[0].0; // we know it's not empty
118 if first.is_dir() {
121 if first.is_dir() {
helix-term/src/args.rs+2
@@ -11,6 +11,7 @@ pub struct Args {
11 pub load_tutor: bool,
11 pub load_tutor: bool,
12 pub verbosity: u64,
12 pub verbosity: u64,
13 pub files: Vec<(PathBuf, Position)>,
13 pub files: Vec<(PathBuf, Position)>,
14+ pub edit_config: bool,
14}
15}
15
16
16impl Args {
17impl Args {
@@ -26,6 +27,7 @@ impl Args {
26 "--version" => args.display_version = true,
27 "--version" => args.display_version = true,
27 "--help" => args.display_help = true,
28 "--help" => args.display_help = true,
28 "--tutor" => args.load_tutor = true,
29 "--tutor" => args.load_tutor = true,
30+ "--edit-config" => args.edit_config = true,
29 "--health" => {
31 "--health" => {
30 args.health = true;
32 args.health = true;
31 args.health_arg = argv.next_if(|opt| !opt.starts_with('-'));
33 args.health_arg = argv.next_if(|opt| !opt.starts_with('-'));
helix-term/src/main.rs+1
@@ -60,6 +60,7 @@ ARGS:
60
60
61FLAGS:
61FLAGS:
62 -h, --help Prints help information
62 -h, --help Prints help information
63+ --edit-config Opens the helix config file
63 --tutor Loads the tutorial
64 --tutor Loads the tutorial
64 --health [LANG] Checks for potential errors in editor setup
65 --health [LANG] Checks for potential errors in editor setup
65 If given, checks for config errors in language LANG
66 If given, checks for config errors in language LANG