aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/main.rs')
-rw-r--r--helix-term/src/main.rs35
1 files changed, 19 insertions, 16 deletions
diff --git a/helix-term/src/main.rs b/helix-term/src/main.rs
index e554a21b..0385d92c 100644
--- a/helix-term/src/main.rs
+++ b/helix-term/src/main.rs
@@ -1,8 +1,7 @@
use anyhow::{Context, Error, Result};
use helix_term::application::Application;
use helix_term::args::Args;
-use helix_term::config::Config;
-use helix_term::keymap::merge_keys;
+use helix_term::config::{Config, ConfigLoadError};
use std::path::PathBuf;
fn setup_logging(logpath: PathBuf, verbosity: u64) -> Result<()> {
@@ -60,7 +59,6 @@ ARGS:
FLAGS:
-h, --help Prints help information
- --edit-config Opens the helix config file
--tutor Loads the tutorial
--health [LANG] Checks for potential errors in editor setup
If given, checks for config errors in language LANG
@@ -118,19 +116,24 @@ FLAGS:
std::fs::create_dir_all(&conf_dir).ok();
}
- let config = match std::fs::read_to_string(helix_loader::config_file()) {
- Ok(config) => toml::from_str(&config)
- .map(merge_keys)
- .unwrap_or_else(|err| {
- eprintln!("Bad config: {}", err);
- eprintln!("Press <ENTER> to continue with default config");
- use std::io::Read;
- // This waits for an enter press.
- let _ = std::io::stdin().read(&mut []);
- Config::default()
- }),
- Err(err) if err.kind() == std::io::ErrorKind::NotFound => Config::default(),
- Err(err) => return Err(Error::new(err)),
+ let config = match Config::load_default() {
+ Ok(config) => config,
+ Err(err) => {
+ match err {
+ ConfigLoadError::BadConfig(err) => {
+ eprintln!("Bad config: {}", err);
+ eprintln!("Press <ENTER> to continue with default config");
+ use std::io::Read;
+ // This waits for an enter press.
+ let _ = std::io::stdin().read(&mut []);
+ Config::default()
+ }
+ ConfigLoadError::Error(err) if err.kind() == std::io::ErrorKind::NotFound => {
+ Config::default()
+ }
+ ConfigLoadError::Error(err) => return Err(Error::new(err)),
+ }
+ }
};
setup_logging(logpath, args.verbosity).context("failed to initialize logging")?;