From 42b6bdcd64a8974ae82ad0b3023b4ca14c8a84e5 Mon Sep 17 00:00:00 2001 From: daa84 Date: Fri, 13 Oct 2017 13:16:52 +0300 Subject: [PATCH] Disable swap files In case neovim ends unexpected on next start - neovim ask user for recovery but gui have not access to this event. So temprorary disable this. Also do some improvemnt, so error message can be shown to user on nvim start errors --- src/error.rs | 4 +--- src/nvim.rs | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/error.rs b/src/error.rs index de58f88..4fdb47f 100644 --- a/src/error.rs +++ b/src/error.rs @@ -34,9 +34,7 @@ impl ErrorArea { {}\n\n\ Possible error reasons:\n\ ● Not supported nvim version (minimum supported version is {})\n\ - ● Error in configuration file (init.vim or ginit.vim)\n\ - ● Wrong nvim binary path \ - (right path can be passed with --nvim-bin-path=path_here)", + ● Error in configuration file (init.vim or ginit.vim)", encode_minimal(err), shell::MINIMUM_SUPPORTED_NVIM_VERSION)); self.base.show_all(); } diff --git a/src/nvim.rs b/src/nvim.rs index c209dd0..d9287bc 100644 --- a/src/nvim.rs +++ b/src/nvim.rs @@ -236,6 +236,8 @@ pub fn start( cmd.arg("--embed") .arg("--headless") + // Swap files are disabled because it shows message window on start up but frontend can't detect it. + .arg("-n") .arg("--cmd") .arg("set termguicolors") .arg("--cmd") @@ -388,15 +390,19 @@ fn call_gui_event( match try_str!(args[0]) { "Popupmenu" => { ui.nvim() - .unwrap() - .set_option(UiOption::ExtPopupmenu(try_uint!(args[1]) == 1)) - .map_err(|e| e.to_string())? + .ok_or_else(|| "Nvim not initialized".to_owned()) + .and_then(|mut nvim| { + nvim.set_option(UiOption::ExtPopupmenu(try_uint!(args[1]) == 1)) + .map_err(|e| e.to_string()) + })? } "Tabline" => { ui.nvim() - .unwrap() - .set_option(UiOption::ExtTabline(try_uint!(args[1]) == 1)) - .map_err(|e| e.to_string())? + .ok_or_else(|| "Nvim not initialized".to_owned()) + .and_then(|mut nvim| { + nvim.set_option(UiOption::ExtTabline(try_uint!(args[1]) == 1)) + .map_err(|e| e.to_string()) + })? } opt => error!("Unknown option {}", opt), }