Vim: Switch vim-template to submodule

This commit is contained in:
Salt 2018-01-29 15:01:38 -06:00
parent 5412b36eb8
commit 2865099793
53 changed files with 4 additions and 1408 deletions

3
.gitmodules vendored
View File

@ -7,3 +7,6 @@
[submodule ".vim/bundle/SimpylFold"]
path = .vim/bundle/SimpylFold
url = git@github.com:tmhedberg/SimpylFold.git
[submodule ".vim/bundle/vim-template"]
path = .vim/bundle/vim-template
url = git@github.com:aperezdc/vim-template.git

@ -0,0 +1 @@
Subproject commit 606d5d419bd07e4085fd95ee578d03f35088c844

View File

@ -1,73 +0,0 @@
=============================
Simple Vim templates plugin
=============================
:Author: Adrian Perez <aperez@igalia.com>
This is a simple plugin for Vim that will allow you to have a set of
templates for certain file types. It is useful to add boilerplate code
like guards in C/C++ headers, or license disclaimers.
Installation
============
The easiest way to install the plugin is to install it as a bundle.
For example, using Pathogen__:
1. Get and install `pathogen.vim <https://github.com/tpope/vim-pathogen>`_. You can skip this step
if you already have it installed.
2. ``cd ~/.vim/bundle``
3. ``git clone git://github.com/aperezdc/vim-template.git``
__ https://github.com/tpope/vim-pathogen
Bundle installs are known to work fine also when using Vundle__. Other
bundle managers are expected to work as well.
__ https://github.com/gmarik/vundle
.. important:: If you use Fish__ as your shell, you *will* need to add
``set shell=/bin/sh`` to your ``~/.vimrc`` — the plugin relies on the
setting pointing to a Bourne-compatible__ shell.
__ http://fishshell.com/
__ https://en.wikipedia.org/wiki/Bourne_shell
Documentation
=============
The documentation can be browsed directly in Vim::
:help template.txt
Alternatively, you can also `read it in your browser`__.
__ https://github.com/aperezdc/vim-template/blob/master/doc/template.txt
Updating
========
Manually
--------
In order to update the plugin, go to its bundle directory and use
Git to update it:
1. ``cd ~/.vim/bundle/vim-template``
2. ``git pull``
With Vundle
-----------
Use the ``:BundleUpdate`` command provided by Vundle, for example invoking
Vim like this::
% vim +BundleUpdate

View File

