From 51435306c2593279e8ec57c2a3b67b4c4e4f2c90 Mon Sep 17 00:00:00 2001 From: Joel Goguen Date: Fri, 19 Feb 2021 19:45:42 -0800 Subject: [PATCH] Initial commit --- .gitignore | 1 + LICENSE | 21 ++++++ README.md | 111 ++++++++++++++++++++++++++++ autoload/tmpl.vim | 152 ++++++++++++++++++++++++++++++++++++++ doc/tmpl.vim.txt | 131 ++++++++++++++++++++++++++++++++ plugin/tmpl.vim | 6 ++ templates/LICENSE.BSD3 | 24 ++++++ templates/LICENSE.BSD3.sh | 24 ++++++ templates/LICENSE.MIT | 21 ++++++ templates/LICENSE.MIT.c | 21 ++++++ templates/LICENSE.MIT.h | 21 ++++++ templates/LICENSE.MIT.sh | 21 ++++++ templates/default.c | 8 ++ templates/default.go | 4 + templates/default.h | 12 +++ templates/default.html | 16 ++++ templates/default.py | 2 + templates/default.sh | 5 ++ templates/default.tex | 19 +++++ 19 files changed, 620 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 autoload/tmpl.vim create mode 100644 doc/tmpl.vim.txt create mode 100644 plugin/tmpl.vim create mode 100644 templates/LICENSE.BSD3 create mode 100644 templates/LICENSE.BSD3.sh create mode 100644 templates/LICENSE.MIT create mode 100644 templates/LICENSE.MIT.c create mode 100644 templates/LICENSE.MIT.h create mode 100644 templates/LICENSE.MIT.sh create mode 100644 templates/default.c create mode 100644 templates/default.go create mode 100644 templates/default.h create mode 100644 templates/default.html create mode 100644 templates/default.py create mode 100644 templates/default.sh create mode 100644 templates/default.tex diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6e92f57 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +tags diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b6cd637 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (C) 2021 by Joel Goguen + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e5ede1f --- /dev/null +++ b/README.md @@ -0,0 +1,111 @@ +# tmpl.vim + +`tmpl.vim` provides autoloading new file templates for vim and Neovim. Templates +are kept in any `templates` directory on the `runtimepath`, allowing you to +easily add your own templates separately from this plugin. By setting +`g:tmplvim_default_environment`, different templates for the same file type may +be loaded in different environments (e.g. work versus personal). + +Template names are constructed as `environment.type`. The environment may be set +using `g:tmplvim_default_environment`, which defaults to `default`. For file +names with an extension the file extension is taken as the template type, or for +files with no extension the lower-case name of the file is used as the template +type. + +## Installation + +It is recommended to use a plugin manager to install `tmpl.vim`. + +### With [vim-plug](https://github.com/junegunn/vim-plug) + +```vim +Plug 'jgoguen/tmpl.vim' +``` + +### With [dein.vim](https://github.com/Shougo/dein.vim) + +```vim +call dein#add('jgoguen/tmpl.vim') +``` + +### With [minpac](https://github.com/k-takata/minpac) + +```vim +call minpac#add('jgoguen/tmpl.vim') +``` + +### With vim 8 plugins + +Clone the repository to `pack/plugins/start`: + +For vim 8: +```sh +mkdir -p ~/.vim/pack/plugins/start +git clone https://github.com/jgoguen/tmpl.vim ~/.vim/pack/plugins/start/tmpl.vim +``` + +For Neovim: +```sh +mkdir -p "${XDG_DATA_HOME:-${HOME}/.local/share}/nvim/site/pack/plugins/start" +git clone https://github.com/jgoguen/tmpl.vim "${XDG_DATA_HOME:-${HOME}/.local/share}/nvim/site/pack/plugins/start" +``` + +## Configuration + +To set the template environment, set `g:tmplvim_default_environment`. To +override the template environment on a per-buffer basis, set +`b:tmplvim_default_environment` for the specific buffers. If this is not given, +the default value is `default`. + +To set the replacement value for the `<# AUTHOR #>` tag, set `g:tmplvim_author`. +If this is not given, the default value is the `${USER}` environment variable. + +To set the replacement value for arbitrary template tags, use the dictionary +`g:tmplvim_template_vars`. Set the tag name as the dictionary key and the value +as the tag replacement value. + +## Template tags + +Templates may contain tags which will be automatically expanded when the +template is loaded into the buffer. There are two types of tags: + +1. Template variables +2. Template includes + +Template includes are processed first, then variables once includes have been +inserted into the buffer. Nested includes are not currently supported. + +### Template variables + +Template variable tags are upper-case letters surrounded by `<#` and `#>`. The +value of a template variable comes from `g:tmplvim_template_vars`, except for +some specific reserved tag names: + +1. `DATE`: Always replaced with the value of `strftime('%Y-%m-%d')` (e.g. + `2020-03-04`) +2. `YEAR`: Always replaced with the value of `strftime('%Y')` (e.g. `2020`) +3. `TIME`: Always replaced with the value of `strftime('%H:%M:%S')` (e.g. + `13:03:34`) +4. `AUTHOR`: Always replaced with the value of `g:tmplvim_author`, or the value + of `$USER` if that is not set. +5. `DIRNAME`: Always replaced with the name of the directory the file is in. +6. `BASENAME`: Always replaced with the name of the file without extensions. +7. `UPPERBASENAME`: Always replaced with the name of the file without extensions + in upper-case. + +### Template includes + +Template include tags are letters, numbers, or periods surrounded by `<$` and +`$>`. The tag name is expected to be the name of another template, which may +include template variables but may not include other template includes. For +example, the include tag `<$ LICENSE.MIT $>` will be replaced with the contents +of the template file named `LICENSE.MIT`. + +To accommodate including files in source code templates, an include with the +same extension as the current buffer will be searched for and preferred if +found. For example, the include tag `<$ LICENSE.MIT $>` in `setup.py` would use +the template named `LICENSE.MIT.py` if it exists, or `LICENSE.MIT` if not. + +## Usage + +When a new file is opened, the corresponding template is automatically loaded. diff --git a/autoload/tmpl.vim b/autoload/tmpl.vim new file mode 100644 index 0000000..f412894 --- /dev/null +++ b/autoload/tmpl.vim @@ -0,0 +1,152 @@ +" vim: set syntax=vim filetype=vim noexpandtab ts=2 sts=2 sw=2 autoindent: +" vim: set foldmarker=[[[,]]] foldmethod=marker foldlevel=0: + +let s:tmplVarTag = '<# *\([A-Z]\+\) *#>' +let s:tmplIncludeTag = '<\$ *\([A-Za-z0-9\.]\+\) *\$>' +let s:specialChars = '^[]\:*$' + +function! tmpl#LoadTemplateFile(...) abort + let template_environment = '' + let template_format = '' + + if a:0 >= 2 + " Both format and environment are given + let template_format = a:1 + let template_environment = a:2 + elseif a:0 == 1 + " Got format but not environment + let template_format = a:1 + endif + + if template_environment ==? '' + let template_environment = get(b:, 'tmplvim_default_environment', get(g:, 'tmplvim_default_environment', 'default')) + endif + + if template_format ==? '' + " Either a file extension or a file basename is needed to create the + " template path. + " - script.sh -> default.sh + " - Makefile -> default.makefile + " - project.py -> default.py + let file_extension = tolower(expand('%:e')) + if len(file_extension) == 0 + let file_name = tolower(expand('%:t')) + if len(file_name) == 0 + throw 'Cannot load template, need file extension or name' + else + let template_format = file_name + endif + else + let template_format = file_extension + endif + endif + + let template_name = printf('%s.%s', template_environment, template_format) + + let templates = templates_for_glob(template_name) + if empty(templates) + return 0 + endif + + execute printf('silent! 0r%s', templates[0]) + call expand_include_vars() + call expand_tmpl_vars() + set nomodified +endfunction + +function! tmpl#TemplateCommandCompletion(arglead, cmdline, cursorpos) abort + " Why use a dictionary? So we don't repeat values! Given there can be multiple + " environments it's likely there will be repeat types, and since there's + " multiple environments, well, there's repeat environments. + let resultset = {} + let templates = templates_for_glob('*') + let num_args = len(split(a:cmdline, ' ')) + + for tmpl_file in templates + if num_args == 1 + " Format first + let resultset[fnamemodify(tmpl_file, ':e')] = 1 + elseif num_args == 2 + " Environment second + let resultset[fnamemodify(tmpl_file, ':t:r')] = 1 + endif + endfor + + return keys(resultset) +endfunction + +function! s:templates_for_glob(glob) abort + let templates = filter(split(globpath(&runtimepath, printf('templates/%s', a:glob)), "\n"), 'filereadable(v:val)') + if empty(templates) + return [] + endif + + return templates +endfunction + +function! s:expand_tmpl_vars() abort + let old_winstate = winsaveview() + let old_query = getreg('/') + + let [matchline, matchcol] = searchpos(s:tmplVarTag) + let template_vars = get(g:, 'tmplvim_template_vars', {'KEY': 'MYKEY'}) + while matchline != 0 + let matches = matchlist(getline(matchline), printf('^%s', s:tmplVarTag), matchcol-1) + if len(matches) > 0 + let key = matches[1] + let value = '' + + if key ==# 'DATE' + let value = strftime('%Y-%m-%d') + elseif key ==# 'YEAR' + let value = strftime('%Y') + elseif key ==# 'TIME' + let value = strftime('%H:%M:%S') + elseif key ==# 'AUTHOR' + let value = get(g:, 'tmplvim_author', expand($USER)) + elseif key ==# 'DIRNAME' + let value = expand('%:p:h:t') + elseif key ==# 'BASENAME' + let value = expand('%:t:r') + elseif key ==# 'UPPERBASENAME' + let value = toupper(expand('%:t:r')) + elseif index(keys(template_vars), key) != -1 + let value = template_vars[matches[1]] + endif + + execute printf('silent %ds/^.\{%d\}\zs%s/%s/g', matchline, (matchcol-1), escape(matches[0], s:specialChars), expand(value, s:specialChars)) + endif + + let [matchline, matchcol] = searchpos(s:tmplVarTag) + endwhile + + call setreg('/', old_query) + call winrestview(old_winstate) +endfunction + +function! s:expand_include_vars() + let old_winstate = winsaveview() + let old_query = getreg('/') + let format = expand('%:e') + + let [matchline, matchcol] = searchpos(s:tmplIncludeTag) + while matchline != 0 + let matches = matchlist(getline(matchline), printf('^%s', s:tmplIncludeTag), matchcol-1) + if len(matches) > 0 + let templates = templates_for_glob(matches[1]) + if !empty(templates) + let tmpl_file = templates[0] + if filereadable(printf('%s.%s', tmpl_file, format)) + let tmpl_file = printf('%s.%s', tmpl_file, format) + endif + execute printf('silent! %ds/^.\{%d\}\zs%s//', matchline, (matchcol-1), escape(matches[0], s:specialChars)) + execute printf('silent! %dr%s', matchline-1, tmpl_file) + endif + endif + + let [matchline, matchcol] = searchpos(s:tmplIncludeTag) + endwhile + + call setreg('/', old_query) + call winrestview(old_winstate) +endfunction diff --git a/doc/tmpl.vim.txt b/doc/tmpl.vim.txt new file mode 100644 index 0000000..1cebba9 --- /dev/null +++ b/doc/tmpl.vim.txt @@ -0,0 +1,131 @@ +*tmpl.vim* + +tmpl.vim - vim file templates + +================================================================================= +CONTENTS *tmpl.vim-contents* + + 1. Introduction................................|tmpl.vim-introduction| + 1.1. Examples................................|tmpl.vim-examples| + 2. Global Options..............................|tmpl.vim-options| + 3. Commands....................................|tmpl.vim-commands| + 4. Template Tags...............................|tmpl.vim-tags| + 4.1. Variables...............................|tmpl.vim-tags-variables| + 4.2. Includes................................|tmpl.vim-tags-include| + +================================================================================= +1. Introduction *tmpl.vim-introduction* + +tmpl.vim provides automated loading of templates for new files. You can load +templates for a specific environment, including on a per-buffer basis, for +various file types. Template files are kept in the |'runtimepath'|, allowing you +to easily add your own templates separately from this plugin (and other plugins +can contribute plugins). + +Templates are loaded from a directory named `templates` on the |'runtimepath'|. +The name of the template to load is constructed: + +1. The template environment is found (if none is given the default comes from + |g:tmplvim_default_environment|, or `default` if that is undefined). The + template environment may be overridden in each buffer by setting + |b:tmplvim_default_environment|. +2. The file extension is converted to lower-case and added to the template name. +3. If no file extension is found, the name of the file is converted to + lower-case and added to the template name as an extension. + +--------------------------------------------------------------------------------- +1.1 Examples *tmpl.vim-examples* + +1. For a buffer with no name, no template file will be loaded automatically. +2. A buffer for `module.PY` will load the template `default.py`. +3. A buffer for `setup.sh` will load the template `default.sh`. +4. A buffer for `TARGETS` will load the template `default.targets`. +5. A buffer for `Makefile` with |g:tmplvim_default_environment| set to + `workplace` will load the template `workplace.makefile`. +6. A buffer for `setup.py` with |b:tmplvim_default_environment| set to + `myproject` will load the template `myproject.py`. + +================================================================================= +2. Global Options *tmpl.vim-options* + +g:tmplvim_default_environment *g:tmplvim_default_environment* + *b:tmplvim_default_environment* + Type: |String| + Default: `'default'` + + Set the default template base name. This can be overridden on a per-buffer + basis by setting `b:tmplvim_default_environment`. + +g:tmplvim_template_vars *g:tmplvim_template_vars* + + Type: |Dictionary| + Default: `{}` + + Map template variables to the preferred value. Template variables are special + tags in a template file which are expanded when the template is inserted into + a buffer. The tag `<#TAG_NAME#>` requires `TAG_NAME` to be present in + `g:tmplvim_template_vars` and will be replaced with the value of the + |Dictionary| entry. Any tags without a corresponding entry will be ignored. + +g:tmplvim_author *g:tmplvim_author* + + Type: |String| + Default: `$USER` + + The value to replace the template variable tag (see |tmplvim-tags-variables|) + `AUTHOR` with. If not given, the value of the `$USER` environment variable + will be the default value. + +================================================================================= +3. Commands *tmpl.vim-commands* + +LoadTemplateFile `name` *LoadTemplateFile* + + Load a template file into the current buffer. If `name` is given use that, + otherwise the value of |g:tmplvim_default_environment| will be used. + +================================================================================= +4. Template Tags *tmpl.vim-tags* + +Templates may contain tags which will be automatically expanded when the +template is loaded into the buffer. There are two types of tags: + +1. Template variables (|tmpl.vim-tags-variables|) +2. Template includes (|tmpl.vim-tags-include|) + +Template includes are processed first, then variables once includes have been +inserted into the buffer. Nested includes are not currently supported. + +--------------------------------------------------------------------------------- +4.1. Template variables *tmpl.vim-tags-variables* + +Template variable tags are upper-case letters surrounded by `<#` and `#>`. The +value of a template variable comes from |g:tmplvim_template_vars|, except for +some specific reserved tag names: + +1. `DATE`: Always replaced with the value of `strftime('%Y-%m-%d')` (e.g. + `2020-03-04`, see |strftime()|) +2. `YEAR`: Always replaced with the value of `strftime('%Y')` (e.g. `2020`, see + |strftime()|) +3. `TIME`: Always replaced with the value of `strftime('%H:%M:%S')` (e.g. + `13:03:34`, see |strftime()|) +4. `AUTHOR`: Always replaced with the value of |g:tmplvim_author|, or the value + of `$USER` if that is not set. +5. `DIRNAME`: Always replaced with the name of the directory the file is in. +6. `BASENAME`: Always replaced with the name of the file without extensions. +7. `UPPERBASENAME`: Always replaced with the name of the file without extensions + in upper-case. + +--------------------------------------------------------------------------------- +4.2. Template includes *tmpl.vim-tags-include* + +Template include tags are letters, numbers, or periods surrounded by `<$` and +`$>`. The tag name is expected to be the name of another template, which may +include template variables but may not include other template includes. For +example, the include tag `<$ LICENSE.MIT $>` will be replaced with the contents +of the template file named `LICENSE.MIT`. + +To accommodate including files in source code templates, an include with the +same extension as the current buffer will be searched for and preferred if +found. For example, the include tag `<$ LICENSE.MIT $>` in `setup.py` would use +the template named `LICENSE.MIT.py` if it exists, or `LICENSE.MIT` if not. diff --git a/plugin/tmpl.vim b/plugin/tmpl.vim new file mode 100644 index 0000000..69a6a5c --- /dev/null +++ b/plugin/tmpl.vim @@ -0,0 +1,6 @@ +" vim: set syntax=vim filetype=vim noexpandtab ts=2 sts=2 sw=2 autoindent: +" vim: set foldmarker=[[[,]]] foldmethod=marker foldlevel=0: + +autocmd BufNewFile * silent call tmpl#LoadTemplateFile() + +command! -complete=customlist,tmpl#TemplateCommandCompletion -nargs=+ LoadTemplateFile call tmpl#LoadTemplateFile() diff --git a/templates/LICENSE.BSD3 b/templates/LICENSE.BSD3 new file mode 100644 index 0000000..e441101 --- /dev/null +++ b/templates/LICENSE.BSD3 @@ -0,0 +1,24 @@ +Copyright (c) <# YEAR #>, <# AUTHOR #> +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/templates/LICENSE.BSD3.sh b/templates/LICENSE.BSD3.sh new file mode 100644 index 0000000..3bc74dd --- /dev/null +++ b/templates/LICENSE.BSD3.sh @@ -0,0 +1,24 @@ +# Copyright (c) <# YEAR #>, <# AUTHOR #> +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/templates/LICENSE.MIT b/templates/LICENSE.MIT new file mode 100644 index 0000000..7abb138 --- /dev/null +++ b/templates/LICENSE.MIT @@ -0,0 +1,21 @@ +The MIT License + +Copyright (C) <# YEAR #> by <# AUTHOR #> + +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. diff --git a/templates/LICENSE.MIT.c b/templates/LICENSE.MIT.c new file mode 100644 index 0000000..97c1067 --- /dev/null +++ b/templates/LICENSE.MIT.c @@ -0,0 +1,21 @@ +// The MIT License +// +// Copyright (C) <# YEAR #> by <# AUTHOR #> +// +// 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. diff --git a/templates/LICENSE.MIT.h b/templates/LICENSE.MIT.h new file mode 100644 index 0000000..97c1067 --- /dev/null +++ b/templates/LICENSE.MIT.h @@ -0,0 +1,21 @@ +// The MIT License +// +// Copyright (C) <# YEAR #> by <# AUTHOR #> +// +// 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. diff --git a/templates/LICENSE.MIT.sh b/templates/LICENSE.MIT.sh new file mode 100644 index 0000000..2505137 --- /dev/null +++ b/templates/LICENSE.MIT.sh @@ -0,0 +1,21 @@ +# The MIT License +# +# Copyright (C) <# YEAR #> by <# AUTHOR #> +# +# 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. diff --git a/templates/default.c b/templates/default.c new file mode 100644 index 0000000..e0ec53d --- /dev/null +++ b/templates/default.c @@ -0,0 +1,8 @@ +// vim: set filetype=c syntax=c autoindent noexpandtab sts=2 ts=2 sw=2: +// vim: foldmethod=marker foldmarker=[[[,]]]: + +<$ LICENSE.MIT $> + +#include +#include +#include "<# BASENAME #>.h" diff --git a/templates/default.go b/templates/default.go new file mode 100644 index 0000000..60a9eb4 --- /dev/null +++ b/templates/default.go @@ -0,0 +1,4 @@ +// vim: set filetype=go syntax=go noexpandtab ts=2 sts=2 sw=2 foldmethod=marker: +// vim: set foldmarker=[[[,]]]: +// Package <# DIRNAME #> is +package <# DIRNAME #> diff --git a/templates/default.h b/templates/default.h new file mode 100644 index 0000000..7ba5575 --- /dev/null +++ b/templates/default.h @@ -0,0 +1,12 @@ +// vim: set filetype=c syntax=c autoindent noexpandtab sts=2 ts=2 sw=2: +// vim: foldmethod=marker foldmarker=[[[,]]]: + +<$ LICENSE.MIT $> + +#ifndef __<# UPPERBASENAME #>_H__ +#define __<# UPPERBASENAME #>_H__ + +#include +#include + +#endif diff --git a/templates/default.html b/templates/default.html new file mode 100644 index 0000000..afae5c5 --- /dev/null +++ b/templates/default.html @@ -0,0 +1,16 @@ + + + + TITLE + + + + + + + diff --git a/templates/default.py b/templates/default.py new file mode 100644 index 0000000..cee5a69 --- /dev/null +++ b/templates/default.py @@ -0,0 +1,2 @@ +#!/usr/bin/env python3 +# vim: set expandtab sw=4 ts=4 sts=4 foldmethod=indent filetype=python syntax=python: diff --git a/templates/default.sh b/templates/default.sh new file mode 100644 index 0000000..b6755cb --- /dev/null +++ b/templates/default.sh @@ -0,0 +1,5 @@ +#!/bin/sh +# vim: set filetype=sh noexpandtab ts=2 sts=2 sw=2 foldmethod=marker: +# vim: set foldmarker=[[[,]]]: + +set -e diff --git a/templates/default.tex b/templates/default.tex new file mode 100644 index 0000000..de86450 --- /dev/null +++ b/templates/default.tex @@ -0,0 +1,19 @@ +% vim: set autoindent sts=4 ts=4 sw=4 noexpandtab foldmethod=syntax + +\documentclass{article} + +\usepackage{url} +\usepackage{graphicx} +\usepackage{hyperref} +\usepackage{amsmath} + +\title{TITLE} +\author{<# AUTHOR #>} + +\begin{document} + +\maketitle + +\section{SECTION} + +\end{document}