feat(adwnode): add plugin

This commit is contained in:
Adrian Wojdat 2023-02-22 22:50:58 +01:00
parent aca048814b
commit dc019bc3ec
4 changed files with 55 additions and 0 deletions

21
plugins/adwnode/LICENSE Normal file
View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2023-present Adrian Wojdat
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

14
plugins/adwnode/README.md Normal file
View file

@ -0,0 +1,14 @@
# NodeJs - Scripts autocomplete
<p align="center"><img src="https://drive.google.com/uc?id=183iJtqEywucyUWWJYv_PTg-Tb2bKlZLN" alt="NodeJs Autocompleter"></p>
## Instalation
To use it, add `adwnode` to the plugins array in your .zshrc file:
```shell
plugins=(... adwnode)
```
## Usage
Just start typing `yarn` or `npm run` inside NodeJs app directory and double press tab key to start autocompleter.
<p align="center"><img src="https://drive.google.com/uc?id=1kQFPM2i4MzuICihUMSiKGRo14nQwr5rS" alt="NodeJs Autocompleter"></p>

17
plugins/adwnode/_adwnode Normal file
View file

@ -0,0 +1,17 @@
_load_nodejs_scripts() {
local read_package_json_scripts_command="try { Object.keys(require('./package.json').scripts).join('\n').replace(/:/g, '\\\:') } catch {''}"
nodejs_scripts=("${(@f)$(node -pe ${read_package_json_scripts_command} | sort)}")
}
_adwnode() {
if command -v node >/dev/null 2>&1; then
if [ -f ./package.json ]; then
_load_nodejs_scripts
if [[ ! ${#nodejs_scripts[@]} -eq 0 ]]; then
_describe '' nodejs_scripts
fi
fi
fi
}

View file

@ -0,0 +1,3 @@
autoload -Uz _adwnode
compdef _adwnode yarn
compdef _adwnode npm run