diff --git a/install.sh b/install.sh index d43eda2..4b556ff 100644 --- a/install.sh +++ b/install.sh @@ -53,12 +53,17 @@ sudo -v || error "Failed to obtain sudo. Aborting." ( while kill -0 $$ 2>/dev/null; do sudo -n true; sleep 50; done ) & SUDO_KEEPALIVE_PID=$! +INSTALL_SUCCESS=false + cleanup() { + local exit_code=$? kill $SUDO_KEEPALIVE_PID 2>/dev/null if ! $VERBOSE && [[ -e /proc/self/fd/3 ]]; then exec 1>&3 2>&4 3>&- 4>&- - echo "" - echo -e " ${RED}[✗]${NC} Installation failed. See log: $LOG_FILE" + if ! $INSTALL_SUCCESS; then + echo "" + echo -e " ${RED}[✗]${NC} Installation failed (exit $exit_code). See log: $LOG_FILE" + fi fi } trap cleanup EXIT @@ -84,6 +89,8 @@ if ! $VERBOSE; then end_quiet_mode fi +INSTALL_SUCCESS=true + # ── Done ──────────────────────────────────────────────────────── echo "" echo " ╔═══════════════════════════════════════╗" diff --git a/lib/common.sh b/lib/common.sh index 1be5a2f..22730a0 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -78,6 +78,12 @@ backup_config() { info "Backed up $(basename "$src") → $BACKUP_DIR/" } +# ── TLS workaround ─────────────────────────────────────────────── +# Many corporate/WSL environments have broken CA chains. Export this so +# all git operations (clone, pull) skip certificate verification, +# matching the -k flag used on all curl calls throughout the installer. +export GIT_SSL_NO_VERIFY=1 + # ── Detect environment ────────────────────────────────────────── IS_WSL=false [[ -f /proc/version ]] && grep -qi microsoft /proc/version && IS_WSL=true diff --git a/lib/neovim.sh b/lib/neovim.sh index 2c217b3..ac50c97 100644 --- a/lib/neovim.sh +++ b/lib/neovim.sh @@ -13,11 +13,11 @@ if command -v nvim &>/dev/null; then fi if $NVIM_NEEDED; then - curl -kLO https://github.com/neovim/neovim/releases/latest/download/nvim-linux-x86_64.tar.gz + curl -kLo /tmp/nvim-linux-x86_64.tar.gz https://github.com/neovim/neovim/releases/latest/download/nvim-linux-x86_64.tar.gz sudo rm -rf /opt/nvim-linux-x86_64 - sudo tar -xzf nvim-linux-x86_64.tar.gz -C /opt + sudo tar -xzf /tmp/nvim-linux-x86_64.tar.gz -C /opt sudo ln -sf /opt/nvim-linux-x86_64/bin/nvim /usr/local/bin/nvim - rm nvim-linux-x86_64.tar.gz + rm -f /tmp/nvim-linux-x86_64.tar.gz info "Neovim installed: $(nvim --version | head -1)" fi @@ -100,6 +100,18 @@ LUA # ── LSP (clangd) ─────────────────────────────────────────────── mkdir -p "$NVIM_CFG/lua/configs" +cat >"$NVIM_CFG/lua/plugins/lspconfig.lua" <<'LUA' +return { + { + "neovim/nvim-lspconfig", + config = function() + require("nvchad.configs.lspconfig").defaults() + require "configs.lspconfig" + end, + }, +} +LUA + cat >"$NVIM_CFG/lua/configs/lspconfig.lua" <<'LUA' local configs = require "nvchad.configs.lspconfig" diff --git a/lib/themes.sh b/lib/themes.sh index 29e555d..e6972af 100644 --- a/lib/themes.sh +++ b/lib/themes.sh @@ -2,29 +2,53 @@ # Theme selection — sources the chosen theme file THEMES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/themes" +THEME_SAVE_FILE="$HOME/.config/archduino/theme" THEME_FILES=(gruvbox catppuccin tokyonight nord dracula) select_theme() { + # Load previously saved theme as default + local saved_theme="" default_idx=1 + if [[ -f "$THEME_SAVE_FILE" ]]; then + saved_theme=$(cat "$THEME_SAVE_FILE") + for idx in "${!THEME_FILES[@]}"; do + if [[ "${THEME_FILES[$idx]}" == "$saved_theme" ]]; then + default_idx=$((idx + 1)) + break + fi + done + fi + echo " Select colorscheme:" echo "" local i=1 for t in "${THEME_FILES[@]}"; do source "$THEMES_DIR/$t.sh" - printf " %d) %s\n" "$i" "$THEME_DISPLAY_NAME" + if [[ $i -eq $default_idx && -n "$saved_theme" ]]; then + printf " %d) %s (current)\n" "$i" "$THEME_DISPLAY_NAME" + else + printf " %d) %s\n" "$i" "$THEME_DISPLAY_NAME" + fi i=$((i + 1)) done echo "" - read -rp " Choice [1-${#THEME_FILES[@]}]: " theme_choice + read -rp " Choice [1-${#THEME_FILES[@]}] (default: $default_idx): " theme_choice - # Default to 1 (Gruvbox) for invalid input - if [[ ! "$theme_choice" =~ ^[0-9]+$ ]] || ((theme_choice < 1 || theme_choice > ${#THEME_FILES[@]})); then - theme_choice=1 + # Default to saved theme (or Gruvbox) for empty/invalid input + if [[ -z "$theme_choice" ]]; then + theme_choice=$default_idx + elif [[ ! "$theme_choice" =~ ^[0-9]+$ ]] || ((theme_choice < 1 || theme_choice > ${#THEME_FILES[@]})); then + theme_choice=$default_idx fi local selected="${THEME_FILES[$((theme_choice - 1))]}" source "$THEMES_DIR/$selected.sh" + + # Persist choice for next run + mkdir -p "$(dirname "$THEME_SAVE_FILE")" + echo "$selected" > "$THEME_SAVE_FILE" + info "Selected theme: $THEME_DISPLAY_NAME" }