feat(revamp): add zsh and neovim configs, add an install script and a dependencies list
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
# Node.js
|
||||
|
||||
Provides utility functions for [Node.js][1], loads the Node Version Manager, and
|
||||
enables [_npm_][2] completion.
|
||||
|
||||
This module must be loaded _before_ the _`completion`_ module so that the
|
||||
provided completion definitions are loaded.
|
||||
|
||||
## nodenv
|
||||
|
||||
[_nodenv_][5] does one thing well - it is concerned solely with switching
|
||||
Node versions. It is simple and predictable, Just Works, and is rock solid in
|
||||
production. nodenv is forked from the popular [_rbenv_][6].
|
||||
|
||||
This will be loaded automatically if nodenv is installed in `$NODENV_ROOT`,
|
||||
_`$XDG_CONFIG_HOME/nodenv`_, _`~/.nodenv`_, or `nodenv` is on the path.
|
||||
|
||||
## nvm
|
||||
|
||||
[_nvm_][7] allows for managing multiple, isolated Node.js installations in the
|
||||
home directory.
|
||||
|
||||
This will be loaded automatically if nvm is installed in `$NVM_DIR`,
|
||||
_`$XDG_CONFIG_HOME/nvm`_, _`~/.nvm`_, or is installed with homebrew.
|
||||
|
||||
## Variables
|
||||
|
||||
- `N_PREFIX` stores the path to [_n_][8] cache.
|
||||
|
||||
## Aliases
|
||||
|
||||
Aliases are enabled by default. To disable them, add the following to
|
||||
_`${ZDOTDIR:-$HOME}/.zpreztorc`_.
|
||||
|
||||
```sh
|
||||
zstyle ':prezto:module:node:alias' skip 'yes'
|
||||
```
|
||||
|
||||
### npm
|
||||
|
||||
- `npmi` install a package.
|
||||
- `npml` list installed packages.
|
||||
- `npmo` check for outdated packages.
|
||||
- `npmp` publish a package.
|
||||
- `npmP` remove extraneous packages.
|
||||
- `npmr` run arbitrary package scripts.
|
||||
- `npms` search for packages.
|
||||
- `npmt` test a package.
|
||||
- `npmu` update packages.
|
||||
- `npmx` uninstalls a package.
|
||||
|
||||
- `npmci` install a project with a clean slate.
|
||||
- `npmcit` install a project with a clean slate and run tests.
|
||||
- `npmit` install package(s) and run tests.
|
||||
|
||||
## 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 version, define the
|
||||
following style inside the `prompt_name_setup` function.
|
||||
|
||||
```sh
|
||||
# %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
|
||||
|
||||
_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)
|
||||
- [Indrajit Raychaudhuri](https://github.com/indrajitr)
|
||||
|
||||
[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/nodenv/nodenv
|
||||
[6]: https://github.com/sstephenson/rbenv
|
||||
[7]: https://github.com/nvm-sh/nvm
|
||||
[8]: https://github.com/tj/n
|
||||
@@ -0,0 +1,15 @@
|
||||
#compdef grunt
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Grunt completion, delegating to grunt to do all the completion work.
|
||||
#
|
||||
# Authors:
|
||||
# Indrajit Raychaudhuri <irc@indrajit.com>
|
||||
#
|
||||
|
||||
if (( $+commands[grunt] )); then
|
||||
eval "$(grunt --completion=zsh)"
|
||||
|
||||
_grunt_completion "$@"
|
||||
fi
|
||||
@@ -0,0 +1,15 @@
|
||||
#compdef gulp
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Gulp completion, delegating to gulp to do all the completion work.
|
||||
#
|
||||
# Authors:
|
||||
# Indrajit Raychaudhuri <irc@indrajit.com>
|
||||
#
|
||||
|
||||
if (( $+commands[gulp] )); then
|
||||
eval "$(gulp --completion=zsh)"
|
||||
|
||||
_gulp_completion "$@"
|
||||
fi
|
||||
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# Opens the Node.js online API documentation in the default browser.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# function node-doc {
|
||||
|
||||
if [[ -z "$BROWSER" ]]; then
|
||||
print "$0: no web browser defined" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# TODO: Make the sections easier to use.
|
||||
"$BROWSER" "https://nodejs.org/docs/${$(node --version 2> /dev/null)/%-*}/api/all.html#${1}"
|
||||
|
||||
# }
|
||||
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# Exposes information about the Node.js environment via the $node_info
|
||||
# associative array.
|
||||
#
|
||||
# Authors:
|
||||
# Zeh Rizzatti <zehrizzatti@gmail.com>
|
||||
#
|
||||
|
||||
# function node-info {
|
||||
|
||||
local version
|
||||
local version_format
|
||||
local version_formatted
|
||||
|
||||
unset node_info
|
||||
typeset -gA node_info
|
||||
|
||||
if (( $+commands[nodenv] )); then
|
||||
version="${${$(nodenv version)#v}[(w)0]}"
|
||||
elif (( $+functions[nvm_version] )); then
|
||||
version="${$(nvm_version)#v}"
|
||||
elif (( $+commands[node] )) ; then
|
||||
version="${$(node -v)#v}"
|
||||
fi
|
||||
|
||||
if [[ "$version" != (none|system) ]]; 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
|
||||
|
||||
# }
|
||||
@@ -0,0 +1,67 @@
|
||||
#
|
||||
# Configures Node local installation, loads version managers, and defines
|
||||
# variables and aliases.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
# Zeh Rizzatti <zehrizzatti@gmail.com>
|
||||
# Indrajit Raychaudhuri <irc@indrajit.com>
|
||||
#
|
||||
|
||||
# Possible lookup locations for manually installed nodenv and nvm.
|
||||
local_nodenv_paths=({$NODENV_ROOT,{$XDG_CONFIG_HOME/,$HOME/.}nodenv}/bin/nodenv(N))
|
||||
local_nvm_paths=({$NVM_DIR,{$XDG_CONFIG_HOME/,$HOME/.}nvm}/nvm.sh(N))
|
||||
|
||||
# Load manually installed or package manager installed nodenv into the shell
|
||||
# session.
|
||||
if (( $#local_nodenv_paths || $+commands[nodenv] )); then
|
||||
|
||||
# Ensure manually installed nodenv is added to path when present.
|
||||
[[ -s $local_nodenv_paths[1] ]] && path=($local_nodenv_paths[1]:h $path)
|
||||
|
||||
eval "$(nodenv init - --no-rehash zsh)"
|
||||
|
||||
# Load manually installed nvm into the shell session.
|
||||
elif (( $#local_nvm_paths )); then
|
||||
source "$local_nvm_paths[1]" --no-use
|
||||
|
||||
# Load package manager installed nvm into the shell session.
|
||||
elif (( $+commands[brew] )) \
|
||||
&& [[ -d "${nvm_path::="$(brew --prefix 2> /dev/null)"/opt/nvm}" ]]; then
|
||||
source "$nvm_path/nvm.sh" --no-use
|
||||
fi
|
||||
|
||||
unset local_n{odenv,vm}_paths nvm_path
|
||||
|
||||
# Return if requirements are not found.
|
||||
if (( ! $+commands[node] && ! $#functions[(i)n(odenv|vm)] )); then
|
||||
return 1
|
||||
fi
|
||||
|
||||
#
|
||||
# Variables
|
||||
#
|
||||
|
||||
N_PREFIX="${XDG_CONFIG_HOME:-$HOME/.config}/n" # The path to 'n' cache.
|
||||
|
||||
#
|
||||
# Aliases
|
||||
#
|
||||
|
||||
if ! zstyle -t ':prezto:module:node:alias' skip; then
|
||||
# npm
|
||||
alias npmi='npm install'
|
||||
alias npml='npm list'
|
||||
alias npmo='npm outdated'
|
||||
alias npmp='npm publish'
|
||||
alias npmP='npm prune'
|
||||
alias npmr='npm run'
|
||||
alias npms='npm search'
|
||||
alias npmt='npm test'
|
||||
alias npmu='npm update'
|
||||
alias npmx='npm uninstall'
|
||||
|
||||
alias npmci='npm ci'
|
||||
alias npmcit='npm cit'
|
||||
alias npmit='npm it'
|
||||
fi
|
||||
Reference in New Issue
Block a user