@@ -1,6 +1,7 @@
1−use anyhow::{Context, Result};
1+use anyhow::{Context, Error, Result};
2use helix_term::application::Application;
2use helix_term::application::Application;
3use helix_term::args::Args;
3use helix_term::args::Args;
4+use helix_term::config::Config;
4use std::path::PathBuf;
5use std::path::PathBuf;
6fn setup_logging(logpath: PathBuf, verbosity: u64) -> Result<()> {
7fn setup_logging(logpath: PathBuf, verbosity: u64) -> Result<()> {
@@ -110,8 +111,28 @@ FLAGS:
111 setup_logging(logpath, args.verbosity).context("failed to initialize logging")?;
112 setup_logging(logpath, args.verbosity).context("failed to initialize logging")?;
114+ let config_dir = helix_loader::config_dir();
115+ if !config_dir.exists() {
116+ std::fs::create_dir_all(&config_dir).ok();
119+ let config = match std::fs::read_to_string(config_dir.join("config.toml")) {
120+ Ok(config) => toml::from_str(&config)
121+ .map(helix_term::keymap::merge_keys)
122+ .unwrap_or_else(|err| {
123+ eprintln!("Bad config: {}", err);
124+ eprintln!("Press <ENTER> to continue with default config");
126+ // This waits for an enter press.
127+ let _ = std::io::stdin().read(&mut []);
130+ Err(err) if err.kind() == std::io::ErrorKind::NotFound => Config::default(),
131+ Err(err) => return Err(Error::new(err)),
113 // TODO: use the thread local executor to spawn the application task separately from the work pool
134 // TODO: use the thread local executor to spawn the application task separately from the work pool
114− let mut app = Application::new(args).context("unable to create new application")?;
135+ let mut app = Application::new(args, config).context("unable to create new application")?;
116 let exit_code = app.run().await?;
137 let exit_code = app.run().await?;