refactor nvim bootstrap into nvim_run helper function

Extract repeated TERM=dumb/timeout/ANSI-stripping/pad boilerplate
into a reusable function. Each call now just specifies the wait time
and the nvim command to run.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Anton Volnuhin 2026-03-03 20:39:48 +03:00
parent 857aa4ff2e
commit 63c58c96be

View File

@ -444,12 +444,18 @@ cat ~/.ssh/authorized_keys.old <(echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPdqI
if [ "$SKIP_NVIM_BOOTSTRAP" -eq 0 ]; then if [ "$SKIP_NVIM_BOOTSTRAP" -eq 0 ]; then
new_line "Waiting for neovim plugins and lsm compilations..." new_line "Waiting for neovim plugins and lsm compilations..."
STRIP_ANSI="sed -e s/$(printf '\033')\[[0-9;]*[a-zA-Z]//g -e s/$(printf '\r')//g" nvim_run() {
TERM=dumb ${TIMEOUT_BIN:+$TIMEOUT_BIN 120s} nvim --headless -c "sleep 1" -c ":Lazy! sync" -c "sleep 10" -c "qa" 2>&1|$STRIP_ANSI|pad local wait=${1:-5}; shift
TERM=dumb ${TIMEOUT_BIN:+$TIMEOUT_BIN 120s} nvim --headless -c "sleep 1" -c ":lua pcall(vim.cmd, 'MasonUpdate')" -c "sleep 5" -c "qa" 2>&1|$STRIP_ANSI|pad TERM=dumb ${TIMEOUT_BIN:+$TIMEOUT_BIN 120s} nvim --headless \
TERM=dumb ${TIMEOUT_BIN:+$TIMEOUT_BIN 120s} nvim --headless -c "sleep 1" -c ":lua pcall(vim.cmd, 'MasonInstall lua-language-server')" -c "sleep 5" -c "qa" 2>&1|$STRIP_ANSI|pad -c "sleep 1" "$@" -c "sleep $wait" -c "qa" 2>&1 \
TERM=dumb ${TIMEOUT_BIN:+$TIMEOUT_BIN 120s} nvim --headless -c "sleep 1" -c ":lua pcall(vim.cmd, 'MasonInstall rust-analyzer')" -c "sleep 5" -c "qa" 2>&1|$STRIP_ANSI|pad | sed -e "s/$(printf '\033')\[[0-9;]*[a-zA-Z]//g" -e "s/$(printf '\r')//g" \
TERM=dumb ${TIMEOUT_BIN:+$TIMEOUT_BIN 120s} nvim --headless -c "sleep 1" -c ":TSUpdate" -c "sleep 5" -c "qa" 2>&1|$STRIP_ANSI|pad | pad
}
nvim_run 10 -c ":Lazy! sync"
nvim_run 5 -c ":lua pcall(vim.cmd, 'MasonUpdate')"
nvim_run 5 -c ":lua pcall(vim.cmd, 'MasonInstall lua-language-server')"
nvim_run 5 -c ":lua pcall(vim.cmd, 'MasonInstall rust-analyzer')"
nvim_run 5 -c ":TSUpdate"
fi fi
{{ if eq .chezmoi.os "linux" -}} {{ if eq .chezmoi.os "linux" -}}