@ -1,289 +0,0 @@
*template.txt* Simple templates plug-in
CONTENTS *template-contents*
Introduction |template-introduction|
Usage |template-usage|
Commands |template-commands|
Configuration |template-configuration|
Search order |template-search-order|
Variables |template-variables|
User Variables |template-user-variables|
Troubleshooting |template-troubleshooting|
===========================================================================
INTRODUCTION *template-introduction*
This is a simple plug-in for Vim (and NeoVim) allowing to have template
files per file type, which will be used as starting point when creating
new buffers. Template files may contain variables (|template-variables|),
which are expanded at the time of buffer creation (see |template-usage|).
The main purpose of the templates is to add boilerplate code to new
files, like C/C++ header guards, or license disclaimers.
===========================================================================
USAGE *template-usage*
Templates can be used by creating a new file name, the file suffix will
determine which template is used:
>
$ vim foo.c
<
Templates can be manually expanded in the current buffer using the
|:Template| command. For example, the following will load and expand the
template for a file matching the pattern `*.c`:
>
:Template *.c
<
Note that automatic insertion of templates can be disabling by setting
the `g:templates_no_autocmd` variable.
===========================================================================
COMMANDS *template-commands*
The plug-in defines two commands, both of which expand a template in the
current buffer. The first expands a matched template at the beginning of
the current buffer. Its syntax is:
*:Template* <pattern>
The <pattern> must be the same as for the template file that is to be
expanded into the current buffer. For example:
>
:Template *.c
>
will expand the local template `.vim-template:*.c`, or the global template
`template:*.c`, whichever is found first (see |template-search-order|
for more information).
The second command works exactly the same except that it will expand a matched
template under the cursor instead of at the beginning of the buffer. Its syntax
is:
*:TemplateHere* <pattern>
===========================================================================
CONFIGURATION *template-configuration*
The following variables can be used to configure the behaviour of the
plug-in:
`g:templates_no_autocmd`
Whether to disable automatic insertion of templates when new
buffers are created. (Default: `0`).
`g:templates_directory`
Path of a directory containing additional global templates.
Alternatively, it can contain a list of paths, which will
be searched in order. See |template-search-order| for more
details. (Default: `[]`).
`g:templates_name_prefix`
Prefix for path-relative templates. See |template-search-order|
for more details. (Default: `.vim-template:`).
`g:templates_global_name_prefix`
Prefix for global templates (builtin and those listed in
`g:templates_directory`, NOT path-relative templates). See
|template-search-order| for more details. (Default:
`=template=`).
`g:templates_fuzzy_start`
If non-zero, template patterns are not forced to match the
entire file name, just the end (`<pattern>$`). If zero, template
patterns need to consume the entire file name to procure a match
(`^<pattern>$`). For example, if `g:templates_fuzzy_start = 1`,
a file named `template:.c` would match files named `.c` and
`test.c`. If set to zero, the template would only match `.c`
(Default: `1`).
`g:templates_tr_in`, and `g:templates_tr_out`
These variables control how template names are interpreted as
regular expressions for matching file names. This can be
useful on a Windows box where `*` is not allowed in file
names. The default configuration converts underscores (`_`)
into regular expression wildcards (`.*`).
(Default: `['.','*','?']`, and `['\.','.*','\?']`).
`g:templates_no_builtin_templates`
If non-zero, disables usage of the built-in templates. See
|template-search-order| for more details. (Default: `0`).
`g:templates_user_variables`
Allows expansion of user-defined variables. See
|template-user-variables| for more details.
(Default: `[]`).
`g:templates_debug`
If non-zero, output debugging information. (Default: `0`).
`g:templates_plugin_loaded`
Setting this to a non-zero value will disable the plug-in.
(Default: `0`).
`g:templates_search_height`
Controls the search in the current directory and parents. If
set to -1, the template is searched for in the given
directory and all parents in its directory structure, stopping
at the first matching template. If set to 0, no searching
is done in the given directory or any parents. If set to [1]
only the given directory is searched. If greater
than one, n parents and the given directory will be searched
where n is equal to height - 1. (Default: `-1`).
===========================================================================
SEARCH ORDER *template-search-order*
Searching for templates uses the following logic:
1. If a file named `.vim-template:<pattern>` exists in the current
directory, it is used. If there are multiple template files that match
pattern in the same directory, the one that is most specific is used.
If no suitable template is found, goto step `(2)`.
2. If a parent directory exists, it is set as current directory, and goto
step `(1)`; otherwise goto step `(3)`.
3. Try to use `=template=<pattern>` file from the directories specified using
the `g:templates_directory` variable (only if the option is defined,
and the directory exists).
4. Try to use the `=template=<pattern>` file supplied with the plug-in (only
if `g:templates_no_builtin_templates` is undefined or has a zero value).
Note that the `.vim-template:` local file prefix can be set using the
`g:templates_name_prefix` variable, and the `=template=` global file prefix
can be set using the `g:templates_global_name_prefix` variable. The variable
`g:templates_search_height` controls searching the current directory and
parents.
===========================================================================
VARIABLES *template-variables*
Template variables are all-caps identifiers surrounded by percent signs,
e.g. `%VAR%`. The following variables are available for expansion in
templates:
`%DAY%`, `%YEAR%`, `%MONTH`
Current day of the month, year, and month of the year,
as numeric values.
`%DATE%`
Current date in `YYYY-mm-dd` format. This is equivalent
to expanding `%YEAR%-%MONTH%-%DAY%`.
`%TIME%`
Current time in `HH:MM` format.
`%FDATE%`
Current full date (date and time) in `YYYY-mm-ddHH:MM`
format. This is equivalent to expanding `%DATE%%TIME%`.
`%FILE%`
File name, without extension.
`%EXT%`
File extension (component after the last period).
`%FFILE%`
File name, with extension. This is equivalent to
expanding `%FILE%.%EXT%`.
`%MAIL%`
E-mail address of the current user. May be overriden by
defining the `g:email` variable.
`%USER%`
Current logged-in user name. May be overriden by defining
the `g:username` variable.
`%LICENSE%`
Expands to the string `MIT` by default. May be overriden
by definining the `g:license` variable.
`%HOST%`
Current host name.
`%GUARD%`
A string containing only alphanumeric characters, and
underscores, suitable to be used as preprocessor guards
for C/C++/Objective-C header file.
`%CLASS%`
File name, without extension, and the first character of
each word capitalised. This is typically used for Java/C++
class names.
`%MACROCLASS%`
File name, without extension, in all-capitals.
`%CAMELCLASS%`
File name, without extension, with the first character of
every work capitalised, and underscores removed.
`%HERE%`
Expands to nothing, but ensures that the cursor will be placed in
the position where this variable appears after expanding the template.
===========================================================================
USER VARIABLES *template-user-variables*
The `g:templates_user_variables` variable allows to expand user-defined
variables in templates. It should be set to an array, where each item is
a two-element array: the first element is the name of the user-defined
variable, and the second element the name of a function. For example,
the following can be added to the user |vimrc|:
>
let g:templates_user_variables = [
\ ['FULLPATH', 'GetFullPath'],
\ ]
function! GetFullPath()
return expand('%:p')
endfunction
>
This way, each occurrence of `%FULLPATH%` in a template will be replaced
with the absolute path of the current file.
===========================================================================
TROUBLESHOOTING *template-troubleshooting*
Q: Why are no templates found by the plugin?
A: Make sure you are using a Bourne-compatible shell. Vim will pick by
default the value of the `$SHELL` environment variable. If you are using
a non-Bourn shell (like Fish, for example), you can tell Vim to use a
different one by using the 'shell' option. This should not be needed
in non-Unix systems, so you may want to add the following snippet to
your `vimrc`:
>
if has('unix')
set shell=/bin/sh
endif
<
---
Q: How can I debug how the plugin looks up templates?
A: Add `set g:templates_debug = 1` in your `vimrc`.
---
Q: My question is not answered here. How can I contact the developers?
A: Please file an issue at https://github.com/aperezdc/vim-template/issues
We have a `question` category for the issues which you can check to see
whether others have had the same question before. Eventually, the most
common questions may end up in the |template-troubleshooting| section of
the documentation (this one you are reading).
vim:tw=78:sw=8:ts=8:ft=help:norl:noet

