21 changed files with 445 additions and 104 deletions
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
complete --command nvm --exclusive |
||||
complete --command nvm --exclusive --long version --description "Print version" |
||||
complete --command nvm --exclusive --long help --description "Print help" |
||||
complete --command nvm --long silent --description "Suppress standard output" |
||||
|
||||
complete --command nvm --exclusive --condition __fish_use_subcommand --arguments install --description "Download and activate the specified Node version" |
||||
complete --command nvm --exclusive --condition __fish_use_subcommand --arguments use --description "Activate the specified Node version in the current shell" |
||||
complete --command nvm --exclusive --condition __fish_use_subcommand --arguments list --description "List installed Node versions" |
||||
complete --command nvm --exclusive --condition __fish_use_subcommand --arguments list-remote --description "List available Node versions to install" |
||||
complete --command nvm --exclusive --condition __fish_use_subcommand --arguments current --description "Print the currently-active Node version" |
||||
complete --command nvm --exclusive --condition "__fish_seen_subcommand_from install" --arguments "( |
||||
test -e $nvm_data && string split ' ' <$nvm_data/.index |
||||
)" |
||||
complete --command nvm --exclusive --condition "__fish_seen_subcommand_from use" --arguments "(_nvm_list | string split ' ')" |
||||
complete --command nvm --exclusive --condition __fish_use_subcommand --arguments uninstall --description "Uninstall the specified Node version" |
||||
complete --command nvm --exclusive --condition "__fish_seen_subcommand_from uninstall" --arguments "( |
||||
_nvm_list | string split ' ' | string replace system '' |
||||
)" |
||||
complete --command nvm --exclusive --condition "__fish_seen_subcommand_from use uninstall" --arguments "( |
||||
set --query nvm_default_version && echo default |
||||
)" |
||||
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
set --query XDG_DATA_HOME || set --local XDG_DATA_HOME ~/.local/share |
||||
set --query nvm_mirror || set --global nvm_mirror https://nodejs.org/dist |
||||
set --query nvm_data || set --global nvm_data $XDG_DATA_HOME/nvm |
||||
|
||||
function _nvm_install --on-event nvm_install |
||||
test ! -d $nvm_data && command mkdir -p $nvm_data |
||||
echo "Downloading the Node distribution index..." 2>/dev/null |
||||
_nvm_index_update |
||||
end |
||||
|
||||
function _nvm_update --on-event nvm_update |
||||
set --query --universal nvm_data && set --erase --universal nvm_data |
||||
set --query --universal nvm_mirror && set --erase --universal nvm_mirror |
||||
set --query nvm_mirror || set --global nvm_mirror https://nodejs.org/dist |
||||
end |
||||
|
||||
function _nvm_uninstall --on-event nvm_uninstall |
||||
command rm -rf $nvm_data |
||||
|
||||
set --query nvm_current_version && _nvm_version_deactivate $nvm_current_version |
||||
|
||||
set --names | string replace --filter --regex -- "^nvm" "set --erase nvm" | source |
||||
functions --erase (functions --all | string match --entire --regex -- "^_nvm_") |
||||
end |
||||
|
||||
if status is-interactive && set --query nvm_default_version && ! set --query nvm_current_version |
||||
nvm use --silent $nvm_default_version |
||||
end |
||||
@ -1,2 +1,3 @@
@@ -1,2 +1,3 @@
|
||||
jorgebucaran/fisher |
||||
tomyun/base16-fish |
||||
jorgebucaran/nvm.fish |
||||
|
||||
File diff suppressed because one or more lines are too long
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
function _nvm_index_update |
||||
test ! -d $nvm_data && command mkdir -p $nvm_data |
||||
|
||||
set --local index $nvm_data/.index |
||||
|
||||
if not command curl -q --location --silent $nvm_mirror/index.tab >$index.temp |
||||
command rm -f $index.temp |
||||
echo "nvm: Can't update index, host unavailable: \"$nvm_mirror\"" >&2 |
||||
return 1 |
||||
end |
||||
|
||||
command awk -v OFS=\t ' |
||||
/v0.9.12/ { exit } # Unsupported |
||||
NR > 1 { |
||||
print $1 (NR == 2 ? " latest" : $10 != "-" ? " lts/" tolower($10) : "") |
||||
} |
||||
' $index.temp >$index |
||||
|
||||
command rm -f $index.temp |
||||
end |
||||
@ -0,0 +1,14 @@
@@ -0,0 +1,14 @@
|
||||
function _nvm_list |
||||
set --local versions $nvm_data/* |
||||
|
||||
set --query versions[1] && |
||||
string match --entire --regex -- ( |
||||
string replace --all -- $nvm_data/ "" $versions | |
||||
string match --regex -- "v\d.+" | |
||||
string escape --style=regex | |
||||
string join "|" |
||||
) <$nvm_data/.index |
||||
|
||||
command --all node | |
||||
string match --quiet --invert --regex -- "^$nvm_data" && echo system |
||||
end |
||||
@ -0,0 +1,4 @@
@@ -0,0 +1,4 @@
|
||||
function _nvm_version_activate --argument-names ver |
||||
set --global --export nvm_current_version $ver |
||||
set --prepend PATH $nvm_data/$ver/bin |
||||
end |
||||
@ -0,0 +1,5 @@
@@ -0,0 +1,5 @@
|
||||
function _nvm_version_deactivate --argument-names ver |
||||
test "$nvm_current_version" = "$ver" && set --erase nvm_current_version |
||||
set --local index (contains --index -- $nvm_data/$ver/bin $PATH) && |
||||
set --erase PATH[$index] |
||||
end |
||||
@ -0,0 +1,237 @@
@@ -0,0 +1,237 @@
|
||||
function nvm --description "Node version manager" |
||||
for silent in --silent -s |
||||
if set --local index (contains --index -- $silent $argv) |
||||
set --erase argv[$index] && break |
||||
end |
||||
set --erase silent |
||||
end |
||||
|
||||
set --local cmd $argv[1] |
||||
set --local ver $argv[2] |
||||
|
||||
if set --query silent && ! set --query cmd[1] |
||||
echo "nvm: Version number not specified (see nvm -h for usage)" >&2 |
||||
return 1 |
||||
end |
||||
|
||||
if ! set --query ver[1] && contains -- "$cmd" install use |
||||
for file in .nvmrc .node-version |
||||
set file (_nvm_find_up $PWD $file) && read ver <$file && break |
||||
end |
||||
|
||||
if ! set --query ver[1] |
||||
echo "nvm: Invalid version or missing \".nvmrc\" file" >&2 |
||||
return 1 |
||||
end |
||||
end |
||||
|
||||
set --local their_version $ver |
||||
|
||||
switch "$cmd" |
||||
case -v --version |
||||
echo "nvm, version 2.2.18" |
||||
case "" -h --help |
||||
echo "Usage: nvm install <version> Download and activate the specified Node version" |
||||
echo " nvm install Install the version specified in the nearest .nvmrc file" |
||||
echo " nvm use <version> Activate the specified Node version in the current shell" |
||||
echo " nvm use Activate the version specified in the nearest .nvmrc file" |
||||
echo " nvm list List installed Node versions" |
||||
echo " nvm list-remote List available Node versions to install" |
||||
echo " nvm list-remote <regex> List Node versions matching a given regex pattern" |
||||
echo " nvm current Print the currently-active Node version" |
||||
echo " nvm uninstall <version> Uninstall the specified Node version" |
||||
echo "Options:" |
||||
echo " -s, --silent Suppress standard output" |
||||
echo " -v, --version Print the version of nvm" |
||||
echo " -h, --help Print this help message" |
||||
echo "Variables:" |
||||
echo " nvm_arch Override architecture, e.g. x64-musl" |
||||
echo " nvm_mirror Use a mirror for downloading Node binaries" |
||||
echo " nvm_default_version Set the default version for new shells" |
||||
echo " nvm_default_packages Install a list of packages every time a Node version is installed" |
||||
echo " nvm_data Set a custom directory for storing nvm data" |
||||
echo "Examples:" |
||||
echo " nvm install latest Install the latest version of Node" |
||||
echo " nvm use 14.15.1 Use Node version 14.15.1" |
||||
echo " nvm use system Activate the system's Node version" |
||||
|
||||
case install |
||||
_nvm_index_update |
||||
|
||||
string match --entire --regex -- (_nvm_version_match $ver) <$nvm_data/.index | read ver alias |
||||
|
||||
if ! set --query ver[1] |
||||
echo "nvm: Invalid version number or alias: \"$their_version\"" >&2 |
||||
return 1 |
||||
end |
||||
|
||||
if test ! -e $nvm_data/$ver |
||||
set --local os (command uname -s | string lower) |
||||
set --local ext tar.gz |
||||
set --local arch (command uname -m) |
||||
set --local tarcmd tar |
||||
|
||||
switch $os |
||||
case aix |
||||
set arch ppc64 |
||||
case sunos |
||||
case linux |
||||
case darwin |
||||
case {msys_nt,mingw\*_nt}\* |
||||
set os win |
||||
set ext zip |
||||
set tarcmd bsdtar |
||||
case \* |
||||
echo "nvm: Unsupported operating system: \"$os\"" >&2 |
||||
return 1 |
||||
end |
||||
|
||||
switch $arch |
||||
case i\*86 |
||||
set arch x86 |
||||
case x86_64 |
||||
set arch x64 |
||||
case arm64 |
||||
string match --regex --quiet "v(?<major>\d+)" $ver |
||||
if test "$os" = darwin -a $major -lt 16 |
||||
set arch x64 |
||||
end |
||||
case armv6 armv6l |
||||
set arch armv6l |
||||
case armv7 armv7l |
||||
set arch armv7l |
||||
case armv8 armv8l aarch64 |
||||
set arch arm64 |
||||
end |
||||
|
||||
set --query nvm_arch && set arch $nvm_arch |
||||
|
||||
set --local dir "node-$ver-$os-$arch" |
||||
set --local url $nvm_mirror/$ver/$dir.$ext |
||||
|
||||
command mkdir -p $nvm_data/$ver |
||||
|
||||
if ! set --query silent |
||||
echo -e "Installing Node \x1b[1m$ver\x1b[22m $alias" |
||||
echo -e "Fetching \x1b[4m$url\x1b[24m\x1b[7m" |
||||
end |
||||
|
||||
if ! command curl -q $silent --progress-bar --location $url | |
||||
command $tarcmd --extract --gzip --directory $nvm_data/$ver 2>/dev/null |
||||
command rm -rf $nvm_data/$ver |
||||
echo -e "\033[F\33[2K\x1b[0mnvm: Invalid mirror or host unavailable: \"$url\"" >&2 |
||||
return 1 |
||||
end |
||||
|
||||
set --query silent || echo -en "\033[F\33[2K\x1b[0m" |
||||
|
||||
if test "$os" = win |
||||
command mv $nvm_data/$ver/$dir $nvm_data/$ver/bin |
||||
else |
||||
command mv $nvm_data/$ver/$dir/* $nvm_data/$ver |
||||
command rm -rf $nvm_data/$ver/$dir |
||||
end |
||||
end |
||||
|
||||
if test $ver != "$nvm_current_version" |
||||
set --query nvm_current_version && _nvm_version_deactivate $nvm_current_version |
||||
_nvm_version_activate $ver |
||||
|
||||
set --query nvm_default_packages[1] && npm install --global $silent $nvm_default_packages |
||||
end |
||||
|
||||
set --query silent || printf "Now using Node %s (npm %s) %s\n" (_nvm_node_info) |
||||
case use |
||||
test $ver = default && set ver $nvm_default_version |
||||
_nvm_list | string match --entire --regex -- (_nvm_version_match $ver) | read ver __ |
||||
|
||||
if ! set --query ver[1] |
||||
echo "nvm: Can't use Node \"$their_version\", version must be installed first" >&2 |
||||
return 1 |
||||
end |
||||
|
||||
if test $ver != "$nvm_current_version" |
||||
set --query nvm_current_version && _nvm_version_deactivate $nvm_current_version |
||||
test $ver != system && _nvm_version_activate $ver |
||||
end |
||||
|
||||
set --query silent || printf "Now using Node %s (npm %s) %s\n" (_nvm_node_info) |
||||
case uninstall |
||||
if test -z "$ver" |
||||
echo "nvm: Not enough arguments for command: \"$cmd\"" >&2 |
||||
return 1 |
||||
end |
||||
|
||||
test $ver = default && test ! -z "$nvm_default_version" && set ver $nvm_default_version |
||||
|
||||
_nvm_list | string match --entire --regex -- (_nvm_version_match $ver) | read ver __ |
||||
|
||||
if ! set -q ver[1] |
||||
echo "nvm: Node version not installed or invalid: \"$their_version\"" >&2 |
||||
return 1 |
||||
end |
||||
|
||||
set --query silent || printf "Uninstalling Node %s %s\n" $ver (string replace ~ \~ "$nvm_data/$ver/bin/node") |
||||
|
||||
_nvm_version_deactivate $ver |
||||
|
||||
command rm -rf $nvm_data/$ver |
||||
case current |
||||
_nvm_current |
||||
case ls list |
||||
_nvm_list | _nvm_list_format (_nvm_current) $argv[2] |
||||
case lsr {ls,list}-remote |
||||
_nvm_index_update || return |
||||
_nvm_list | command awk ' |
||||
FILENAME == "-" && (is_local[$1] = FNR == NR) { next } { |
||||
print $0 (is_local[$1] ? " ✓" : "") |
||||
} |
||||
' - $nvm_data/.index | _nvm_list_format (_nvm_current) $argv[2] |
||||
case \* |
||||
echo "nvm: Unknown command or option: \"$cmd\" (see nvm -h for usage)" >&2 |
||||
return 1 |
||||
end |
||||
end |
||||
|
||||
function _nvm_find_up --argument-names path file |
||||
test -e "$path/$file" && echo $path/$file || begin |
||||
test ! -z "$path" || return |
||||
_nvm_find_up (string replace --regex -- '/[^/]*$' "" $path) $file |
||||
end |
||||
end |
||||
|
||||
function _nvm_version_match --argument-names ver |
||||
string replace --regex -- '^v?(\d+|\d+\.\d+)$' 'v$1.' $ver | |
||||
string replace --filter --regex -- '^v?(\d+)' 'v$1' | |
||||
string escape --style=regex || string lower '\b'$ver'(?:/\w+)?$' |
||||
end |
||||
|
||||
function _nvm_list_format --argument-names current regex |
||||
command awk -v current="$current" -v regex="$regex" ' |
||||
$0 ~ regex { |
||||
aliases[versions[i++] = $1] = $2 " " $3 |
||||
pad = (n = length($1)) > pad ? n : pad |
||||
} |
||||
END { |
||||
if (!i) exit 1 |
||||
while (i--) |
||||
printf((current == versions[i] ? " ▶ " : " ") "%"pad"s %s\n", |
||||
versions[i], aliases[versions[i]]) |
||||
} |
||||
' |
||||
end |
||||
|
||||
function _nvm_current |
||||
command --search --quiet node || return |
||||
set --query nvm_current_version && echo $nvm_current_version || echo system |
||||
end |
||||
|
||||
function _nvm_node_info |
||||
set --local npm_path (string replace bin/npm-cli.js "" (realpath (command --search npm))) |
||||
test -f $npm_path/package.json || set --local npm_version_default (command npm --version) |
||||
command node --eval " |
||||
console.log(process.version) |
||||
console.log('$npm_version_default' ? '$npm_version_default': require('$npm_path/package.json').version) |
||||
console.log(process.execPath) |
||||
" | string replace -- ~ \~ |
||||
end |
||||
@ -1,33 +1,34 @@
@@ -1,33 +1,34 @@
|
||||
{ |
||||
"Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, |
||||
"Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, |
||||
"FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, |
||||
"LuaSnip": { "branch": "master", "commit": "f03089854a8e15594a01562fa7192d0009a6fbe7" }, |
||||
"base16-nvim": { "branch": "master", "commit": "2349e8357864bf0ef45d40f491f8e1e6465485b0" }, |
||||
"bufferline.nvim": { "branch": "main", "commit": "6ecd37e0fa8b156099daedd2191130e083fb1490" }, |
||||
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, |
||||
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, |
||||
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, |
||||
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, |
||||
"dressing.nvim": { "branch": "master", "commit": "8b7ae53d7f04f33be3439a441db8071c96092d19" }, |
||||
"friendly-snippets": { "branch": "main", "commit": "53d3df271d031c405255e99410628c26a8f0d2b0" }, |
||||
"lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, |
||||
"lspkind.nvim": { "branch": "master", "commit": "57610d5ab560c073c465d6faf0c19f200cb67e6e" }, |
||||
"lualine.nvim": { "branch": "master", "commit": "2248ef254d0a1488a72041cfb45ca9caada6d994" }, |
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "4eb8e15e3c0757303d4c6dea64d2981fc679e990" }, |
||||
"mason.nvim": { "branch": "main", "commit": "41e75af1f578e55ba050c863587cffde3556ffa6" }, |
||||
"neotest": { "branch": "master", "commit": "d424d262d01bccc1e0b038c9a7220a755afd2a1f" }, |
||||
"neotest-elixir": { "branch": "master", "commit": "3117ca5442c02998847131c39551b76a6ceac9d7" }, |
||||
"neotest-go": { "branch": "main", "commit": "d29d20d912aca81a07c50022d880cc66f0d26542" }, |
||||
"nvim-cmp": { "branch": "main", "commit": "0b751f6beef40fd47375eaf53d3057e0bfa317e4" }, |
||||
"nvim-lspconfig": { "branch": "master", "commit": "694aaec65733e2d54d393abf80e526f86726c988" }, |
||||
"nvim-tree.lua": { "branch": "master", "commit": "05f55c1fd6470b31627655c528245794e3cd4b2c" }, |
||||
"nvim-treesitter": { "branch": "master", "commit": "841dde702ce2e58ffc3724808f3dbea2edee57d5" }, |
||||
"nvim-web-devicons": { "branch": "master", "commit": "5efb8bd06841f91f97c90e16de85e96d57e9c862" }, |
||||
"plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, |
||||
"base16-nvim": { "branch": "master", "commit": "23e5128eb5f629c29532c24a1e733cbe019f05bb" }, |
||||
"bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, |
||||
"cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, |
||||
"cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, |
||||
"cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" }, |
||||
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, |
||||
"dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, |
||||
"friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, |
||||
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, |
||||
"lspkind.nvim": { "branch": "master", "commit": "c7274c48137396526b59d86232eabcdc7fed8a32" }, |
||||
"lualine.nvim": { "branch": "master", "commit": "131a558e13f9f28b15cd235557150ccb23f89286" }, |
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "7b01e2974a47d489bb92f47a41e4c0088ea8f86e" }, |
||||
"mason.nvim": { "branch": "main", "commit": "cbf8d285e1462dd24acf3507817be2bbcb035919" }, |
||||
"neotest": { "branch": "master", "commit": "ad991822b7076b1d940b33a9d6d0d30416d5df81" }, |
||||
"neotest-elixir": { "branch": "master", "commit": "a242aebeaa6997c1c149138ff77f6cacbe33b6fc" }, |
||||
"neotest-go": { "branch": "main", "commit": "59b50505053f9c45a9febb79e11a56206c3e3901" }, |
||||
"nvim-cmp": { "branch": "main", "commit": "a1d504892f2bc56c2e79b65c6faded2fd21f3eca" }, |
||||
"nvim-lspconfig": { "branch": "master", "commit": "dfbada1a311c4bf3369f8d5421369c9b6e8b888f" }, |
||||
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, |
||||
"nvim-tree.lua": { "branch": "master", "commit": "07f541fcaa4a5ae019598240362449ab7e9812b3" }, |
||||
"nvim-treesitter": { "branch": "master", "commit": "cf12346a3414fa1b06af75c79faebe7f76df080a" }, |
||||
"nvim-web-devicons": { "branch": "master", "commit": "0d7d35fa946837b8738b17c18d1faa1ac351e7f9" }, |
||||
"plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, |
||||
"rust.vim": { "branch": "master", "commit": "889b9a7515db477f4cb6808bef1769e53493c578" }, |
||||
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, |
||||
"telescope.nvim": { "branch": "0.1.x", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, |
||||
"telescope-fzf-native.nvim": { "branch": "main", "commit": "b25b749b9db64d375d782094e2b9dce53ad53a40" }, |
||||
"telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, |
||||
"vim-maximizer": { "branch": "master", "commit": "2e54952fe91e140a2e69f35f22131219fcd9c5f1" }, |
||||
"vim-tmux-navigator": { "branch": "master", "commit": "7db70e08ea03b3e4d91f63713d76134512e28d7e" }, |
||||
"which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } |
||||
"vim-tmux-navigator": { "branch": "master", "commit": "e41c431a0c7b7388ae7ba341f01a0d217eb3a432" }, |
||||
"which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } |
||||
} |
||||
Loading…
Reference in new issue