install.fairie/home/dot_local/bin/post-installx/executable_post-vim.sh

27 lines
1.2 KiB
Bash
Raw Normal View History

2024-05-04 21:05:33 -07:00
#!/usr/bin/env bash
# @file VIM Plugins AOT Installation
# @brief This script triggers VIM to pre-install plugins so that VIM loads into the desired state the first time it is invoked
2024-05-27 20:45:14 -07:00
set -Eeuo pipefail
2024-05-27 20:50:11 -07:00
trap "gum log -sl error 'Script encountered an error!'" ERR
2024-05-27 04:15:03 -07:00
2024-05-04 21:05:33 -07:00
# @description This script installs the extensions defined in `${XDG_CONFIG_HOME:-$HOME/.config}/coc/extensions/package.json`
# which should correlate to the Coc extensions defined in `${XDG_CONFIG_HOME:-$HOME/.config}/vim/vimrc`.
installCocExtensions() {
if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/coc/extensions/package.json" ]; then
2024-05-27 20:50:11 -07:00
gum log -sl info "Running npm i --no-progress --no-package-lock in ${XDG_CONFIG_HOME:-$HOME/.config}/coc/extensions"
2024-05-27 23:55:42 -07:00
cd "${XDG_CONFIG_HOME:-$HOME/.config}/coc/extensions"
npm i --no-progress --no-package-lock
gum log -sl info "Running vim +CocUpdateSync +qall"
vim +CocUpdateSync +qall
2024-05-04 21:05:33 -07:00
else
2024-05-27 20:50:11 -07:00
gum log -sl info "Skipping Coc extension installation because ${XDG_CONFIG_HOME:-$HOME/.config}/coc/extensions/package.json is missing"
2024-05-04 21:05:33 -07:00
fi
}
2024-05-27 23:55:42 -07:00
### Install VIM plugins
gum log -sl info "Installing VIM plugins" && vim +'PlugInstall --sync' +qall
### Install VIM coc plugins
2024-05-27 20:50:11 -07:00
gum log -sl info "Updating VIM coc extensions" && installCocExtensions