View File

@ -1,523 +0,0 @@
"
" Template system for Vim
"
" Copyright (C) 2012 Adrian Perez de Castro <aperez@igalia.com>
" Copyright (C) 2005 Adrian Perez de Castro <the.lightman@gmail.com>
"
" Distributed under terms of the MIT license.
"
if exists("g:templates_plugin_loaded")
finish
endif
let g:templates_plugin_loaded = 1
if !exists('g:templates_name_prefix')
let g:templates_name_prefix = ".vim-template:"
endif
if !exists('g:templates_global_name_prefix')
let g:templates_global_name_prefix = "=template="
endif
if !exists('g:templates_debug')
let g:templates_debug = 0
endif
if !exists('g:templates_tr_in')
let g:templates_tr_in = [ '.', '*', '?' ]
endif
if !exists('g:templates_tr_out')
let g:templates_tr_out = [ '\.', '.*', '\?' ]
endif
if !exists('g:templates_fuzzy_start')
let g:templates_fuzzy_start = 1
endif
if !exists('g:templates_search_height')
" First try to find the deprecated option
if exists('g:template_max_depth')
echom('g:template_max_depth is deprecated in favor of g:templates_search_height')
let g:templates_search_height = g:template_max_depth != 0 ? g:template_max_depth : -1
endif
if(!exists('g:templates_search_height'))
let g:templates_search_height = -1
endif
endif
if !exists('g:templates_directory')
let g:templates_directory = []
elseif type(g:templates_directory) == type('')
" Convert string value to a list with one element.
let s:tmp = g:templates_directory
unlet g:templates_directory
let g:templates_directory = [ s:tmp ]
unlet s:tmp
endif
if !exists('g:templates_no_builtin_templates')
let g:templates_no_builtin_templates = 0
endif
if !exists('g:templates_user_variables')
let g:templates_user_variables = []
endif
" Put template system autocommands in their own group. {{{1
if !exists('g:templates_no_autocmd')
let g:templates_no_autocmd = 0
endif
if !g:templates_no_autocmd
augroup Templating
autocmd!
autocmd BufNewFile * call <SID>TLoad()
augroup END
endif
function <SID>Debug(mesg)
if g:templates_debug
echom(a:mesg)
endif
endfunction
" normalize the path
" replace the windows path sep \ with /
function <SID>NormalizePath(path)
return substitute(a:path, "\\", "/", "g")
endfunction
" Template searching. {{{1
" Returns a string containing the path of the parent directory of the given
" path. Works like dirname(3). It also simplifies the given path.
function <SID>DirName(path)
let l:tmp = <SID>NormalizePath(a:path)
return substitute(l:tmp, "[^/][^/]*/*$", "", "")
endfunction
" Default templates directory
let s:default_template_dir = <SID>DirName(<SID>DirName(expand("<sfile>"))) . "templates"
" Find the target template in windows
"
" In windows while we clone the symbol link from github
" it will turn to normal file, so we use this function
" to figure out the destination file
function <SID>TFindLink(path, template)
if !filereadable(a:path . a:template)
return a:template
endif
let l:content = readfile(a:path . a:template, "b")
if len(l:content) != 1
return a:template
endif
if filereadable(a:path . l:content[0])
return <SID>TFindLink(a:path, l:content[0])
else
return a:template
endif
endfunction
" Translate a template file name into a regular expression to test for matching
" against a given filename. As of writing this behavior is something like this:
" (with a g:templates_name_prefix set as 'template.')
"
" template.py -> ^.*py$
"
" template.test.py -> ^.*test.py$
"
function <SID>TemplateToRegex(template, prefix)
let l:template_base_name = fnamemodify(a:template,":t")
let l:template_glob = strpart(l:template_base_name, len(a:prefix))
" Translate the template's glob into a normal regular expression
let l:in_escape_mode = 0
let l:template_regex = ""
for l:c in split(l:template_glob, '\zs')
if l:in_escape_mode == 1
if l:c == '\'
let l:template_regex = l:template_regex . '\\'
else
let l:template_regex = l:template_regex . l:c
endif
let l:in_escape_mode = 0
else
if l:c == '\'
let l:in_escape_mode = 1
else
let l:tr_index = index(g:templates_tr_in, l:c)
if l:tr_index != -1
let l:template_regex = l:template_regex . g:templates_tr_out[l:tr_index]
else
let l:template_regex = l:template_regex . l:c
endif
endif
endif
endfor
if g:templates_fuzzy_start
return l:template_regex . '$'
else
return '^' . l:template_regex . '$'
endif
endfunction
" Given a template and filename, return a score on how well the template matches
" the given filename. If the template does not match the file name at all,
" return 0
function <SID>TemplateBaseNameTest(template, prefix, filename)
let l:tregex = <SID>TemplateToRegex(a:template, a:prefix)
" Ensure that we got a valid regex
if l:tregex == ""
return 0
endif
" For now only use the base of the filename.. this may change later
" *Note* we also have to be careful because a:filename may also be the passed
" in text from TLoadCmd...
let l:filename_chopped = fnamemodify(a:filename,":t")
" Check for a match
let l:regex_result = match(l:filename_chopped,l:tregex)
if l:regex_result != -1
" For a match return a score based on the regex length
return len(l:tregex)
else
" No match
return 0
endif
endfunction
" Returns the most specific / highest scored template file found in the given
" path. Template files are found by using a glob operation on the current path
" and the setting of g:templates_name_prefix. If no template is found in the
" given directory, return an empty string
function <SID>TDirectorySearch(path, template_prefix, file_name)
let l:picked_template = ""
let l:picked_template_score = 0
" Use find if possible as it will also get hidden files on nix systems. Use
" builtin glob as a fallback
if executable("find") && !has("win32") && !has("win64")
let l:find_cmd = '`find -L ' . shellescape(a:path) . ' -maxdepth 1 -type f -name ' . shellescape(a:template_prefix . '*' ) . '`'
call <SID>Debug("Executing " . l:find_cmd)
let l:glob_results = glob(l:find_cmd)
if v:shell_error != 0
call <SID>Debug("Could not execute find command")
unlet l:glob_results
endif
endif
if !exists("l:glob_results")
call <SID>Debug("Using fallback glob")
let l:glob_results = glob(a:path . a:template_prefix . "*")
endif
let l:templates = split(l:glob_results, "\n")
for template in l:templates
" Make sure the template is readable
if filereadable(template)
let l:current_score =
\<SID>TemplateBaseNameTest(template, a:template_prefix, a:file_name)
call <SID>Debug("template: " . template . " got scored: " . l:current_score)
" Pick that template only if it beats the currently picked template
" (here we make the assumption that template name length ~= template
" specifity / score)
if l:current_score > l:picked_template_score
let l:picked_template = template
let l:picked_template_score = l:current_score
endif
endif
endfor
if l:picked_template != ""
call <SID>Debug("Picked template: " . l:picked_template)
else
call <SID>Debug("No template found")
endif
return l:picked_template
endfunction
" Searches for a [template] in a given [path].
"
" If [height] is [-1] the template is searched for in the given directory and
" all parents in its directory structure
"
" If [height] is [0] no searching is done in the given directory or any
" parents
"
" If [height] is [1] only the given directory is searched
"
" If [height] is greater than one, n parents and the given directory will be
" searched where n is equal to height - 1
"
" If no template is found an empty string is returned.
"
function <SID>TSearch(path, template_prefix, file_name, height)
if (a:height != 0)
" pick a template from the current path
let l:picked_template = <SID>TDirectorySearch(a:path, a:template_prefix, a:file_name)
if l:picked_template != ""
return l:picked_template
else
let l:pathUp = <SID>DirName(a:path)
if l:pathUp != a:path
let l:new_height = a:height >= 0 ? a:height - 1 : a:height
return <SID>TSearch(l:pathUp, a:template_prefix, a:file_name, l:new_height)
endif
endif
endif
" Ooops, either we cannot go up in the path or [height] reached 0
return ""
endfunction
" Tries to find valid templates using the global g:templates_name_prefix as a glob
" matcher for template files. The search is done as follows:
" 1. The [path] passed to the function, [upwards] times up.
" 2. The g:templates_directory directory, if it exists.
" 3. Built-in templates from s:default_template_dir.
" Returns an empty string if no template is found.
"
function <SID>TFind(path, name, up)
let l:tmpl = <SID>TSearch(a:path, g:templates_name_prefix, a:name, a:up)
if l:tmpl != ''
return l:tmpl
endif
for l:directory in g:templates_directory
let l:directory = <SID>NormalizePath(expand(l:directory) . '/')
if isdirectory(l:directory)
let l:tmpl = <SID>TSearch(l:directory, g:templates_global_name_prefix, a:name, 1)
if l:tmpl != ''
return l:tmpl
endif
endif
endfor
if g:templates_no_builtin_templates
return ''
endif
return <SID>TSearch(<SID>NormalizePath(expand(s:default_template_dir) . '/'), g:templates_global_name_prefix, a:name, 1)
endfunction
" Escapes a string for use in a regex expression where the regex uses / as the
" delimiter. Must be used with Magic Mode off /V
"
function <SID>EscapeRegex(raw)
return escape(a:raw, '/')
endfunction
" Template variable expansion. {{{1
" Makes a single [variable] expansion, using [value] as replacement.
"
function <SID>TExpand(variable, value)
silent! execute "%s/\\V%" . <SID>EscapeRegex(a:variable) . "%/" . <SID>EscapeRegex(a:value) . "/g"
endfunction
" Performs variable expansion in a template once it was loaded {{{2
"
function <SID>TExpandVars()
" Date/time values
let l:day = strftime("%d")
let l:year = strftime("%Y")
let l:month = strftime("%m")
let l:monshort = strftime("%b")
let l:monfull = strftime("%B")
let l:time = strftime("%H:%M")
let l:date = exists("g:dateformat") ? strftime(g:dateformat) :
\ (l:year . "-" . l:month . "-" . l:day)
let l:fdate = l:date . " " . l:time
let l:filen = expand("%:t:r:r:r")
let l:filex = expand("%:e")
let l:filec = expand("%:t")
let l:fdir = expand("%:p:h:t")
let l:hostn = hostname()
let l:user = exists("g:username") ? g:username :
\ (exists("g:user") ? g:user : $USER)
let l:email = exists("g:email") ? g:email : (l:user . "@" . l:hostn)
let l:guard = toupper(substitute(l:filec, "[^a-zA-Z0-9]", "_", "g"))
let l:class = substitute(l:filen, "\\([a-zA-Z]\\+\\)", "\\u\\1\\e", "g")
let l:macroclass = toupper(l:class)
let l:camelclass = substitute(l:class, "_", "", "g")
" Finally, perform expansions
call <SID>TExpand("DAY", l:day)
call <SID>TExpand("YEAR", l:year)
call <SID>TExpand("DATE", l:date)
call <SID>TExpand("TIME", l:time)
call <SID>TExpand("USER", l:user)
call <SID>TExpand("FDATE", l:fdate)
call <SID>TExpand("MONTH", l:month)
call <SID>TExpand("MONTHSHORT", l:monshort)
call <SID>TExpand("MONTHFULL", l:monfull)
call <SID>TExpand("FILE", l:filen)
call <SID>TExpand("FFILE", l:filec)
call <SID>TExpand("FDIR", l:fdir)
call <SID>TExpand("EXT", l:filex)
call <SID>TExpand("MAIL", l:email)
call <SID>TExpand("HOST", l:hostn)
call <SID>TExpand("GUARD", l:guard)
call <SID>TExpand("CLASS", l:class)
call <SID>TExpand("MACROCLASS", l:macroclass)
call <SID>TExpand("CAMELCLASS", l:camelclass)
call <SID>TExpand("LICENSE", exists("g:license") ? g:license : "MIT")
" Perform expansions for user-defined variables
for [l:varname, l:funcname] in g:templates_user_variables
let l:value = function(funcname)()
call <SID>TExpand(l:varname, l:value)
endfor
endfunction
" }}}2
" Puts the cursor either at the first line of the file or in the place of
" the template where the %HERE% string is found, removing %HERE% from the
" template.
"
function <SID>TPutCursor()
0 " Go to first line before searching
if search("%HERE%", "W")
let l:column = col(".")
let l:lineno = line(".")
s/%HERE%//
call cursor(l:lineno, l:column)
endif
endfunction
" File name utils
"
" Ensures that the given file name is safe to be opened and will not be shell
" expanded
function <SID>NeuterFileName(filename)
let l:neutered = fnameescape(a:filename)
call <SID>Debug("Neutered " . a:filename . " to " . l:neutered)
return l:neutered
endfunction
" Template application. {{{1
" Loads a template for the current buffer, substitutes variables and puts
" cursor at %HERE%. Used to implement the BufNewFile autocommand.
"
function <SID>TLoad()
if !line2byte( line( '$' ) + 1 ) == -1
return
endif
let l:file_name = expand("%:p")
let l:file_dir = <SID>DirName(l:file_name)
let l:depth = g:templates_search_height
let l:tFile = <SID>TFind(l:file_dir, l:file_name, l:depth)
call <SID>TLoadTemplate(l:tFile, 0)
endfunction
" Like the previous one, TLoad(), but intended to be called with an argument
" that either is a filename (so the file is loaded as a template) or
" a template suffix (and the template is searched as usual). Of course this
" makes variable expansion and cursor positioning.
"
function <SID>TLoadCmd(template, position)
if filereadable(a:template)
let l:tFile = a:template
else
let l:height = g:templates_search_height
let l:tName = g:templates_global_name_prefix . a:template
let l:file_name = expand("%:p")
let l:file_dir = <SID>DirName(l:file_name)
let l:tFile = <SID>TFind(l:file_dir, a:template, l:height)
endif
call <SID>TLoadTemplate(l:tFile, a:position)
endfunction
" Load the given file as a template
function <SID>TLoadTemplate(template, position)
if a:template != ""
let l:deleteLastLine = 0
if line('$') == 1 && getline(1) == ''
let l:deleteLastLine = 1
endif
" Read template file and expand variables in it.
let l:safeFileName = <SID>NeuterFileName(a:template)
if a:position == 0 || l:deleteLastLine == 1
execute "keepalt 0r " . l:safeFileName
else
execute "keepalt r " . l:safeFileName
endif
call <SID>TExpandVars()
if l:deleteLastLine == 1
" Loading a template into an empty buffer leaves an extra blank line at the bottom, delete it
execute line('$') . "d _"
endif
call <SID>TPutCursor()
setlocal nomodified
endif
endfunction
" Commands {{{1
" Just calls the above function, pass either a filename or a template
" suffix, as explained before =)
"
fun ListTemplateSuffixes(A,P,L)
let l:templates = split(globpath(s:default_template_dir, g:templates_global_name_prefix . a:A . "*"), "\n")
let l:res = []
for t in templates
let l:suffix = substitute(t, ".*\\.", "", "")
call add(l:res, l:suffix)
endfor
return l:res
endfun
command -nargs=1 -complete=customlist,ListTemplateSuffixes Template call <SID>TLoadCmd("<args>", 0)
command -nargs=1 -complete=customlist,ListTemplateSuffixes TemplateHere call <SID>TLoadCmd("<args>", 1)
" Syntax autocommands {{{1
"
" Enable the vim-template syntax for template files
" Usually we'd put this in the ftdetect folder, but because
" g:templates_name_prefix doesn't get defined early enough we have to add the
" template detection from the plugin itself
execute "au BufNewFile,BufRead " . g:templates_name_prefix . "* "
\. "let b:vim_template_subtype = &filetype | "
\. "set ft=vim-template"
if !g:templates_no_builtin_templates
execute "au BufNewFile,BufRead "
\. s:default_template_dir . "/" . g:templates_global_name_prefix . "* "
\. "let b:vim_template_subtype = &filetype | "
\. "set ft=vim-template"
endif
for s:directory in g:templates_directory
let s:directory = <SID>NormalizePath(expand(s:directory) . '/')
if isdirectory(s:directory)
execute "au BufNewFile,BufRead "
\. s:directory . "/" . g:templates_global_name_prefix . "* "
\. "let b:vim_template_subtype = &filetype | "
\. "set ft=vim-template"
endif
unlet s:directory
endfor
" vim: fdm=marker

