From 0f10f186e846c26f1e553a08dc5b0f982b225a1d Mon Sep 17 00:00:00 2001 From: keith Date: Sun, 16 Feb 2020 22:42:06 -0800 Subject: [PATCH] fix setting loading --- src/settings.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/settings.rs b/src/settings.rs index 6ddab99..ebdd7e1 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -7,6 +7,7 @@ use nvim_rs::compat::tokio::Compat; use flexi_logger::{Logger, Criterion, Naming, Cleanup}; use tokio::process::ChildStdin; use parking_lot::Mutex; +use log::warn; use crate::error_handling::ResultPanicExplanation; @@ -14,6 +15,7 @@ lazy_static! { pub static ref SETTINGS: Settings = Settings::new(); } +#[derive(Debug)] pub enum Setting { Bool(bool), U16(u16), @@ -113,12 +115,14 @@ impl Settings { pub async fn read_initial_values(&self, nvim: &Neovim>) { let keys : Vec= self.settings.lock().keys().cloned().collect(); for name in keys { - let variable_name = format!("g:neovide_{}", name.to_string()); - if let Ok(value) = nvim.get_var(&variable_name).await { - self.settings.lock().get_mut(&name).unwrap().parse(value); - } else { - let setting = self.get(&name); - nvim.set_var(&variable_name, setting.unparse()).await.ok(); + let variable_name = format!("neovide_{}", name.to_string()); + match nvim.get_var(&variable_name).await { + Ok(value) => self.settings.lock().get_mut(&name).unwrap().parse(value), + Err(error) => { + warn!("Initial value load failed for {}: {}", name, error); + let setting = self.get(&name); + nvim.set_var(&variable_name, setting.unparse()).await.ok(); + } } } } @@ -139,7 +143,6 @@ impl Settings { pub fn handle_changed_notification(&self, arguments: Vec) { let mut arguments = arguments.into_iter(); let (name, value) = (arguments.next().unwrap(), arguments.next().unwrap()); - dbg!(&name, &value); let name: Result= name.try_into(); let name = name.unwrap();