Add an option to force vim plug update (#795)
* Add an option to force vim plug update (fix #751) * Rustfmt * Update src/config.rs Co-authored-by: M*C*O <mcofficer@gmx.de> Co-authored-by: M*C*O <mcofficer@gmx.de>
This commit is contained in:
committed by
GitHub
parent
d002b1ab1a
commit
23c9908a6a
@@ -212,6 +212,12 @@ pub struct Composer {
|
|||||||
self_update: Option<bool>,
|
self_update: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Default, Debug)]
|
||||||
|
#[serde(deny_unknown_fields)]
|
||||||
|
pub struct Vim {
|
||||||
|
force_plug_update: Option<bool>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Default, Debug)]
|
#[derive(Deserialize, Default, Debug)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
/// Configuration file
|
/// Configuration file
|
||||||
@@ -244,6 +250,7 @@ pub struct ConfigFile {
|
|||||||
git: Option<Git>,
|
git: Option<Git>,
|
||||||
windows: Option<Windows>,
|
windows: Option<Windows>,
|
||||||
npm: Option<NPM>,
|
npm: Option<NPM>,
|
||||||
|
vim: Option<Vim>,
|
||||||
firmware: Option<Firmware>,
|
firmware: Option<Firmware>,
|
||||||
vagrant: Option<Vagrant>,
|
vagrant: Option<Vagrant>,
|
||||||
flatpak: Option<Flatpak>,
|
flatpak: Option<Flatpak>,
|
||||||
@@ -626,6 +633,15 @@ impl Config {
|
|||||||
.unwrap_or(false)
|
.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
|
/// Whether to send a desktop notification at the beginning of every step
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn notify_each_step(&self) -> bool {
|
pub fn notify_each_step(&self) -> bool {
|
||||||
|
|||||||
@@ -11,7 +11,11 @@ endif
|
|||||||
if exists(":PlugUpgrade")
|
if exists(":PlugUpgrade")
|
||||||
echo "Plug"
|
echo "Plug"
|
||||||
PlugUpgrade
|
PlugUpgrade
|
||||||
|
if $TOPGRADE_FORCE_PLUGUPDATE
|
||||||
|
PlugUpdate!
|
||||||
|
else
|
||||||
PlugUpdate
|
PlugUpdate
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if exists(":PackerUpdate")
|
if exists(":PackerUpdate")
|
||||||
|
|||||||
@@ -45,14 +45,19 @@ fn upgrade(vim: &Path, vimrc: &Path, ctx: &ExecutionContext) -> Result<()> {
|
|||||||
tempfile.write_all(UPGRADE_VIM.replace('\r', "").as_bytes())?;
|
tempfile.write_all(UPGRADE_VIM.replace('\r', "").as_bytes())?;
|
||||||
debug!("Wrote vim script to {:?}", tempfile.path());
|
debug!("Wrote vim script to {:?}", tempfile.path());
|
||||||
|
|
||||||
let output = ctx
|
let mut command = ctx.run_type().execute(&vim);
|
||||||
.run_type()
|
|
||||||
.execute(&vim)
|
command
|
||||||
.args(&["-u"])
|
.args(&["-u"])
|
||||||
.arg(vimrc)
|
.arg(vimrc)
|
||||||
.args(&["-U", "NONE", "-V1", "-nNesS"])
|
.args(&["-U", "NONE", "-V1", "-nNesS"])
|
||||||
.arg(tempfile.path())
|
.arg(tempfile.path());
|
||||||
.output()?;
|
|
||||||
|
if ctx.config().force_vim_plug_update() {
|
||||||
|
command.env("TOPGRADE_FORCE_PLUGUPDATE", "true");
|
||||||
|
}
|
||||||
|
|
||||||
|
let output = command.output()?;
|
||||||
|
|
||||||
if let ExecutorOutput::Wet(output) = output {
|
if let ExecutorOutput::Wet(output) = output {
|
||||||
let status = output.status;
|
let status = output.status;
|
||||||
|
|||||||
Reference in New Issue
Block a user