View File

@ -1,19 +0,0 @@
" vim-template syntax file
" Language: vim-template
" Maintainer: Lyude Paul <thatslyude@gmail.com>
" Last Change: 2014 April 21
if exists("b:current_syntax")
finish
endif
if b:vim_template_subtype != ""
execute "runtime! syntax/" . b:vim_template_subtype . ".vim"
unlet b:current_syntax
endif
syn match vimtemplateVariable "%\%(DAY\|YEAR\|MONTH\|MONTHSHORT\|MONTHFULL\|DATE\|TIME\|FILE\|FFILE\|EXT\|MAIL\|USER\|HOST\|GUARD\|CLASS\|MACROCLASS\|CAMELCLASS\|HERE\)%" containedin=ALL
let b:current_syntax = "vim-template"
hi def link vimtemplateVariable Constant

View File

@ -1,10 +0,0 @@
#! /bin/bash
#
# %FFILE%
# Copyright (C) %YEAR% %USER% <%MAIL%>
#
# Distributed under terms of the %LICENSE% license.
#
%HERE%

View File

@ -1,11 +0,0 @@
/*
* %FFILE%
* Copyright (C) %YEAR% %USER% <%MAIL%>
*
* Distributed under terms of the %LICENSE% license.
*/
#include "%FILE%.h"
%HERE%

