Skip to content

Commit

Permalink
Add --config option
Browse files Browse the repository at this point in the history
Add book entry

Change to --edit-config
  • Loading branch information
jharrilim committed Mar 8, 2022
1 parent 9a04064 commit 919bb17
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions book/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ To override global configuration parameters, create a `config.toml` file located
* Linux and Mac: `~/.config/helix/config.toml`
* Windows: `%AppData%\helix\config.toml`

> Note: You may use `hx --edit-config` to create and edit the `config.toml` file.
Example config:

```toml
Expand Down
3 changes: 3 additions & 0 deletions helix-term/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ impl Application {
editor.open(path, Action::VerticalSplit)?;
// Unset path to prevent accidentally saving to the original tutor file.
doc_mut!(editor).set_path(None)?;
} else if args.config {
let path = conf_dir.join("config.toml");
editor.open(path, Action::VerticalSplit)?;
} else if !args.files.is_empty() {
let first = &args.files[0].0; // we know it's not empty
if first.is_dir() {
Expand Down
2 changes: 2 additions & 0 deletions helix-term/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub struct Args {
pub load_tutor: bool,
pub verbosity: u64,
pub files: Vec<(PathBuf, Position)>,
pub config: bool,
}

impl Args {
Expand All @@ -25,6 +26,7 @@ impl Args {
"--version" => args.display_version = true,
"--help" => args.display_help = true,
"--tutor" => args.load_tutor = true,
"--edit-config" => args.config = true,
arg if arg.starts_with("--") => {
return Err(Error::msg(format!(
"unexpected double dash argument: {}",
Expand Down
1 change: 1 addition & 0 deletions helix-term/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ ARGS:
FLAGS:
-h, --help Prints help information
--edit-config Opens the helix config file
--tutor Loads the tutorial
-v Increases logging verbosity each use for up to 3 times
(default file: {})
Expand Down

0 comments on commit 919bb17

Please sign in to comment.