aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/main.rs
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2020-08-21 15:48:48 +0000
committerGitHub <noreply@github.com>2020-08-21 18:48:48 +0300
commit3c3e6870dedad56b270f5b65ea57d5a6e46b1de6 (patch)
tree84a4e306a1c198f1bb81a090cb41f7b062e3f736 /alacritty/src/main.rs
parent3a7130086a8b5fa95c46a15d5b09a220be57708c (diff)
downloadr-alacritty-3c3e6870dedad56b270f5b65ea57d5a6e46b1de6.tar.gz
r-alacritty-3c3e6870dedad56b270f5b65ea57d5a6e46b1de6.tar.bz2
r-alacritty-3c3e6870dedad56b270f5b65ea57d5a6e46b1de6.zip
Add configuration file imports
This adds the ability for users to have multiple configuration files which all inherit from each other. The order of imports is chronological, branching out to the deepest children first and overriding every field with that of the configuration files that are loaded at a later point in time. Live config reload watches the directories of all configuration files, allowing edits in any of them to update Alacritty immediately. While the imports are live reloaded, a new configuration file watcher will only be spawned once Alacritty is restarted. Since this might cause loops which would be very difficult to detect, a maximum depth is set to limit the recursion possible with nested configuration files. Fixes #779.
Diffstat (limited to 'alacritty/src/main.rs')
-rw-r--r--alacritty/src/main.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/alacritty/src/main.rs b/alacritty/src/main.rs
index e6884204..21c4804c 100644
--- a/alacritty/src/main.rs
+++ b/alacritty/src/main.rs
@@ -54,7 +54,7 @@ mod gl {
}
use crate::cli::Options;
-use crate::config::monitor::Monitor;
+use crate::config::monitor;
use crate::config::Config;
use crate::display::Display;
use crate::event::{Event, EventProxy, Processor};
@@ -84,7 +84,10 @@ fn main() {
// Load configuration file.
let config_path = options.config_path().or_else(config::installed_config);
- let config = config_path.map(config::load_from).unwrap_or_else(Config::default);
+ let config = config_path
+ .as_ref()
+ .and_then(|path| config::load_from(path).ok())
+ .unwrap_or_else(Config::default);
let config = options.into_config(config);
// Update the log level from config.
@@ -121,9 +124,9 @@ fn main() {
fn run(window_event_loop: GlutinEventLoop<Event>, config: Config) -> Result<(), Box<dyn Error>> {
info!("Welcome to Alacritty");
- match &config.config_path {
- Some(config_path) => info!("Configuration loaded from \"{}\"", config_path.display()),
- None => info!("No configuration file found"),
+ info!("Configuration files loaded from:");
+ for path in &config.ui_config.config_paths {
+ info!(" \"{}\"", path.display());
}
// Set environment variables.
@@ -179,7 +182,7 @@ fn run(window_event_loop: GlutinEventLoop<Event>, config: Config) -> Result<(),
// The monitor watches the config file for changes and reloads it. Pending
// config changes are processed in the main loop.
if config.ui_config.live_config_reload() {
- config.config_path.as_ref().map(|path| Monitor::new(path, event_proxy.clone()));
+ monitor::watch(config.ui_config.config_paths.clone(), event_proxy);
}
// Setup storage for message UI.