View File

@ -1 +0,0 @@
=template=.c

View File

@ -1 +0,0 @@
=template=.c

View File

@ -1,13 +0,0 @@
cmake_minimum_required (VERSION 2.8)
# projectname is the same as the main-executable
project(%HERE%%FDIR%)
add_definitions('-g')
add_definitions('-Wall')
#add_definitions('-std=c++11')
add_executable(${PROJECT_NAME} ${PROJECT_NAME}.cpp)
add_custom_target(${PROJECT_NAME}-symlink ALL ln --force -s ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/${PROJECT_NAME} DEPENDS ${PROJECT_NAME})
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_SOURCE_DIR}/${PROJECT_NAME})

View File

@ -1,8 +0,0 @@
###
# %FFILE%
# Copyright (C) %YEAR% %USER% <%MAIL%>
#
# Distributed under terms of the %LICENSE% license.
###
%HERE%

View File

@ -1 +0,0 @@
=template=.c

View File

@ -1,12 +0,0 @@
/*
* %FFILE%
* Copyright (C) %YEAR% %USER%
*
* Distributed under terms of the %LICENSE% license.
*/
body {
%HERE%background: white;
color: black;
}

View File

@ -1 +0,0 @@
=template=.c

View File

@ -1,8 +0,0 @@
//
// %FFILE%
// Copyright (C) %YEAR% %USER% <%MAIL%>
//
// Distributed under terms of the %LICENSE% license.
//
%HERE%

