diff options
author | Blaž Hrastnik | 2021-04-07 14:56:20 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-04-07 14:56:20 +0000 |
commit | bc4e54c0c45abbbb5fe9ac3278361d0b4e5774ba (patch) | |
tree | a37eafc76b3b2fd19415761eac0eb97b437f261b /helix-term | |
parent | f0d49d3ca4535a8c22a4ca4038e889560723ec74 (diff) |
Load config files from ~/.config/helix, fallback to defaults.
Diffstat (limited to 'helix-term')
-rw-r--r-- | helix-term/src/main.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/helix-term/src/main.rs b/helix-term/src/main.rs index a2ea5993..612f8cf0 100644 --- a/helix-term/src/main.rs +++ b/helix-term/src/main.rs @@ -74,10 +74,17 @@ fn main() { setup_logging(verbosity).expect("failed to initialize logging."); // initialize language registry + use helix_core::config_dir; use helix_core::syntax::{Loader, LOADER}; - let toml = include_str!("../../languages.toml"); + + // load $HOME/.config/helix/languages.toml, fallback to default config + let config = std::fs::read(config_dir().join("languages.toml")); + let toml = config + .as_deref() + .unwrap_or(include_bytes!("../../languages.toml")); + LOADER.get_or_init(|| { - let config = toml::from_str(toml).expect("Could not parse languages.toml"); + let config = toml::from_slice(toml).expect("Could not parse languages.toml"); Loader::new(config) }); |