From 6cceb58139dfb54135cd108850cf094179dbe43b Mon Sep 17 00:00:00 2001 From: Roey Darwish Dror Date: Thu, 7 Jun 2018 09:21:44 +0300 Subject: [PATCH] Fix vim breakage. Detect ~/.vim/vimrc as well --- src/main.rs | 5 ++--- src/vim.rs | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 9b2b88a2..8b1fef7b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -115,9 +115,8 @@ fn main() -> Result<(), Error> { } } - if let Ok(vim) = which("Vim") { - let vimrc = home_path(".vimrc"); - if vimrc.exists() { + if let Ok(vim) = which("vim") { + if let Some(vimrc) = vim::vimrc() { if let Some(plugin_framework) = vim::PluginFramework::detect(&vimrc) { terminal.print_separator(&format!("vim ({:?})", plugin_framework)); run_vim(&vim, &vimrc, plugin_framework.upgrade_command()) diff --git a/src/vim.rs b/src/vim.rs index 501f2cff..901ebee7 100644 --- a/src/vim.rs +++ b/src/vim.rs @@ -1,3 +1,4 @@ +use super::home_path; use std::fs; use std::path::PathBuf; @@ -31,3 +32,21 @@ impl PluginFramework { } } } + +pub fn vimrc() -> Option { + { + let vimrc = home_path(".vimrc"); + if vimrc.exists() { + return Some(vimrc); + } + } + + { + let vimrc = home_path(".vim/vimrc"); + if vimrc.exists() { + return Some(vimrc); + } + } + + None +}