View File

@ -1,8 +0,0 @@
!
! %FFILE%
! Copyright (C) %YEAR% %USER% <%MAIL%>
!
! Distributed under terms of the %LICENSE% license.
!
%HERE%

View File

@ -1,8 +0,0 @@
!
! %FFILE%
! Copyright (C) %YEAR% %USER% <%MAIL%>
!
! Distributed under terms of the %LICENSE% license.
!
%HERE%

View File

@ -1,10 +0,0 @@
//
// %FFILE%
// Copyright (C) %YEAR% %USER% <%MAIL%>
//
// Distributed under terms of the %LICENSE% license.
//
package main
%HERE%

View File

@ -1,13 +0,0 @@
/*
* %FFILE%
* Copyright (C) %YEAR% %USER% <%MAIL%>
*
* Distributed under terms of the %LICENSE% license.
*/
#ifndef %GUARD%
#define %GUARD%
%HERE%
#endif /* !%GUARD% */

View File

@ -1,12 +0,0 @@
#! /usr/bin/env runhugs +l
--
-- %FFILE%
-- Copyright (C) %YEAR% %USER% <%MAIL%>
--
-- Distributed under terms of the %LICENSE% license.
--
module %FILE% where
%HERE%

View File

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>%CLASS%</title>
</head>
<body>
%HERE%
</body>
</html>

