https://github.com/artbit/vim-tmpl
VIM plugin for the custom bash templating function
https://github.com/artbit/vim-tmpl
shell vim vim-plugins
Last synced: about 1 month ago
JSON representation
VIM plugin for the custom bash templating function
- Host: GitHub
- URL: https://github.com/artbit/vim-tmpl
- Owner: ArtBIT
- License: mit
- Created: 2014-11-30T10:05:48.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2022-05-13T08:32:26.000Z (about 4 years ago)
- Last Synced: 2026-04-04T13:06:14.851Z (3 months ago)
- Topics: shell, vim, vim-plugins
- Language: Shell
- Size: 18.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Overview
VIM-TMPL is a plugin with the custom bash templating function
## Features
You can call the templates by running the following command:
`:Tmpl html/html5`
Works best when used with snippets plugins like SnipMate ot UltiSnips.
## Installation
There are several plugin managers for vim, which will either allow you to
manually clone vim plugin repositories, or will do so for you. Probably the
two most popular ones currently are `pathogen
`_ and `vundle
`_. Please refer to their docs for
instructions on how to install plugins.
## Configuration
You can create your own templates directory with your own templates
```
# i.e. in your $HOME
#
# $HOME/templates
# $HOME/templates/react
# $HOME/templates/react/jsx
#
# Just export the path in VIM_TMPL_TEMPLATES env var
export VIM_TMPL_TEMPLATES=$HOME/templates
# And then in nvim
:Tmpl react/jsx
```
## Example template
Each template is a simple bash script, and can follow this proposed structure
```lang=sh
#/bin/bash
# Map positional arguments to varnames and set their default values
# first argument is always filepath
declare -A VARS=( ["FILEPATH"]="./Component/Component.js" )
# Map passed arguments to varnames
for VAR in "${!VARS[@]}"; do
VAL=${1:-${VARS[$VAR]}}
export $VAR=$VAL
shift
done
PARENTDIR=$(basename $(dirname -- "$FILEPATH"))
FILENAME=$(basename -- "$FILEPATH")
EXTENSION="${FILENAME##*.}"
NAME="${FILENAME%.*}"
#--------Begin template-----------#
cat $TEMPLATE < = ({className}) => {
return
}
export default ${NAME}
EOF
#--------End template-----------#
```
## License
See the [LICENSE](LICENSE) file.