Install Vim plugins by direct git clone instead of interactive :PluginInstall

Vundle's :PluginInstall hangs when stdout is not a TTY (e.g. automated
runs on Alpine). Clone each plugin declared in .vimrc directly instead
- unattended, idempotent, and skips the Vundle self-reference.
This commit is contained in:
2026-07-20 09:09:31 -03:00
parent 351631e7b4
commit d8d996a05c

View File

@@ -188,25 +188,43 @@ deploy_dotfiles() {
# Vim plugins via Vundle # Vim plugins via Vundle
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
install_vim_plugins() { install_vim_plugins() {
info "Installing Vim plugins (Vundle)" info "Installing Vim plugins"
if [ ! -f "$HOME/.vimrc" ]; then if [ ! -f "$HOME/.vimrc" ]; then
warn "No .vimrc deployed; skipping Vim plugin install." warn "No .vimrc deployed; skipping Vim plugin install."
return 0 return 0
fi fi
VUNDLE_DIR="$HOME/.vim/bundle/Vundle.vim" VUNDLE_DIR="$HOME/.vim/bundle/Vundle.vim"
if [ ! -d "$VUNDLE_DIR" ]; then if [ ! -d "$VUNDLE_DIR" ]; then
info "Cloning Vundle" info "Cloning Vundle"
run git clone --depth=1 https://github.com/VundleVim/Vundle.vim.git "$VUNDLE_DIR" run git clone --depth=1 https://github.com/VundleVim/Vundle.vim.git "$VUNDLE_DIR"
fi
info "Running :PluginInstall (idempotent)"
# Headless, tolerant of the 'dracula' colorscheme-not-found warning at startup.
if [ "$DRY_RUN" -eq 1 ]; then
printf ' $ vim +PluginInstall +qall\n'
else else
vim +PluginInstall +qall >/dev/null 2>&1 || \ ok "Vundle already present, skipping"
warn "Vim PluginInstall exited non-zero; verify with: vim +PluginInstall +qall"
fi fi
ok "Vim plugins installed"
# Rather than drive Vundle's interactive :PluginInstall (which hangs when
# stdout is not a TTY), clone each plugin declared in .vimrc directly.
# This is fully unattended and idempotent.
info "Cloning Vim plugins declared in .vimrc"
# Extract 'Plugin/Repo' and 'Plugin user/repo' style declarations,
# normalise to an https URL, skip the Vundle self-reference.
plugins=$(grep -oE "Plugin '[^']+'" "$HOME/.vimrc" \
| sed -E "s/Plugin '//; s/'//" \
| grep -v "^VundleVim/Vundle.vim$")
for repo in $plugins; do
name=$(basename "$repo")
dir="$HOME/.vim/bundle/$name"
if [ -d "$dir" ]; then
ok "$name already present, skipping"
continue
fi
info "Cloning $repo"
if run git clone --depth=1 "https://github.com/$repo.git" "$dir"; then
ok "$name installed"
else
warn "Failed to clone $repo (non-fatal)."
fi
done
} }
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------