Fix neovim upgrade (#77)
This commit is contained in:
@@ -18,11 +18,6 @@ if exists(":PlugUpgrade")
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if exists(":PackerUpdate")
|
|
||||||
echo "Packer"
|
|
||||||
PackerSync
|
|
||||||
endif
|
|
||||||
|
|
||||||
if exists("*dein#update()")
|
if exists("*dein#update()")
|
||||||
echo "dein#update()"
|
echo "dein#update()"
|
||||||
call dein#update()
|
call dein#update()
|
||||||
@@ -43,4 +38,10 @@ if exists(":CocUpdateSync")
|
|||||||
CocUpdateSync
|
CocUpdateSync
|
||||||
endif
|
endif
|
||||||
|
|
||||||
quitall
|
if exists(':PackerSync')
|
||||||
|
echo "Packer"
|
||||||
|
autocmd User PackerComplete quitall
|
||||||
|
PackerSync
|
||||||
|
else
|
||||||
|
quitall
|
||||||
|
endif
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use crate::error::{SkipStep, TopgradeError};
|
use crate::error::{SkipStep, TopgradeError};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
use crate::executor::{CommandExt, ExecutorOutput, RunType};
|
use crate::executor::{CommandExt, Executor, ExecutorOutput, RunType};
|
||||||
use crate::terminal::print_separator;
|
use crate::terminal::print_separator;
|
||||||
use crate::{
|
use crate::{
|
||||||
execution_context::ExecutionContext,
|
execution_context::ExecutionContext,
|
||||||
@@ -9,7 +9,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use directories::BaseDirs;
|
use directories::BaseDirs;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::PathBuf;
|
||||||
use std::{
|
use std::{
|
||||||
io::{self, Write},
|
io::{self, Write},
|
||||||
process::Command,
|
process::Command,
|
||||||
@@ -40,19 +40,14 @@ fn nvimrc(base_dirs: &BaseDirs) -> Result<PathBuf> {
|
|||||||
.or_else(|_| base_dir.join("nvim/init.lua").require())
|
.or_else(|_| base_dir.join("nvim/init.lua").require())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn upgrade(vim: &Path, vimrc: &Path, ctx: &ExecutionContext) -> Result<()> {
|
fn upgrade_script() -> Result<tempfile::NamedTempFile> {
|
||||||
let mut tempfile = tempfile::NamedTempFile::new()?;
|
let mut tempfile = tempfile::NamedTempFile::new()?;
|
||||||
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());
|
||||||
|
Ok(tempfile)
|
||||||
|
}
|
||||||
|
|
||||||
let mut command = ctx.run_type().execute(vim);
|
fn upgrade(command: &mut Executor, ctx: &ExecutionContext) -> Result<()> {
|
||||||
|
|
||||||
command
|
|
||||||
.args(["-u"])
|
|
||||||
.arg(vimrc)
|
|
||||||
.args(["-U", "NONE", "-V1", "-nNesS"])
|
|
||||||
.arg(tempfile.path());
|
|
||||||
|
|
||||||
if ctx.config().force_vim_plug_update() {
|
if ctx.config().force_vim_plug_update() {
|
||||||
command.env("TOPGRADE_FORCE_PLUGUPDATE", "true");
|
command.env("TOPGRADE_FORCE_PLUGUPDATE", "true");
|
||||||
}
|
}
|
||||||
@@ -114,13 +109,21 @@ pub fn upgrade_vim(base_dirs: &BaseDirs, ctx: &ExecutionContext) -> Result<()> {
|
|||||||
|
|
||||||
let output = Command::new(&vim).arg("--version").check_output()?;
|
let output = Command::new(&vim).arg("--version").check_output()?;
|
||||||
if !output.starts_with("VIM") {
|
if !output.starts_with("VIM") {
|
||||||
return Err(SkipStep(String::from("vim binary might by actually nvim")).into());
|
return Err(SkipStep(String::from("vim binary might be actually nvim")).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
let vimrc = vimrc(base_dirs)?;
|
let vimrc = vimrc(base_dirs)?;
|
||||||
|
|
||||||
print_separator("Vim");
|
print_separator("Vim");
|
||||||
upgrade(&vim, &vimrc, ctx)
|
upgrade(
|
||||||
|
ctx.run_type()
|
||||||
|
.execute(&vim)
|
||||||
|
.args(&["-u"])
|
||||||
|
.arg(vimrc)
|
||||||
|
.args(&["-U", "NONE", "-V1", "-nNesS"])
|
||||||
|
.arg(upgrade_script()?.path()),
|
||||||
|
ctx,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn upgrade_neovim(base_dirs: &BaseDirs, ctx: &ExecutionContext) -> Result<()> {
|
pub fn upgrade_neovim(base_dirs: &BaseDirs, ctx: &ExecutionContext) -> Result<()> {
|
||||||
@@ -128,7 +131,15 @@ pub fn upgrade_neovim(base_dirs: &BaseDirs, ctx: &ExecutionContext) -> Result<()
|
|||||||
let nvimrc = nvimrc(base_dirs)?;
|
let nvimrc = nvimrc(base_dirs)?;
|
||||||
|
|
||||||
print_separator("Neovim");
|
print_separator("Neovim");
|
||||||
upgrade(&nvim, &nvimrc, ctx)
|
upgrade(
|
||||||
|
ctx.run_type()
|
||||||
|
.execute(&nvim)
|
||||||
|
.args(&["-u"])
|
||||||
|
.arg(nvimrc)
|
||||||
|
.args(&["--headless", "-V1", "-nS"])
|
||||||
|
.arg(upgrade_script()?.path()),
|
||||||
|
ctx,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_voom(_base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
|
pub fn run_voom(_base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
|
||||||
|
|||||||
Reference in New Issue
Block a user