[📦 NEW] PlugClean for vim on cleanup (#259)
This commit is contained in:
committed by
Roey Darwish Dror
parent
f506d52309
commit
cda1363b6d
@@ -260,7 +260,6 @@ impl Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Tell whether we should perform cleanup steps.
|
/// Tell whether we should perform cleanup steps.
|
||||||
#[cfg(not(windows))]
|
|
||||||
pub fn cleanup(&self) -> bool {
|
pub fn cleanup(&self) -> bool {
|
||||||
self.opt.cleanup || self.config_file.cleanup.unwrap_or(false)
|
self.opt.cleanup || self.config_file.cleanup.unwrap_or(false)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -415,13 +415,13 @@ fn run() -> Result<(), Error> {
|
|||||||
execute(
|
execute(
|
||||||
&mut report,
|
&mut report,
|
||||||
"vim",
|
"vim",
|
||||||
|| vim::upgrade_vim(&base_dirs, run_type),
|
|| vim::upgrade_vim(&base_dirs, run_type, config.cleanup()),
|
||||||
config.no_retry(),
|
config.no_retry(),
|
||||||
)?;
|
)?;
|
||||||
execute(
|
execute(
|
||||||
&mut report,
|
&mut report,
|
||||||
"Neovim",
|
"Neovim",
|
||||||
|| vim::upgrade_neovim(&base_dirs, run_type),
|
|| vim::upgrade_neovim(&base_dirs, run_type, config.cleanup()),
|
||||||
config.no_retry(),
|
config.no_retry(),
|
||||||
)?;
|
)?;
|
||||||
execute(
|
execute(
|
||||||
|
|||||||
@@ -35,11 +35,17 @@ impl PluginFramework {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn upgrade_command(self) -> &'static str {
|
pub fn upgrade_command(self, cleanup: bool) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
PluginFramework::NeoBundle => "NeoBundleUpdate",
|
PluginFramework::NeoBundle => "NeoBundleUpdate",
|
||||||
PluginFramework::Vundle => "PluginUpdate",
|
PluginFramework::Vundle => "PluginUpdate",
|
||||||
PluginFramework::Plug => "PlugUpgrade | PlugUpdate",
|
PluginFramework::Plug => {
|
||||||
|
if cleanup {
|
||||||
|
"PlugUpgrade | PlugClean | PlugUpdate"
|
||||||
|
} else {
|
||||||
|
"PlugUpgrade | PlugUpdate"
|
||||||
|
}
|
||||||
|
}
|
||||||
PluginFramework::Dein => "call dein#install() | call dein#update()",
|
PluginFramework::Dein => "call dein#install() | call dein#update()",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,14 +68,20 @@ fn nvimrc(base_dirs: &BaseDirs) -> Option<PathBuf> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
fn upgrade(vim: &PathBuf, vimrc: &PathBuf, plugin_framework: PluginFramework, run_type: RunType) -> Result<(), Error> {
|
fn upgrade(
|
||||||
|
vim: &PathBuf,
|
||||||
|
vimrc: &PathBuf,
|
||||||
|
plugin_framework: PluginFramework,
|
||||||
|
run_type: RunType,
|
||||||
|
cleanup: bool,
|
||||||
|
) -> Result<(), Error> {
|
||||||
let output = run_type
|
let output = run_type
|
||||||
.execute(&vim)
|
.execute(&vim)
|
||||||
.args(&["-N", "-u"])
|
.args(&["-N", "-u"])
|
||||||
.arg(vimrc)
|
.arg(vimrc)
|
||||||
.args(&[
|
.args(&[
|
||||||
"-c",
|
"-c",
|
||||||
plugin_framework.upgrade_command(),
|
plugin_framework.upgrade_command(cleanup),
|
||||||
"-c",
|
"-c",
|
||||||
"quitall",
|
"quitall",
|
||||||
"-e",
|
"-e",
|
||||||
@@ -93,7 +105,7 @@ fn upgrade(vim: &PathBuf, vimrc: &PathBuf, plugin_framework: PluginFramework, ru
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn upgrade_vim(base_dirs: &BaseDirs, run_type: RunType) -> Result<(), Error> {
|
pub fn upgrade_vim(base_dirs: &BaseDirs, run_type: RunType, cleanup: bool) -> Result<(), Error> {
|
||||||
let vim = require("vim")?;
|
let vim = require("vim")?;
|
||||||
|
|
||||||
let output = Command::new(&vim).arg("--version").check_output()?;
|
let output = Command::new(&vim).arg("--version").check_output()?;
|
||||||
@@ -105,17 +117,17 @@ pub fn upgrade_vim(base_dirs: &BaseDirs, run_type: RunType) -> Result<(), Error>
|
|||||||
let plugin_framework = require_option(PluginFramework::detect(&vimrc))?;
|
let plugin_framework = require_option(PluginFramework::detect(&vimrc))?;
|
||||||
|
|
||||||
print_separator(&format!("Vim ({:?})", plugin_framework));
|
print_separator(&format!("Vim ({:?})", plugin_framework));
|
||||||
upgrade(&vim, &vimrc, plugin_framework, run_type)
|
upgrade(&vim, &vimrc, plugin_framework, run_type, cleanup)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn upgrade_neovim(base_dirs: &BaseDirs, run_type: RunType) -> Result<(), Error> {
|
pub fn upgrade_neovim(base_dirs: &BaseDirs, run_type: RunType, cleanup: bool) -> Result<(), Error> {
|
||||||
let nvim = require("nvim")?;
|
let nvim = require("nvim")?;
|
||||||
let nvimrc = require_option(nvimrc(&base_dirs))?;
|
let nvimrc = require_option(nvimrc(&base_dirs))?;
|
||||||
let plugin_framework = require_option(PluginFramework::detect(&nvimrc))?;
|
let plugin_framework = require_option(PluginFramework::detect(&nvimrc))?;
|
||||||
|
|
||||||
print_separator(&format!("Neovim ({:?})", plugin_framework));
|
print_separator(&format!("Neovim ({:?})", plugin_framework));
|
||||||
upgrade(&nvim, &nvimrc, plugin_framework, run_type)
|
upgrade(&nvim, &nvimrc, plugin_framework, run_type, cleanup)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_voom(_base_dirs: &BaseDirs, run_type: RunType) -> Result<(), Error> {
|
pub fn run_voom(_base_dirs: &BaseDirs, run_type: RunType) -> Result<(), Error> {
|
||||||
|
|||||||
Reference in New Issue
Block a user