|
|
@ -7,6 +7,7 @@ use nvim_rs::compat::tokio::Compat;
|
|
|
|
use flexi_logger::{Logger, Criterion, Naming, Cleanup};
|
|
|
|
use flexi_logger::{Logger, Criterion, Naming, Cleanup};
|
|
|
|
use tokio::process::ChildStdin;
|
|
|
|
use tokio::process::ChildStdin;
|
|
|
|
use parking_lot::Mutex;
|
|
|
|
use parking_lot::Mutex;
|
|
|
|
|
|
|
|
use log::warn;
|
|
|
|
|
|
|
|
|
|
|
|
use crate::error_handling::ResultPanicExplanation;
|
|
|
|
use crate::error_handling::ResultPanicExplanation;
|
|
|
|
|
|
|
|
|
|
|
@ -14,6 +15,7 @@ lazy_static! {
|
|
|
|
pub static ref SETTINGS: Settings = Settings::new();
|
|
|
|
pub static ref SETTINGS: Settings = Settings::new();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum Setting {
|
|
|
|
pub enum Setting {
|
|
|
|
Bool(bool),
|
|
|
|
Bool(bool),
|
|
|
|
U16(u16),
|
|
|
|
U16(u16),
|
|
|
@ -113,12 +115,14 @@ impl Settings {
|
|
|
|
pub async fn read_initial_values(&self, nvim: &Neovim<Compat<ChildStdin>>) {
|
|
|
|
pub async fn read_initial_values(&self, nvim: &Neovim<Compat<ChildStdin>>) {
|
|
|
|
let keys : Vec<String>= self.settings.lock().keys().cloned().collect();
|
|
|
|
let keys : Vec<String>= self.settings.lock().keys().cloned().collect();
|
|
|
|
for name in keys {
|
|
|
|
for name in keys {
|
|
|
|
let variable_name = format!("g:neovide_{}", name.to_string());
|
|
|
|
let variable_name = format!("neovide_{}", name.to_string());
|
|
|
|
if let Ok(value) = nvim.get_var(&variable_name).await {
|
|
|
|
match nvim.get_var(&variable_name).await {
|
|
|
|
self.settings.lock().get_mut(&name).unwrap().parse(value);
|
|
|
|
Ok(value) => self.settings.lock().get_mut(&name).unwrap().parse(value),
|
|
|
|
} else {
|
|
|
|
Err(error) => {
|
|
|
|
let setting = self.get(&name);
|
|
|
|
warn!("Initial value load failed for {}: {}", name, error);
|
|
|
|
nvim.set_var(&variable_name, setting.unparse()).await.ok();
|
|
|
|
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<Value>) {
|
|
|
|
pub fn handle_changed_notification(&self, arguments: Vec<Value>) {
|
|
|
|
let mut arguments = arguments.into_iter();
|
|
|
|
let mut arguments = arguments.into_iter();
|
|
|
|
let (name, value) = (arguments.next().unwrap(), arguments.next().unwrap());
|
|
|
|
let (name, value) = (arguments.next().unwrap(), arguments.next().unwrap());
|
|
|
|
dbg!(&name, &value);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let name: Result<String, _>= name.try_into();
|
|
|
|
let name: Result<String, _>= name.try_into();
|
|
|
|
let name = name.unwrap();
|
|
|
|
let name = name.unwrap();
|
|
|
|