From fbedaa8a2be698100b23f579c479eca5d55a3e88 Mon Sep 17 00:00:00 2001
From: Zeh Rizzatti <zehrizzatti@gmail.com>
Date: Thu, 13 Dec 2012 12:10:55 -0300
Subject: [PATCH 1/3] Support for creationix/nvm

Adds support for nvm inside the node module.

If `.nvm/nvm.sh` is found, it is sourced, similar to the way rvm,
rbenv and others work.
---
 modules/node/init.zsh | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/modules/node/init.zsh b/modules/node/init.zsh
index 16847abccb..92c5d923c5 100644
--- a/modules/node/init.zsh
+++ b/modules/node/init.zsh
@@ -5,6 +5,11 @@
 #   Sorin Ionescu <sorin.ionescu@gmail.com>
 #
 
+# Load NVM into the shell session.
+if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
+  source "$HOME/.nvm/nvm.sh"
+fi
+
 # Return if requirements are not found.
 if (( ! $+commands[node] )); then
   return 1

From 0e3848093aa1dbb70a99bce5b623a37669e08756 Mon Sep 17 00:00:00 2001
From: Zeh Rizzatti <zehrizzatti@gmail.com>
Date: Thu, 13 Dec 2012 12:26:01 -0300
Subject: [PATCH 2/3] Add node-info function

Minimal configuration required prior to calling node-info is:
ztyle -s ':prezto:module:node:info:version' format '%v'

$node_info[version] will contain the current version of node.js
on the path, if nvm is loaded.

This information can be used in prompts like $ruby_info.
---
 modules/node/functions/node-info | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 modules/node/functions/node-info

diff --git a/modules/node/functions/node-info b/modules/node/functions/node-info
new file mode 100644
index 0000000000..f2eca0b684
--- /dev/null
+++ b/modules/node/functions/node-info
@@ -0,0 +1,26 @@
+# vim: ft=zsh
+#
+# Exposes information about the node.js environment via the $node_info
+# associative array.
+#
+# Authors:
+#   Zeh Rizzatti <zehrizzatti@gmail.com>
+#
+
+local version
+local version_format
+local version_formatted
+
+unset node_info
+typeset -gA node_info
+
+if (( $+functions[nvm_version] )); then
+  version="${$(nvm_version)#v}"
+fi
+
+if [[ -n "$version" ]]; then
+  zstyle -s ':prezto:module:node:info:version' format 'version_format'
+  zformat -f version_formatted "$version_format" "v:$version"
+  node_info[version]="$version_formatted"
+fi
+

From 616a795253b2000e352a9fa9adda6c1e985143f6 Mon Sep 17 00:00:00 2001
From: Zeh Rizzatti <zehrizzatti@gmail.com>
Date: Fri, 21 Dec 2012 01:26:17 -0300
Subject: [PATCH 3/3] Update node readme

---
 modules/node/README.md | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/modules/node/README.md b/modules/node/README.md
index 58f2b082ec..65cef10dfc 100644
--- a/modules/node/README.md
+++ b/modules/node/README.md
@@ -3,11 +3,31 @@ Node.js
 
 Provides utility functions for [Node.js][1] and loads [npm][2] completion.
 
+nvm
+---
+
+Loads [nvm][5], which allows for managing multiple, isolated node.js
+installations in the home directory.
+
 Functions
 ---------
 
   - `node-doc` opens the Node.js online [API documentation][3] in the default
     browser.
+  - `node-info` exposes information about the node.js environment via the
+    `$node_info` associative array.
+
+Theming
+-------
+
+To display the version number of the current node.js instance (when nvm is
+setup), define the following style inside the `prompt_name_setup` function.
+
+    # %v - node.js version
+    zstyle ':prezto:module:node:info:version' format 'version:%v'
+
+Then add `$node_info[version]` to either `$PROMPT` or `$RPROMPT` and call
+`node-info` in `prompt_name_preexec` hook function.
 
 Authors
 -------
@@ -15,9 +35,11 @@ Authors
 *The authors of this module should be contacted via the [issue tracker][4].*
 
   - [Sorin Ionescu](https://github.com/sorin-ionescu)
+  - [Zeh Rizzatti](https://github.com/zehrizzatti)
 
 [1]: http://nodejs.org
 [2]: http://npmjs.org
 [3]: http://nodejs.org/api
 [4]: https://github.com/sorin-ionescu/prezto/issues
+[5]: https://github.com/creationix/nvm