From b25e86aebeb0d9351d6f18a2a6e6b62de9db1730 Mon Sep 17 00:00:00 2001 From: Tristan C Date: Thu, 20 Feb 2020 19:34:17 -0600 Subject: [PATCH] Modified 'setup_changed_listeners' for compatibility with neovim versions < 0.4.3 --- src/settings.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/settings.rs b/src/settings.rs index f8a1d70..08a6bdb 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -130,12 +130,16 @@ impl Settings { pub async fn setup_changed_listeners(&self, nvim: &Neovim>) { let keys : Vec = self.settings.lock().keys().cloned().collect(); for name in keys { - let vimscript = - format!("function NeovideNotify{}Changed(d, k, z)\n", name) + - &format!(" call rpcnotify(1, \"setting_changed\", \"{}\", g:neovide_{})\n", name, name) + - "endfunction\n" + - &format!("call dictwatcheradd(g:, \"neovide_{}\", \"NeovideNotify{}Changed\")", name, name); - nvim.exec(&vimscript, false).await + let vimscript = format!( + concat!( + "exe \"", + "fun! NeovideNotify{0}Changed(d, k, z)\n", + "call rpcnotify(1, 'setting_changed', '{0}', g:neovide_{0})\n", + "endf\n", + "call dictwatcheradd(g:, 'neovide_{0}', 'NeovideNotify{0}Changed')\"", + ) + , name); + nvim.command(&vimscript).await .unwrap_or_explained_panic(&format!("Could not setup setting notifier for {}", name)); } }