View File

@ -1,16 +0,0 @@
/* TEAM */
Your title: %USER%
Site: %MAIL%, link to a contact form, etc.
Twitter: your Twitter username.
Location: City, Country.
%HERE%
/* THANKS */
Name: name or url
/* SITE */
Last update: YYYY/MM/DD
Standards: HTML5, CSS3,..
Components: Modernizr, jQuery, etc.
Software: Software used for the development

View File

@ -1,14 +0,0 @@
/*
* %FFILE%
* Copyright (C) %YEAR% %USER% <%MAIL%>
*
* Distributed under terms of the %LICENSE% license.
*/
public class %FILE%
{
public %FILE%() {
%HERE%
}
}

View File

@ -1,8 +0,0 @@
#=
%FILE%
Copyright © %YEAR% %USER% <%MAIL%>
Distributed under terms of the %LICENSE% license.
=#
%HERE%

View File

@ -1,11 +0,0 @@
/*
* %FFILE%
* Copyright (C) %YEAR% %USER% <%MAIL%>
*
* Distributed under terms of the %LICENSE% license.
*/
(function(){
'use strict';
%HERE%
})();

View File

@ -1,12 +0,0 @@
<%@ page contentType="text/html;Charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="" tagdir="/WEB-INF/tags"%>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
%HERE%
</body>
</html>

View File

@ -1,21 +0,0 @@
/*
* %FFILE%
* Copyright (C) %YEAR% %USER% <%MAIL%>
*
* Distributed under terms of the %LICENSE% license.
*/
import React, { Component } from 'react'
class %FILE% extends Component {
constructor(props: any) {
super(props)
}
render() {
return (
%HERE%
)
}
}

View File

@ -1,4 +0,0 @@
%FILE% by %USER%
%FDATE%
%HERE%

View File

@ -1,9 +0,0 @@
#! /usr/bin/env lua
--
-- %FFILE%
-- Copyright (C) %YEAR% %USER% <%MAIL%>
--
-- Distributed under terms of the %LICENSE% license.
--
%HERE%

View File

@ -1 +0,0 @@
=template=.c

View File

@ -1 +0,0 @@
=template=Makefile

View File

@ -1,9 +0,0 @@
(*
* %FFILE%
* Copyright (C) %YEAR% %USER% <%MAIL%>
*
* Distributed under terms of the %LICENSE% license.
*)
let %HERE%

View File

@ -1 +0,0 @@
=template=.m

View File

