From 94aa49c0b96fed98d2751107301c16f32de13383 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Mon, 4 Mar 2024 11:02:37 +0100 Subject: feat(nvm)!: make `lazy` and `autoload` options compatible BREAKING CHANGE: Prior to this commit, if `lazy` and `autoload` options were enabled at the same time, `lazy` was getting overriden and only `autoload` was taken into account. Now they work together and `autoload` will be enabled after `nvm` has been lazy-loaded. Closes #11690 --- plugins/nvm/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'plugins/nvm/README.md') diff --git a/plugins/nvm/README.md b/plugins/nvm/README.md index b5ef221d3..e88ce0158 100644 --- a/plugins/nvm/README.md +++ b/plugins/nvm/README.md @@ -43,8 +43,7 @@ zstyle ':omz:plugins:nvm' lazy-cmd eslint prettier typescript ... #### `.nvmrc` autoload -Note: _this option cannot be used at the same time as `lazy`. `autoload` will override it and load `nvm` at -startup._ +Note: _if used at the same time as `lazy`, `autoload` will start working only after nvm has been lazy-loaded_ If set, the plugin will automatically load a node version when if finds a [`.nvmrc` file](https://github.com/nvm-sh/nvm#nvmrc) in the current working directory indicating which node -- cgit v1.2.3-70-g09d2 From 8c5f64cc2f0e75399a1e906e39713ed25b65ece1 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Mon, 6 May 2024 09:49:21 +0200 Subject: feat(nvm): add `corepack` to `lazy_cmd` --- plugins/nvm/README.md | 6 +++--- plugins/nvm/nvm.plugin.zsh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'plugins/nvm/README.md') diff --git a/plugins/nvm/README.md b/plugins/nvm/README.md index e88ce0158..eb1e236ee 100644 --- a/plugins/nvm/README.md +++ b/plugins/nvm/README.md @@ -26,9 +26,9 @@ These settings should go in your zshrc file, before Oh My Zsh is sourced: #### Lazy startup This option will help you to defer nvm's load until you use it to speed-up your zsh startup. This will source -nvm script only when using it, and will create a function for `node`, `npm`, `npx`, `pnpm`, `yarn`, and the -command(s) specified by `lazy-cmd` option, so when you call either of them, nvm will be loaded and run with -default version. To enable it, you can add this snippet to your zshrc, before Oh My Zsh is sourced: +nvm script only when using it, and will create a function for `node`, `npm`, `npx`, `pnpm`, `yarn`, `corepack` +and the command(s) specified by `lazy-cmd` option, so when you call either of them, nvm will be loaded and run +with default version. To enable it, you can add this snippet to your zshrc, before Oh My Zsh is sourced: ```zsh zstyle ':omz:plugins:nvm' lazy yes diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh index c2e8de94b..95c94030a 100644 --- a/plugins/nvm/nvm.plugin.zsh +++ b/plugins/nvm/nvm.plugin.zsh @@ -72,9 +72,9 @@ function _omz_setup_autoload { } if zstyle -t ':omz:plugins:nvm' lazy; then - # Call nvm when first using nvm, node, npm, pnpm, yarn or other commands in lazy-cmd + # Call nvm when first using nvm, node, npm, pnpm, yarn, corepack or other commands in lazy-cmd zstyle -a ':omz:plugins:nvm' lazy-cmd nvm_lazy_cmd - nvm_lazy_cmd=(nvm node npm npx pnpm yarn $nvm_lazy_cmd) # default values + nvm_lazy_cmd=(nvm node npm npx pnpm yarn corepack $nvm_lazy_cmd) # default values eval " function $nvm_lazy_cmd { for func in $nvm_lazy_cmd; do -- cgit v1.2.3-70-g09d2 From a3dfe290363c5f0ac6add41a1126d7c842a4d7c4 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Wed, 28 Aug 2024 10:34:25 +0200 Subject: feat(nvm): add `pnpx` as lazy cmd --- plugins/nvm/README.md | 7 ++++--- plugins/nvm/nvm.plugin.zsh | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'plugins/nvm/README.md') diff --git a/plugins/nvm/README.md b/plugins/nvm/README.md index eb1e236ee..fe91cc3b2 100644 --- a/plugins/nvm/README.md +++ b/plugins/nvm/README.md @@ -26,9 +26,10 @@ These settings should go in your zshrc file, before Oh My Zsh is sourced: #### Lazy startup This option will help you to defer nvm's load until you use it to speed-up your zsh startup. This will source -nvm script only when using it, and will create a function for `node`, `npm`, `npx`, `pnpm`, `yarn`, `corepack` -and the command(s) specified by `lazy-cmd` option, so when you call either of them, nvm will be loaded and run -with default version. To enable it, you can add this snippet to your zshrc, before Oh My Zsh is sourced: +nvm script only when using it, and will create a function for `node`, `npm`, `npx`, `pnpm`, `pnpx`, `yarn`, +`corepack` and the command(s) specified by `lazy-cmd` option, so when you call either of them, nvm will be +loaded and run with default version. To enable it, you can add this snippet to your zshrc, before Oh My Zsh is +sourced: ```zsh zstyle ':omz:plugins:nvm' lazy yes diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh index f36182eda..a00c2e117 100644 --- a/plugins/nvm/nvm.plugin.zsh +++ b/plugins/nvm/nvm.plugin.zsh @@ -74,7 +74,7 @@ function _omz_setup_autoload { if zstyle -t ':omz:plugins:nvm' lazy; then # Call nvm when first using nvm, node, npm, pnpm, yarn, corepack or other commands in lazy-cmd zstyle -a ':omz:plugins:nvm' lazy-cmd nvm_lazy_cmd - nvm_lazy_cmd=(nvm node npm npx pnpm yarn corepack $nvm_lazy_cmd) # default values + nvm_lazy_cmd=(nvm node npm npx pnpm pnpx yarn corepack $nvm_lazy_cmd) # default values eval " function $nvm_lazy_cmd { for func in $nvm_lazy_cmd; do -- cgit v1.2.3-70-g09d2 From 1514145a09140425b914e9cd98fc1d638a8c4003 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Thu, 19 Sep 2024 11:44:51 +0200 Subject: feat(nvm): add `_omz_nvm_load` function --- plugins/nvm/README.md | 2 ++ plugins/nvm/nvm.plugin.zsh | 24 +++++++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) (limited to 'plugins/nvm/README.md') diff --git a/plugins/nvm/README.md b/plugins/nvm/README.md index fe91cc3b2..1245f66db 100644 --- a/plugins/nvm/README.md +++ b/plugins/nvm/README.md @@ -42,6 +42,8 @@ as you want: zstyle ':omz:plugins:nvm' lazy-cmd eslint prettier typescript ... ``` +There will be a function `_omz_nvm_load` available to load `nvm` without executing any other trigger command. + #### `.nvmrc` autoload Note: _if used at the same time as `lazy`, `autoload` will start working only after nvm has been lazy-loaded_ diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh index a00c2e117..682bddc47 100644 --- a/plugins/nvm/nvm.plugin.zsh +++ b/plugins/nvm/nvm.plugin.zsh @@ -20,7 +20,7 @@ if [[ -z "$NVM_DIR" ]] || [[ ! -f "$NVM_DIR/nvm.sh" ]]; then return fi -function _omz_load_nvm_completion { +function _omz_nvm_setup_completion { local _nvm_completion # Load nvm bash completion for _nvm_completion in "$NVM_DIR/bash_completion" "$NVM_HOMEBREW/etc/bash_completion.d/nvm"; do @@ -33,12 +33,12 @@ function _omz_load_nvm_completion { break fi done - unfunction _omz_load_nvm_completion + unfunction _omz_nvm_setup_completion } -function _omz_setup_autoload { +function _omz_nvm_setup_autoload { if ! zstyle -t ':omz:plugins:nvm' autoload; then - unfunction _omz_setup_autoload + unfunction _omz_nvm_setup_autoload return fi @@ -68,13 +68,13 @@ function _omz_setup_autoload { add-zsh-hook chpwd load-nvmrc load-nvmrc - unfunction _omz_setup_autoload + unfunction _omz_nvm_setup_autoload } if zstyle -t ':omz:plugins:nvm' lazy; then # Call nvm when first using nvm, node, npm, pnpm, yarn, corepack or other commands in lazy-cmd zstyle -a ':omz:plugins:nvm' lazy-cmd nvm_lazy_cmd - nvm_lazy_cmd=(nvm node npm npx pnpm pnpx yarn corepack $nvm_lazy_cmd) # default values + nvm_lazy_cmd=(_omz_nvm_load nvm node npm npx pnpm pnpx yarn corepack $nvm_lazy_cmd) # default values eval " function $nvm_lazy_cmd { for func in $nvm_lazy_cmd; do @@ -84,14 +84,16 @@ if zstyle -t ':omz:plugins:nvm' lazy; then done # Load nvm if it exists in \$NVM_DIR [[ -f \"\$NVM_DIR/nvm.sh\" ]] && source \"\$NVM_DIR/nvm.sh\" - _omz_load_nvm_completion - _omz_setup_autoload - \"\$0\" \"\$@\" + _omz_nvm_setup_completion + _omz_nvm_setup_autoload + if [[ \"\$0\" != _omz_nvm_load ]]; then + \"\$0\" \"\$@\" + fi } " unset nvm_lazy_cmd else source "$NVM_DIR/nvm.sh" - _omz_load_nvm_completion - _omz_setup_autoload + _omz_nvm_setup_completion + _omz_nvm_setup_autoload fi -- cgit v1.2.3-70-g09d2