diff --git a/.chezmoiexternal.toml b/.chezmoiexternal.toml.tmpl similarity index 67% rename from .chezmoiexternal.toml rename to .chezmoiexternal.toml.tmpl index 11d495d9..b526065e 100644 --- a/.chezmoiexternal.toml +++ b/.chezmoiexternal.toml.tmpl @@ -1,3 +1,5 @@ +{{- $nvmRelease := (gitHubLatestRelease "nvm-sh/nvm").TagName | toString -}} + [".local/share/nvim/site/autoload/plug.vim"] type = "file" url = "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" @@ -27,3 +29,19 @@ refreshPeriod = "168h" type = "file" url = "https://raw.githubusercontent.com/eza-community/eza-themes/refs/heads/main/themes/tokyonight.yml" refreshPeriod = "168h" + +[".nvm/nvm.sh"] +type = "file" +url = "https://raw.githubusercontent.com/nvm-sh/nvm/{{ $nvmRelease }}/nvm.sh" +refreshPeriod = "168h" + +[".nvm/nvm-exec"] +type = "file" +url = "https://raw.githubusercontent.com/nvm-sh/nvm/{{ $nvmRelease }}/nvm-exec" +executable = true +refreshPeriod = "168h" + +[".nvm/bash_completion"] +type = "file" +url = "https://raw.githubusercontent.com/nvm-sh/nvm/{{ $nvmRelease }}/bash_completion" +refreshPeriod = "168h" diff --git a/private_dot_local/share/zsh/scripts/nvm-lazy.zsh b/private_dot_local/share/zsh/scripts/nvm-lazy.zsh index 085f0909..b716676d 100644 --- a/private_dot_local/share/zsh/scripts/nvm-lazy.zsh +++ b/private_dot_local/share/zsh/scripts/nvm-lazy.zsh @@ -8,12 +8,9 @@ # - Minimal overhead: precmd detector only does file checks (no subshells) # - chpwd hook only active while in a project -# Requires BREW_HOME to be set -[[ -z "$BREW_HOME" ]] && return -[[ ! -f "$BREW_HOME/opt/nvm/nvm.sh" ]] && return - # Export NVM_DIR for nvm to work properly export NVM_DIR="$HOME/.nvm" +[[ ! -s "$NVM_DIR/nvm.sh" ]] && return # Find .nvmrc from current dir up to git root (or current dir only if not in git repo) _nvm_find_project_nvmrc() { @@ -49,7 +46,10 @@ _nvm_load() { unfunction nvm node npm npx 2>/dev/null # Load nvm - source "$BREW_HOME/opt/nvm/nvm.sh" + source "$NVM_DIR/nvm.sh" + if [[ -s "$NVM_DIR/bash_completion" ]]; then + source "$NVM_DIR/bash_completion" + fi } # Full hook - only active while in a project