Diff
1diff --git a/plugins/nvm/README.md b/plugins/nvm/README.md
2index 6830c14d0529eb6e8abd1f16f8199fed6ce672a7..eee3bf71782687d6ae5a3cf974a6c32aa02715f0 100644
3--- a/plugins/nvm/README.md
4+++ b/plugins/nvm/README.md
5@@ -43,6 +43,9 @@ zstyle ':omz:plugins:nvm' lazy-cmd eslint prettier typescript ...
6
7 #### `.nvmrc` autoload
8
9+Note: _this option cannot be used at the same time as `lazy`. `autoload` will override it and load `nvm` at
10+startup._
11+
12 If set, the plugin will automatically load a node version when if finds a
13 [`.nvmrc` file](https://github.com/nvm-sh/nvm#nvmrc) in the current working directory indicating which node
14 version to load. This can be done, similar as previous options, adding:
15diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh
16index 943678f7a669aab6caa7c3246ab90d2d22c42ab7..484ef296486969ddd40e642fed2d587c16d43b20 100644
17--- a/plugins/nvm/nvm.plugin.zsh
18+++ b/plugins/nvm/nvm.plugin.zsh
19@@ -16,7 +16,18 @@ fi
20 # Note: nvm is a function so we need to use `which`
21 which nvm &>/dev/null && return
22
23-if zstyle -t ':omz:plugins:nvm' lazy; then
24+if [[ -z "$NVM_DIR" ]]; then
25+ echo "[oh-my-zsh] nvm installation cannot be found"
26+ echo "[oh-my-zsh] set NVM_DIR to your installation"
27+ return
28+fi
29+if [[ ! -f "$NVM_DIR/nvm.sh" ]]; then
30+ echo "[oh-my-zsh] nvm.sh does not exist in $NVM_DIR"
31+ return
32+fi
33+
34+if zstyle -t ':omz:plugins:nvm' lazy && \
35+ ! zstyle -t ':omz:plugins:nvm' autoload; then
36 # Call nvm when first using nvm, node, npm, pnpm, yarn or other commands in lazy-cmd
37 zstyle -a ':omz:plugins:nvm' lazy-cmd nvm_lazy_cmd
38 eval "
39@@ -28,11 +39,8 @@ if zstyle -t ':omz:plugins:nvm' lazy; then
40 }
41 "
42 unset nvm_lazy_cmd
43-elif [[ -f "$NVM_DIR/nvm.sh" ]]; then
44- # Load nvm if it exists in $NVM_DIR
45- source "$NVM_DIR/nvm.sh"
46 else
47- return
48+ source "$NVM_DIR/nvm.sh"
49 fi
50
51 # Autoload nvm when finding a .nvmrc file in the current directory