From e343c64d4eaf0751560934504754727fcd6dd9e6 Mon Sep 17 00:00:00 2001 From: mforsb Date: Tue, 10 Aug 2021 19:32:37 +0200 Subject: [PATCH] Simplify nvim version check, remove regex dependency Using `has("nvim-0.4")` check seems more robust than using a regex to parse the version string. This also means regex is no longer a runtime dependency. --- Cargo.toml | 1 - src/bridge/mod.rs | 12 ++++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 27af971..ab19e2d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,6 @@ futures = "0.3.12" glutin = { git = "https://github.com/Kethku/glutin", branch = "new-keyboard-all" } winit = { git = "https://github.com/Kethku/winit", branch = "new-keyboard-all", default-features = false } gl = "0.14.0" -regex = "1.5.4" swash = "0.1.4" clap="2.33.3" diff --git a/src/bridge/mod.rs b/src/bridge/mod.rs index 8db80b9..bf7c3e0 100644 --- a/src/bridge/mod.rs +++ b/src/bridge/mod.rs @@ -21,7 +21,6 @@ use crate::settings::*; use crate::{cmd_line::CmdLineSettings, error_handling::ResultPanicExplanation}; pub use events::*; use handler::NeovimHandler; -use regex::Regex; pub use tx_wrapper::{TxWrapper, WrapTx}; pub use ui_commands::UiCommand; @@ -188,16 +187,13 @@ async fn start_neovim_runtime( close_watcher_running.store(false, Ordering::Relaxed); }); - if let Ok(output) = nvim.command_output("version").await { - let re = Regex::new(r"NVIM v0.[4-9]\d*.\d+").unwrap(); - if !re.is_match(&output) { + match nvim.command_output("echo has('nvim-0.4')").await.as_deref() { + Ok("1") => {} // This is just a guard + _ => { error!("Neovide requires nvim version 0.4 or higher. Download the latest version here https://github.com/neovim/neovim/wiki/Installing-Neovim"); std::process::exit(0); } - } else { - error!("Neovide requires nvim version 0.4 or higher. Download the latest version here https://github.com/neovim/neovim/wiki/Installing-Neovim"); - std::process::exit(0); - }; + } nvim.set_var("neovide", Value::Boolean(true)) .await