@ -1,12 +0,0 @@
<?php
/**
* Short description for %FFILE%
*
* @package %FILE%
* @author %USER% <%MAIL%>
* @version 0.1
* @copyright (C) %YEAR% %USER% <%MAIL%>
* @license %LICENSE%
*/
%HERE%

View File

@ -1,16 +0,0 @@
#! /usr/bin/env perl
#
# Short description for %FFILE%
#
# Author %USER% <%MAIL%>
# Version 0.1
# Copyright (C) %YEAR% %USER% <%MAIL%>
# Modified On %FDATE%
# Created %FDATE%
#
use strict;
use warnings;
%HERE%

View File

@ -1,48 +0,0 @@
create or replace package %FILE%
is
/*
* %FFILE%
* Copyright (C) %YEAR% %USER% <%MAIL%>
*
* Distributed under terms of the %LICENSE% license.
*/
procedure main (pv_param1 varchar2(50)
,pv_param2 varchar2(50));
end %FILE%
/
show errors
exit
create or replace package body %FILE%
is
/*
* %FFILE%
* Copyright (C) %YEAR% %USER% <%MAIL%>
*
* Distributed under terms of the %LICENSE% license.
*/
procedure main (pv_param1 varchar2(50)
,pv_param2 varchar2(50))
is
begin
null;
exception
when others then
raise;
end main;
end %FILE%
/
show errors
exit

View File

@ -1,38 +0,0 @@
package %FILE%;
#
# Short description for %FFILE%
#
# Author %USER% <%MAIL%>
# Version 0.1
# Copyright (C) %YEAR% %USER% <%MAIL%>
# Modified On %FDATE%
# Created %FDATE%
#
use strict;
use warnings;
our @ISA = qw(Exporter);
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw();
our $VERSION = '1.00';
require Exporter;
use AutoLoader qw(AUTOLOAD);
sub new
{
my $class = shift;
my $arg = shift;
my $self = {};
%HERE%
bless($self, $class);
return $self;
}
1;
# __END__
# # Below is stub documentation for your module. You'd better edit it!

View File

@ -1,26 +0,0 @@
PRO %FILE%
;+
; Name:
; %FILE%
; Purpose:
;
; Calling sequence:
; %FILE%
; Input:
;
; Output:
;
; Keywords:
;
; History:
;
; Author:
; Copyright © %YEAR% %USER% <%MAIL%>
; Distributed under terms of the %LICENSE% license.
;-
COMPILE_OPT IDL2 ;Set compile options
%HERE%
END

View File

@ -1,11 +0,0 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © %YEAR% %USER% <%MAIL%>
#
# Distributed under terms of the %LICENSE% license.
"""
%HERE%
"""

View File

@ -1,10 +0,0 @@
#!/usr/bin/env ruby
#
# %FFILE%
# Copyright (C) %YEAR% %USER% <%MAIL%>
#
# Distributed under terms of the %LICENSE% license.
#
%HERE%

View File

@ -1,6 +0,0 @@
#
# The Web Robots Pages (http://www.robotstxt.org/)
#
User-agent: *
Disallow:

View File

@ -1,17 +0,0 @@
//
// %FFILE%
// Copyright (C) %YEAR% %USER% <%MAIL%>
// Distributed under terms of the %LICENSE% license.
//
%HERE%
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
}
}

View File

@ -1,10 +0,0 @@
#! /bin/sh
#
# %FFILE%
# Copyright (C) %YEAR% %USER% <%MAIL%>
#
# Distributed under terms of the %LICENSE% license.
#
%HERE%

View File

@ -1,11 +0,0 @@
/*
* %FFILE%
* Copyright (C) %YEAR% %USER% <%MAIL%>
*
* Distributed under terms of the %LICENSE% license.
*/
select %HERE%
-- vim:et

View File

@ -1,17 +0,0 @@
% vim:ft=tex:
%
\documentclass[12pt]{article}
\title{
%FILE%
}
\author{
%USER% --- \texttt{%MAIL%}
}
\begin{document}
\maketitle
%HERE%
\end{document}

View File

@ -1,7 +0,0 @@
%FFILE%
:Author: %USER%
:Email: %MAIL%
:Date: %FDATE%
%HERE%

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<%FILE%>
%HERE%
</%FILE%>
<!-- vim:fenc=utf-8
-->

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
%FFILE%
Copyright (C) %YEAR% %USER% <%MAIL%>
Distributed under terms of the %LICENSE% license.
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
%HERE%
</xsl:stylesheet>

View File

@ -1,8 +0,0 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:i18n="http://namespaces.zope.org/i18n">
%HERE%
</configure>

View File

@ -1 +0,0 @@
=template=.cmake

View File

@ -1 +0,0 @@
=template=Makefile

View File

@ -1,11 +0,0 @@
#
# %FFILE%
# %USER%, %FDATE%
#
all:
%HERE%@echo "%FFILE% needs your attention"
# vim:ft=make
#