diff --git a/src/config.rs b/src/config.rs index 556feada..f201ea94 100644 --- a/src/config.rs +++ b/src/config.rs @@ -212,6 +212,12 @@ pub struct Composer { self_update: Option, } +#[derive(Deserialize, Default, Debug)] +#[serde(deny_unknown_fields)] +pub struct Vim { + force_plug_update: Option, +} + #[derive(Deserialize, Default, Debug)] #[serde(deny_unknown_fields)] /// Configuration file @@ -244,6 +250,7 @@ pub struct ConfigFile { git: Option, windows: Option, npm: Option, + vim: Option, firmware: Option, vagrant: Option, flatpak: Option, @@ -626,6 +633,15 @@ impl Config { .unwrap_or(false) } + /// Whether to force plug update in Vim + pub fn force_vim_plug_update(&self) -> bool { + self.config_file + .vim + .as_ref() + .and_then(|c| c.force_plug_update) + .unwrap_or_default() + } + /// Whether to send a desktop notification at the beginning of every step #[allow(dead_code)] pub fn notify_each_step(&self) -> bool { diff --git a/src/steps/upgrade.vim b/src/steps/upgrade.vim index 481735e5..3eb89d54 100644 --- a/src/steps/upgrade.vim +++ b/src/steps/upgrade.vim @@ -11,7 +11,11 @@ endif if exists(":PlugUpgrade") echo "Plug" PlugUpgrade - PlugUpdate + if $TOPGRADE_FORCE_PLUGUPDATE + PlugUpdate! + else + PlugUpdate + endif endif if exists(":PackerUpdate") diff --git a/src/steps/vim.rs b/src/steps/vim.rs index 43ff6834..ce47221c 100644 --- a/src/steps/vim.rs +++ b/src/steps/vim.rs @@ -27,7 +27,7 @@ pub fn vimrc(base_dirs: &BaseDirs) -> Result { fn nvimrc(base_dirs: &BaseDirs) -> Result { #[cfg(unix)] - let base_dir = + let base_dir = // Bypass directories crate as nvim doesn't use the macOS-specific directories. std::env::var_os("XDG_CONFIG_HOME").map_or_else(|| base_dirs.home_dir().join(".config"), PathBuf::from); @@ -45,14 +45,19 @@ fn upgrade(vim: &Path, vimrc: &Path, ctx: &ExecutionContext) -> Result<()> { tempfile.write_all(UPGRADE_VIM.replace('\r', "").as_bytes())?; debug!("Wrote vim script to {:?}", tempfile.path()); - let output = ctx - .run_type() - .execute(&vim) + let mut command = ctx.run_type().execute(&vim); + + command .args(&["-u"]) .arg(vimrc) .args(&["-U", "NONE", "-V1", "-nNesS"]) - .arg(tempfile.path()) - .output()?; + .arg(tempfile.path()); + + if ctx.config().force_vim_plug_update() { + command.env("TOPGRADE_FORCE_PLUGUPDATE", "true"); + } + + let output = command.output()?; if let ExecutorOutput::Wet(output) = output { let status = output.status;