Brings current UltiSnips snippets into the repository.

This commit is contained in:
Holger Rapp 2014-02-26 09:31:33 +01:00 committed by Marc Weber
parent 3f7061a0ce
commit 59dcc2b72d
56 changed files with 2355 additions and 1034 deletions

View File

@ -1,4 +1,5 @@
This directory contains the main scripts that come bundled with UltiSnips.
This directory contains the snippets for UltiSnips.
https://github.com/sirver/ultisnips
Standing On The Shoulders of Giants
===================================
@ -10,12 +11,7 @@ two projects:
TextMate: http://svn.textmate.org/trunk/Bundles/
SnipMate: http://code.google.com/p/snipmate/
All snippets from those sources were copied and cleaned up, so that they are
- not using shell script, only python (so they are cross platform compatible)
- not using any feature that UltiSnips doesn't offer
UltiSnips has seen contributions by various individuals. Those contributions
have been merged into this collection seamlessly and without further comments.
UltiSnips has seen contributions by many individuals. Those contributions have
been merged into this collection seamlessly and without further comments.
-- vim:ft=rst:nospell:

View File

@ -1,6 +1,8 @@
# This file contains snippets that are always defined. I personally
# have snippets for signatures and often needed texts
priority -50
##############
# NICE BOXES #
##############
@ -12,71 +14,62 @@ Automatically filled during usage"""
_commentDict = { }
def _parse_comments(s):
""" Parses vim's comments option to extract comment format """
i = iter(s.split(","))
""" Parses vim's comments option to extract comment format """
i = iter(s.split(","))
rv = []
try:
while True:
# get the flags and text of a comment part
flags,text = i.next().split(':', 1)
rv = []
try:
while True:
# get the flags and text of a comment part
flags, text = next(i).split(':', 1)
if len(flags) == 0:
if len(text) == 1:
rv.append((text,text,text, ""))
# parse 3-part comment, but ignore those with O flag
elif flags[0] == 's' and 'O' not in flags:
ctriple = []
indent = ""
if len(flags) == 0:
rv.append((text, text, text, ""))
# parse 3-part comment, but ignore those with O flag
elif flags[0] == 's' and 'O' not in flags:
ctriple = []
indent = ""
if flags[-1] in string.digits:
indent = " " * int(flags[-1])
ctriple.append(text)
if flags[-1] in string.digits:
indent = " " * int(flags[-1])
ctriple.append(text)
flags,text = i.next().split(':', 1)
assert(flags[0] == 'm')
ctriple.append(text)
flags,text = next(i).split(':', 1)
assert(flags[0] == 'm')
ctriple.append(text)
flags,text = i.next().split(':', 1)
assert(flags[0] == 'e')
ctriple.append(text)
ctriple.append(indent)
flags,text = next(i).split(':', 1)
assert(flags[0] == 'e')
ctriple.append(text)
ctriple.append(indent)
rv.append(ctriple)
elif flags[0] == 'b':
if len(text) == 1:
rv.insert(0, (text,text,text, ""))
except StopIteration:
return rv
rv.append(ctriple)
elif flags[0] == 'b':
if len(text) == 1:
rv.insert(0, (text,text,text, ""))
except StopIteration:
return rv
def _get_comment_format():
""" Returns a 4-element tuple representing the comment format for
the current file. """
ft = vim.eval("&filetype")
# check if the comment dict has the format for the current file
if _commentDict.has_key(ft):
return _commentDict[ft]
# otherwise parse vim's comments and add it for later use
commentformat = _parse_comments(vim.eval("&comments"))[0]
_commentDict[ft] = commentformat
return commentformat
""" Returns a 4-element tuple representing the comment format for
the current file. """
return _parse_comments(vim.eval("&comments"))[0]
def make_box(twidth, bwidth = None):
if bwidth is None:
bwidth = twidth + 2
b,m,e,i = _get_comment_format()
sline = b + m + bwidth*m + 2*m
nspaces = (bwidth - twidth)//2
mlines = i + m + " " + " "*nspaces
mlinee = " " + " "*(bwidth-twidth-nspaces) + m
eline = i + 2*m + bwidth*m + m + e
return sline, mlines, mlinee, eline
def make_box(twidth, bwidth=None):
b, m, e, i = _get_comment_format()
bwidth_inner = bwidth - 3 - max(len(b), len(i + e)) if bwidth else twidth + 2
sline = b + m + bwidth_inner * m[0] + 2 * m[0]
nspaces = (bwidth_inner - twidth) // 2
mlines = i + m + " " + " " * nspaces
mlinee = " " + " "*(bwidth_inner - twidth - nspaces) + m
eline = i + m + bwidth_inner * m[0] + 2 * m[0] + e
return sline, mlines, mlinee, eline
def foldmarker():
"Return a tuple of (open fold marker, close fold marker)"
return vim.eval("&foldmarker").split(",")
endglobal
snippet box "A nice box with the current comment symbol" b
@ -91,14 +84,29 @@ endsnippet
snippet bbox "A nice box over the full width" b
`!p
box = make_box(len(t[1]), 71)
width = int(vim.eval("&textwidth")) or 71
box = make_box(len(t[1]), width)
snip.rv = box[0] + '\n' + box[1]
`${1:content}`!p
box = make_box(len(t[1]), 71)
box = make_box(len(t[1]), width)
snip.rv = box[2] + '\n' + box[3]`
$0
endsnippet
snippet fold "Insert a vim fold marker" b
`!p snip.rv = _get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]`${2:1} `!p snip.rv = _get_comment_format()[2]`
endsnippet
snippet foldc "Insert a vim fold close marker" b
`!p snip.rv = _get_comment_format()[0]` ${2:1}`!p snip.rv = foldmarker()[1]` `!p snip.rv = _get_comment_format()[2]`
endsnippet
snippet foldp "Insert a vim fold marker pair" b
`!p snip.rv = _get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]` `!p snip.rv = _get_comment_format()[2]`
${2:${VISUAL:Content}}
`!p snip.rv = _get_comment_format()[0]` `!p snip.rv = foldmarker()[1]` $1 `!p snip.rv = _get_comment_format()[2]`
endsnippet
##########################
# LOREM IPSUM GENERATORS #
##########################

52
UltiSnips/bib.snippets Normal file
View File

@ -0,0 +1,52 @@
priority -50
snippet online "Online resource" b
@online{${1:name},
author={${2:author}},
title={${3:title}},
date={${4:date}},
url={${5:url}}
}
$0
endsnippet
snippet article "Article reference" b
@article{${1:name},
author={${2:author}},
title={${3:title}},
journaltitle={${4:journal}},
volume={${5:NN}},
number={${6:NN}},
year={${7:YYYY}},
pages={${8:NN}--${9:NN}}
}
$0
endsnippet
snippet book "Book reference" b
@book{${1:name},
author={${2:author}},
title={${3:title}},
subtitle={${4:subtitle}},
year={${5:YYYY}},
location={${6:somewhere}},
publisher={${7:publisher}},
pages={${8:NN}--${9:NN}}
}
$0
endsnippet
snippet inb "In Book reference" b
@inbook{${1:name},
author={${2:author}},
title={${3:title}},
subtitle={${4:subtitle}},
booktitle={${5:book}},
editor={${6:editor}},
year={${7:YYYY}},
location={${8:somewhere}},
publisher={${9:publisher}},
pages={${10:NN}--${11:NN}}
}
$0
endsnippet

View File

@ -1,27 +1,29 @@
priority -50
global !p
def newsoa():
import datetime
now = datetime.datetime.now()
# return standard SOA formatted serial for today
return now.strftime("%Y%m%d00")
import datetime
now = datetime.datetime.now()
# return standard SOA formatted serial for today
return now.strftime("%Y%m%d00")
endglobal
snippet zone "Bootstrap a new Bind zonefile" b
$TTL 86400
@ IN SOA ${1:example.net}. ${2:hostmaster.$1}.(
`!p snip.rv = newsoa()`; serial
21600; refresh every 6 hours
3600; retry after one hour
604800; expire after a week
86400 ); minimum TTL of 1 day
@ IN SOA ${1:example.net}. ${2:hostmaster.$1}.(
`!p snip.rv = newsoa()`; serial
21600; refresh every 6 hours
3600; retry after one hour
604800; expire after a week
86400 ); minimum TTL of 1 day
IN NS ns01.$1.
IN MX 10 mail.$1.
IN NS ns01.$1.
IN MX 10 mail.$1.
ns01.$1 IN A
mail.$1 IN A
ns01.$1 IN A
mail.$1 IN A
endsnippet
snippet A "Insert A Record" b
${1:hostname} IN A ${2:ip}
${1:hostname} IN A ${2:ip}
endsnippet

View File

@ -2,6 +2,8 @@
# TextMate Snippets #
###########################################################################
priority -50
snippet def "#define ..."
#define ${1}
endsnippet
@ -12,9 +14,9 @@ snippet ifndef "#ifndef ... #define ... #endif"
#endif
endsnippet
snippet #if "#if #endif" !b
snippet #if "#if #endif" b
#if ${1:0}
${VISUAL:code}$0
${VISUAL}${0:${VISUAL/(.*)/(?1::code)/}}
#endif
endsnippet
@ -36,17 +38,24 @@ $0
endsnippet
snippet main "main() (main)"
int main(int argc, char const *argv[])
int main(int argc, char *argv[])
{
${0:/* code */}
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
return 0;
}
endsnippet
snippet for "for int loop (fori)"
for (${4:size_t} ${2:i} = 0; $2 < ${1:count}; ${3:++$2})
snippet for "for loop (for)"
for (${2:i} = 0; $2 < ${1:count}; ${3:++$2})
{
${0:/* code */}
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
}
endsnippet
snippet fori "for int loop (fori)"
for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2})
{
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
}
endsnippet
@ -62,7 +71,7 @@ if not snip.c:
rand = ''.join(random.sample(string.ascii_letters+string.digits, 8))
snip.rv = ('%s_%s' % (name,rand)).upper()
else:
snip.rv = snip.c`}
snip.rv = snip.c`}
#define $1
${0}
@ -75,9 +84,15 @@ snippet td "Typedef"
typedef ${1:int} ${2:MyCustomType};
endsnippet
snippet wh "while loop"
while(${1:/* condition */}) {
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
}
endsnippet
snippet do "do...while loop (do)"
do {
${0:/* code */}
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
} while(${1:/* condition */});
endsnippet
@ -88,18 +103,30 @@ endsnippet
snippet if "if .. (if)"
if (${1:/* condition */})
{
${0:/* code */}
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
}
endsnippet
snippet el "else .. (else)"
else {
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
}
endsnippet
snippet eli "else if .. (eli)"
else if (${1:/* condition */}) {
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
}
endsnippet
snippet ife "if .. else (ife)"
if (${1:/* condition */})
{
${2:/* code */}
${2:/* code */}
}
else
{
${3:/* else */}
${3:/* else */}
}
endsnippet
@ -114,4 +141,15 @@ struct ${1:`!p snip.rv = (snip.basename or "name") + "_t"`}
};
endsnippet
snippet fun "function" b
${1:void} ${2:function_name}(${3})
{
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
}
endsnippet
snippet fund "function declaration" b
${1:void} ${2:function_name}(${3});
endsnippet
# vim:ft=snippets:

View File

@ -1,5 +1,4 @@
# From the TextMate bundle
# with some modification
priority -50
snippet fun "Function" b
${1:name} = `!p snip.rv = "(" if t[2] else ""`${2:args}`!p snip.rv = ") " if t[2] else ""`->
@ -10,52 +9,52 @@ snippet bfun "Function (bound)" i
`!p snip.rv = "(" if t[1] else ""`${1:args}`!p snip.rv = ") " if t[1] else ""`=>`!p snip.rv = " " if t[2] and not t[2].startswith("\n") else ""`${2:expr}
endsnippet
snippet if "If"
snippet if "If" b
if ${1:condition}
${0:# body...}
endsnippet
snippet ife "If .. Else"
snippet ife "If .. Else" b
if ${1:condition}
${2:# body...}
else
${3:# body...}
endsnippet
snippet eif "Else if" b
snippet elif "Else if" b
else if ${1:condition}
${0:# body...}
endsnippet
snippet ifte "Ternary if"
snippet ifte "Ternary if" b
if ${1:condition} then ${2:value} else ${3:other}
endsnippet
snippet unl "Unless"
snippet unl "Unless" b
${1:action} unless ${2:condition}
endsnippet
snippet fora "Array Comprehension"
snippet fora "Array Comprehension" b
for ${1:name} in ${2:array}
${0:# body...}
endsnippet
snippet foro "Object Comprehension"
snippet foro "Object Comprehension" b
for ${1:key}, ${2:value} of ${3:Object}
${0:# body...}
endsnippet
snippet forr "Range Comprehension (inclusive)"
snippet forr "Range Comprehension (inclusive)" b
for ${1:name} in [${2:start}..${3:finish}]`!p snip.rv = " by " if t[4] else ""`${4:step}
${0:# body...}
endsnippet
snippet forrex "Range Comprehension (exclusive)"
snippet forrex "Range Comprehension (exclusive)" b
for ${1:name} in [${2:start}...${3:finish}]`!p snip.rv = " by " if t[4] else ""`${4:step}
${0:# body...}
endsnippet
snippet swi "Switch"
snippet swi "Switch" b
switch ${1:object}
when ${2:value}
${3:# body...}
@ -63,7 +62,7 @@ switch ${1:object}
$0
endsnippet
snippet swit "Switch when .. then"
snippet swit "Switch when .. then" b
switch ${1:object}
when ${2:condition}`!p snip.rv = " then " if t[3] else ""`${3:value}
else`!p snip.rv = " " if t[4] and not t[4].startswith("\n") else ""`${4:value}
@ -77,7 +76,7 @@ class ${1:ClassName}`!p snip.rv = " extends " if t[2] else ""`${2:Ancestor}
$0
endsnippet
snippet try "Try .. Catch"
snippet try "Try .. Catch" b
try
$1
catch ${2:error}
@ -95,4 +94,3 @@ endsnippet
snippet log "Log" b
console.log ${1:"${2:msg}"}
endsnippet

View File

@ -2,8 +2,12 @@
# CoffeeScript versions -- adapted from the JS TextMate bundle + additions
# for some jasmine-jquery matchers
#
priority -50
extends coffee
priority -49
snippet des "Describe (coffee)" b
describe '${1:description}', ->
$0
@ -160,4 +164,3 @@ endsnippet
snippet noscw "expect was not called with (coffee)" b
expect(${1:target}).wasNotCalledWith(${2:arguments})
endsnippet

View File

@ -1,3 +1,10 @@
priority -50
extends c
# We want to overwrite everything in parent ft.
priority -49
###########################################################################
# TextMate Snippets #
###########################################################################
@ -20,7 +27,7 @@ endsnippet
snippet ns "namespace .. (namespace)"
namespace${1/.+/ /m}${1:`!p snip.rv = snip.basename or "name"`}
{
$0
${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}}
}${1/.+/ \/* /m}$1${1/.+/ *\/ /m}
endsnippet

328
UltiSnips/cs.snippets Normal file
View File

@ -0,0 +1,328 @@
#######################################################################
# C# Snippets for UltiSnips #
#######################################################################
priority -50
#########################
# classes and structs #
#########################
snippet namespace "namespace" b
namespace ${1:MyNamespace}
{
${VISUAL}$0
}
endsnippet
snippet class "class" w
class ${1:MyClass}
{
$0
}
endsnippet
snippet struct "struct" w
struct ${1:MyStruct}
{
$0
}
endsnippet
snippet interface "interface" w
interface I${1:Interface}
{
$0
}
endsnippet
snippet enum "enumeration" b
enum ${1:MyEnum} { ${2:Item} };
endsnippet
############
# Main() #
############
snippet sim "static int main" b
static int Main(string[] args)
{
$0
}
endsnippet
snippet svm "static void main" b
static void Main(string[] args)
{
$0
}
endsnippet
################
# properties #
################
snippet prop "Simple property declaration" b
public ${1:int} ${2:MyProperty} { get; set; }
endsnippet
snippet propfull "Full property declaration" b
private ${1:int} ${2:_myProperty};
public $1 ${3:MyProperty}
{
get { return $2; }
set { $2 = value; }
}
endsnippet
snippet propg "Property with a private setter" b
public ${1:int} ${2:MyProperty} { get; private set; }
endsnippet
############
# blocks #
############
snippet #if "#if #endif" b
#if ${1:DEBUG}
${VISUAL}$0
#endif
endsnippet
snippet #region "#region #endregion" b
#region ${1:Region}
${VISUAL}$0
#endregion
endsnippet
###########
# loops #
###########
snippet for "for loop" b
for (int ${1:i} = 0; $1 < ${2:10}; $1++)
{
${VISUAL}$0
}
endsnippet
snippet forr "for loop (reverse)" b
for (int ${1:i} = ${2:10}; $1 >= 0; $1--)
{
${VISUAL}$0
}
endsnippet
snippet foreach "foreach loop" b
foreach (${3:var} ${2:item} in ${1:items})
{
${VISUAL}$0
}
endsnippet
snippet while "while loop" b
while (${1:true})
{
${VISUAL}$0
}
endsnippet
snippet do "do loop" b
do
{
${VISUAL}$0
} while (${1:true});
endsnippet
###############
# branching #
###############
snippet if "if statement" b
if ($1)
{
${VISUAL}$0
}
endsnippet
snippet ife "if else statement" b
if ($1)
{
${VISUAL}$0
}
else
{
}
endsnippet
snippet elif "else if" b
else if ($1)
{
$0
}
endsnippet
snippet elseif "else if" b
else if ($1)
{
$0
}
endsnippet
snippet ifnn "if not null" b
if ($1 != null)
{
${VISUAL}$0
}
endsnippet
snippet switch "switch statement" b
switch (${1:statement})
{
case ${2:value}:
break;
default:
$0break;
}
endsnippet
snippet case "case" b
case ${1:value}:
$2
break;
endsnippet
##############
# wrappers #
##############
snippet using "using statement" b
using (${1:resource})
{
${VISUAL}$0
}
endsnippet
snippet unchecked "unchecked block" b
unchecked
{
${VISUAL}$0
}
endsnippet
snippet checked "checked block" b
checked
{
${VISUAL}$0
}
endsnippet
snippet unsafe "unsafe" b
unsafe
{
${VISUAL}$0
}
endsnippet
########################
# exception handling #
########################
snippet try "try catch block" b
try
{
${VISUAL}$0
}
catch (${1:Exception} ${2:e})
{
throw;
}
endsnippet
snippet tryf "try finally block" b
try
{
${VISUAL}$0
}
finally
{
}
endsnippet
snippet throw "throw"
throw new ${1}Exception("${2}");
endsnippet
##########
# LINQ #
##########
snippet from "LINQ syntax" b
var ${1:seq} =
from ${2:item1} in ${3:items1}
join ${4:item2} in ${5:items2} on $2.${6:prop1} equals $4.${7:prop2}
select ${8:$2.prop3}
where ${9:clause}
endsnippet
############################
# feedback and debugging #
############################
snippet da "Debug.Assert" b
Debug.Assert(${1:true});
endsnippet
snippet cw "Console.WriteLine" b
Console.WriteLine("$1");
endsnippet
# as you first type comma-separated parameters on the right, {n} values appear in the format string
snippet cwp "Console.WriteLine with parameters" b
Console.WriteLine("${2:`!p
snip.rv = ' '.join(['{' + str(i) + '}' for i in range(t[1].count(','))])
`}"${1:, something});
endsnippet
snippet mbox "Message box" b
MessageBox.Show("${1:message}");
endsnippet
##################
# full methods #
##################
snippet equals "Equals method" b
public override bool Equals(object obj)
{
if (obj == null || GetType() != obj.GetType())
{
return false;
}
$0
return base.Equals(obj);
}
endsnippet
##############
# comments #
##############
snippet /// "XML comment" b
/// <summary>
/// $1
/// </summary>
endsnippet

View File

@ -2,6 +2,8 @@
# Most of these came from TextMate #
###########################################################################
priority -50
snippet ! "!important CSS (!)"
${1:!important}
endsnippet

View File

@ -1,5 +1,7 @@
# Simple shortcuts
priority -50
snippet imp "import (imp)" b
import ${1:std.stdio};
endsnippet
@ -42,22 +44,22 @@ endsnippet
snippet pub "public (pub)" b
public:
${1:/*members*/}
${1:/*members*/}
endsnippet
snippet priv "private (priv)" b
private:
${1:/*members*/}
${1:/*members*/}
endsnippet
snippet prot "protected (prot)" b
protected:
${1:/*members*/}
${1:/*members*/}
endsnippet
snippet pack "package (pack)" b
package:
${1:/*members*/}
${1:/*members*/}
endsnippet
snippet ret "return (ret)"
@ -96,7 +98,7 @@ endsnippet
snippet enf "enforce (enf)" b
enforce(${1:/*condition*/},
new ${2}Exception(${3:/*args*/}));
new ${2}Exception(${3:/*args*/}));
endsnippet
# Branches
@ -104,67 +106,67 @@ endsnippet
snippet if "if .. (if)"
if(${1:/*condition*/})
{
${VISUAL}${0:/*code*/}
${VISUAL}${0:/*code*/}
}
endsnippet
snippet ife "if .. else (ife)" b
if(${1:/*condition*/})
{
${2:/*code*/}
${2:/*code*/}
}
else
{
${3:/*else*/}
${3:/*else*/}
}
endsnippet
snippet el "else (el)" b
else
{
${VISUAL}${1:/*code*/}
${VISUAL}${1:/*code*/}
}
endsnippet
snippet eif "else if (elif)" b
snippet elif "else if (elif)" b
else if(${1:/*condition*/})
{
${VISUAL}${0:/*code*/}
${VISUAL}${0:/*code*/}
}
endsnippet
snippet sw "switch (sw)"
switch(${1:/*var*/})
{
case ${2:/*value*/}:
${3:/*code*/}
break;
case ${4:/*value*/}:
${5:/*code*/}
break;
${7:/*more cases*/}
default:
${6:assert(false);}
case ${2:/*value*/}:
${3:/*code*/}
break;
case ${4:/*value*/}:
${5:/*code*/}
break;
${7:/*more cases*/}
default:
${6:assert(false);}
}
endsnippet
snippet fsw "final switch (fsw)"
switch(${1:/*var*/})
{
case ${2:/*value*/}:
${3:/*code*/}
break;
case ${4:/*value*/}:
${5:/*code*/}
break;
${7:/*more cases*/}
case ${2:/*value*/}:
${3:/*code*/}
break;
case ${4:/*value*/}:
${5:/*code*/}
break;
${7:/*more cases*/}
}
endsnippet
snippet case "case (case)" b
case ${1:/*value*/}:
${2:/*code*/}
break;
${2:/*code*/}
break;
endsnippet
snippet ?: "ternary operator (?:)"
@ -176,42 +178,42 @@ endsnippet
snippet do "do while (do)" b
do
{
${VISUAL}${2:/*code*/}
${VISUAL}${2:/*code*/}
} while(${1:/*condition*/});
endsnippet
snippet wh "while (wh)" b
while(${1:/*condition*/})
{
${VISUAL}${2:/*code*/}
${VISUAL}${2:/*code*/}
}
endsnippet
snippet for "for (for)" b
for (${4:size_t} ${2:i} = 0; $2 < ${1:count}; ${3:++$2})
{
${VISUAL}${0:/*code*/}
${VISUAL}${0:/*code*/}
}
endsnippet
snippet forever "forever (forever)" b
for(;;)
{
${VISUAL}${0:/*code*/}
${VISUAL}${0:/*code*/}
}
endsnippet
snippet fore "foreach (fore)"
foreach(${1:/*elem*/}; ${2:/*range*/})
{
${VISUAL}${3:/*code*/}
${VISUAL}${3:/*code*/}
}
endsnippet
snippet forif "foreach if (forif)" b
foreach(${1:/*elem*/}; ${2:/*range*/}) if(${3:/*condition*/})
{
${VISUAL}${4:/*code*/}
${VISUAL}${4:/*code*/}
}
endsnippet
@ -219,8 +221,8 @@ endsnippet
snippet in "in contract (in)" b
in
{
assert(${1:/*condition*/}, "${2:error message}");
${3}
assert(${1:/*condition*/}, "${2:error message}");
${3}
}
body
endsnippet
@ -228,8 +230,8 @@ endsnippet
snippet out "out contract (out)" b
out${1:(result)}
{
assert(${2:/*condition*/}, "${3:error message}");
${4}
assert(${2:/*condition*/}, "${3:error message}");
${4}
}
body
endsnippet
@ -237,8 +239,8 @@ endsnippet
snippet inv "invariant (inv)" b
invariant()
{
assert(${1:/*condition*/}, "${2:error message}");
${3}
assert(${1:/*condition*/}, "${2:error message}");
${3}
}
endsnippet
@ -247,29 +249,29 @@ endsnippet
snippet fun "function definition (fun)"
${1:void} ${2:/*function name*/}(${3:/*args*/}) ${4:@safe pure nothrow}
{
${VISUAL}${5:/*code*/}
${VISUAL}${5:/*code*/}
}
endsnippet
snippet void "void function definition (void)"
void ${1:/*function name*/}(${2:/*args*/}) ${3:@safe pure nothrow}
{
${VISUAL}${4:/*code*/}
${VISUAL}${4:/*code*/}
}
endsnippet
snippet this "ctor (this)" w
this(${1:/*args*/})
{
${VISUAL}${2:/*code*/}
${VISUAL}${2:/*code*/}
}
endsnippet
snippet get "getter property (get)" !
snippet get "getter property (get)"
@property ${1:/*type*/} ${2:/*member_name*/}() const pure nothrow {return ${3:$2_};}
endsnippet
snippet set "setter property (set)" !
snippet set "setter property (set)"
@property void ${1:/*member_name*/}(${2:/*type*/} rhs) pure nothrow {${3:$1_} = rhs;}
endsnippet
@ -278,7 +280,7 @@ endsnippet
snippet main "Main" b
void main(string[] args)
{
${VISUAL}${0: /*code*/}
${VISUAL}${0: /*code*/}
}
endsnippet
@ -293,7 +295,7 @@ endsnippet
snippet scope "scope (scope)" b
scope(${1:exit})
{
${VISUAL}${2:/*code*/}
${VISUAL}${2:/*code*/}
}
endsnippet
@ -302,7 +304,7 @@ endsnippet
snippet with "with (with)"
with(${1})
{
${VISUAL}${2:/*code*/}
${VISUAL}${2:/*code*/}
}
endsnippet
@ -311,33 +313,33 @@ endsnippet
snippet try "try/catch (try)" b
try
{
${VISUAL}${1:/*code to try*/}
${VISUAL}${1:/*code to try*/}
}
catch(${2}Exception e)
{
${3:/*handle exception*/}
${3:/*handle exception*/}
}
endsnippet
snippet tryf "try/catch/finally (tryf)" b
try
{
${VISUAL}${1:/*code to try*/}
${VISUAL}${1:/*code to try*/}
}
catch(${2}Exception e)
{
${3:/*handle exception*/}
${3:/*handle exception*/}
}
finally
{
${4:/*cleanup*/}
${4:/*cleanup*/}
}
endsnippet
snippet catch "catch (catch)" b
catch(${1}Exception e)
{
${2:/*handle exception*/}
${2:/*handle exception*/}
}
endsnippet
@ -351,35 +353,35 @@ endsnippet
snippet struct "struct (struct)"
struct ${1:`!p snip.rv = (snip.basename or "name")`}
{
${2}
${2}
}
endsnippet
snippet union "union (union)"
union ${1:`!p snip.rv = (snip.basename or "name")`}
{
${2}
${2}
}
endsnippet
snippet class "class (class)"
class ${1:`!p snip.rv = (snip.basename or "name")`}
{
${2}
${2}
}
endsnippet
snippet inter "interface (inter)"
interface ${1:`!p snip.rv = (snip.basename or "name")`}
{
${2}
${2}
}
endsnippet
snippet enum "enum (enum)"
enum ${1:`!p snip.rv = (snip.basename or "name")`}
{
${2}
${2}
}
endsnippet
@ -390,10 +392,10 @@ snippet exc "exception declaration (exc)" b
/// ${3:/*documentation*/}
class ${1}Exception : ${2}Exception
{
public this(string msg, string file = __FILE__, int line = __LINE__)
{
super(msg, file, line);
}
public this(string msg, string file = __FILE__, int line = __LINE__)
{
super(msg, file, line);
}
}
endsnippet
@ -403,14 +405,14 @@ endsnippet
snippet version "version (version)" b
version(${1:/*version name*/})
{
${VISUAL}${2:/*code*/}
${VISUAL}${2:/*code*/}
}
endsnippet
snippet debug "debug" b
debug
{
${VISUAL}${1:/*code*/}
${VISUAL}${1:/*code*/}
}
endsnippet
@ -420,7 +422,7 @@ endsnippet
snippet temp "template (temp)" b
template ${2:/*name*/}(${1:/*args*/})
{
${3:/*code*/}
${3:/*code*/}
}
endsnippet
@ -438,7 +440,7 @@ endsnippet
snippet unittest "unittest (unittest)" b
unittest
{
${1:/*code*/}
${1:/*code*/}
}
endsnippet
@ -448,41 +450,41 @@ endsnippet
snippet opDis "opDispatch (opDis)" b
${1:/*return type*/} opDispatch(string s)()
{
${2:/*code*/};
${2:/*code*/};
}
endsnippet
snippet op= "opAssign (op=)" b
void opAssign(${1} rhs) ${2:@safe pure nothrow}
{
${2:/*code*/}
${2:/*code*/}
}
endsnippet
snippet opCmp "opCmp (opCmp)" b
int opCmp(${1} rhs) @safe const pure nothrow
{
${2:/*code*/}
${2:/*code*/}
}
endsnippet
snippet opApply "opApply (opApply)" b
int opApply(int delegate(ref ${1:/*iterated type/s*/}) dg)
{
int result = 0;
${2:/*loop*/}
{
result = dg(${3:/*arg/s*/});
if(result){break;}
}
return result;
int result = 0;
${2:/*loop*/}
{
result = dg(${3:/*arg/s*/});
if(result){break;}
}
return result;
}
endsnippet
snippet toString "toString (toString)" b
string toString() @safe const pure nothrow
{
${1:/*code*/}
${1:/*code*/}
}
endsnippet
@ -490,12 +492,11 @@ endsnippet
# Comments
snippet todo "TODO (todo)" !
snippet todo "TODO (todo)"
// TODO: ${1}
endsnippet
# DDoc
snippet doc "generic ddoc block (doc)" b
@ -508,7 +509,7 @@ snippet fdoc "function ddoc block (fdoc)" b
/// ${1:description}
///
/// ${2:Params: ${3:param} = ${4:param description}
/// ${5}}
/// ${5}}
///
/// ${6:Returns: ${7:return value}}
///
@ -517,7 +518,7 @@ endsnippet
snippet Par "Params (Par)"
Params: ${1:param} = ${2:param description}
/// ${3}
/// ${3}
endsnippet
snippet Ret "Returns (Ret)"

View File

@ -1,3 +1,5 @@
priority -50
# Generic Tags
snippet %
{% ${1} %}${2}
@ -5,7 +7,7 @@ endsnippet
snippet %%
{% ${1:tag_name} %}
${2}
${2}
{% end$1 %}
endsnippet
@ -17,14 +19,14 @@ endsnippet
snippet autoescape
{% autoescape ${1:off} %}
${2}
${2}
{% endautoescape %}
endsnippet
snippet block
{% block ${1} %}
${2}
{% endblock %}
${2}
{% endblock $1 %}
endsnippet
snippet #
@ -33,7 +35,7 @@ endsnippet
snippet comment
{% comment %}
${1}
${1}
{% endcomment %}
endsnippet
@ -51,7 +53,7 @@ endsnippet
snippet filter
{% filter ${1} %}
${2}
${2}
{% endfilter %}
endsnippet
@ -61,24 +63,24 @@ endsnippet
snippet for
{% for ${1} in ${2} %}
${3}
${3}
{% endfor %}
endsnippet
snippet empty
{% empty %}
${1}
${1}
endsnippet
snippet if
{% if ${1} %}
${2}
${2}
{% endif %}
endsnippet
snippet el
snippet else
{% else %}
${1}
${1}
endsnippet
snippet ifchanged
@ -87,13 +89,13 @@ endsnippet
snippet ifequal
{% ifequal ${1} ${2} %}
${3}
${3}
{% endifequal %}
endsnippet
snippet ifnotequal
{% ifnotequal ${1} ${2} %}
${3}
${3}
{% endifnotequal %}
endsnippet

View File

@ -1,5 +1,7 @@
# Credit: @iurifg
priority -50
snippet do
do
${1}

View File

@ -2,6 +2,8 @@
# TEXTMATE SNIPPETS #
###########################################################################
priority -50
snippet pat "Case:Receive:Try Clause"
${1:pattern}${2: when ${3:guard}} ->;
${4:body}

View File

@ -1,3 +1,5 @@
priority -50
# TextMate added these variables to cope with changes in ERB handling
# in different versions of Rails -- for instance, Rails 3 automatically
# strips whitespace so that it's no longer necessary to use a form like
@ -11,16 +13,15 @@
#
global !p
def textmate_var(var, snip):
lookup = dict(
TM_RAILS_TEMPLATE_START_RUBY_EXPR = snip.opt('g:tm_rails_template_start_ruby_expr', '<%= '),
TM_RAILS_TEMPLATE_END_RUBY_EXPR = snip.opt('g:tm_rails_template_end_ruby_expr', ' %>'),
TM_RAILS_TEMPLATE_START_RUBY_INLINE = snip.opt('g:tm_rails_template_start_ruby_inline', '<% '),
TM_RAILS_TEMPLATE_END_RUBY_INLINE = snip.opt('g:tm_rails_template_end_ruby_inline', ' %>'),
TM_RAILS_TEMPLATE_END_RUBY_BLOCK = '<% end %>'
)
snip.rv = lookup[var]
return
lookup = dict(
TM_RAILS_TEMPLATE_START_RUBY_EXPR = snip.opt('g:tm_rails_template_start_ruby_expr', '<%= '),
TM_RAILS_TEMPLATE_END_RUBY_EXPR = snip.opt('g:tm_rails_template_end_ruby_expr', ' %>'),
TM_RAILS_TEMPLATE_START_RUBY_INLINE = snip.opt('g:tm_rails_template_start_ruby_inline', '<% '),
TM_RAILS_TEMPLATE_END_RUBY_INLINE = snip.opt('g:tm_rails_template_end_ruby_inline', ' %>'),
TM_RAILS_TEMPLATE_END_RUBY_BLOCK = '<% end %>'
)
snip.rv = lookup[var]
return
endglobal
@ -42,7 +43,7 @@ endsnippet
snippet ft "form_tag"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`form_tag(${1::action => "${5:update}"}${6:, {:${8:class} => "${9:form}"\}}) do`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
$0
$0
`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)`
endsnippet
@ -52,11 +53,11 @@ endsnippet
snippet for "for loop (ERB)"
<% if !${1:list}.blank? %>
<% for ${2:item} in ${1} %>
$3
<% end %>
<% for ${2:item} in ${1} %>
$3
<% end %>
<% else %>
$4
$4
<% end %>
endsnippet
@ -74,7 +75,7 @@ snippet ffhf "form_for hidden_field 2"
endsnippet
snippet ffl "form_for label 2"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR}f.label :${1:attribute', snip)`${2:, "${3:${1/[[:alpha:]]+|(_)/(?1: :\u$0)/g}}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.label :${1:attribute}${2:, "${3:${1/[[:alpha:]]+|(_)/(?1: :\u$0)/g}}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
endsnippet
snippet ffpf "form_for password_field 2"
@ -99,7 +100,7 @@ endsnippet
snippet fields "fields_for"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`fields_for :${1:model}, @${2:$1} do |$1|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_INLINE', snip)`
$0
$0
`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)`
endsnippet
@ -122,7 +123,7 @@ snippet f. "f.hidden_field"
endsnippet
snippet f. "f.label"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR}f.label :${1:attribute', snip)`${2:, "${3:${1/[[:alpha:]]+|(_)/(?1: :\u$0)/g}}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.label :${1:attribute}${2:, "${3:${1/[[:alpha:]]+|(_)/(?1: :\u$0)/g}}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
endsnippet
snippet f. "f.password_field"
@ -148,14 +149,14 @@ endsnippet
snippet ffe "form_for with errors"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`error_messages_for :${1:model}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`form_for @${2:$1} do |f|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_INLINE', snip)`
$0
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`form_for @${2:$1} do |f|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
$0
`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)`
endsnippet
snippet ff "form_for"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`form_for @${1:model} do |f|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_INLINE', snip)`
$0
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`form_for @${1:model} do |f|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
$0
`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)`
endsnippet
@ -271,9 +272,9 @@ snippet st "submit_tag"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`submit_tag "${1:Save changes}"${2:, :id => "${3:submit}"}${4:, :name => "${5:$3}"}${6:, :class => "${7:form_$3}"}${8:, :disabled => ${9:false}}${10:, :disable_with => "${11:Please wait...}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
endsnippet
snippet el "else (ERB)"
snippet else "else (ERB)"
<% else %>
$0
endsnippet
snippet if "if (ERB)"

View File

@ -1,5 +1,7 @@
# Snippets for Go
priority -50
# when to abbriviate and when not?
# b doesn't work here, because it ignores whitespace
# optional local name?
@ -31,37 +33,55 @@ const (
)
endsnippet
snippet struct "Struct declaration" b
type ${1:Struct} struct {
${0:${VISUAL}}
}
endsnippet
snippet interface "Interface declaration" b
type ${1:Interface} interface {
${0:${VISUAL}}
}
endsnippet
# statements
snippet for "For loop" !b
snippet for "For loop" b
for ${1:condition}${1/(.+)/ /}{
${0:${VISUAL}}
}
endsnippet
snippet forr "For range loop" !b
snippet forr "For range loop" b
for ${2:name} := range ${1:collection} {
${0:${VISUAL}}
}
endsnippet
snippet if "If statement" !b
snippet if "If statement" b
if ${1:condition}${1/(.+)/ /}{
${0:${VISUAL}}
}
endsnippet
snippet switch "Switch statement" !b
snippet switch "Switch statement" b
switch ${1:expression}${1/(.+)/ /}{
case${0}
}
endsnippet
snippet case "Case clause" !b
snippet select "Select statement" b
select {
case${0}
}
endsnippet
snippet case "Case clause" b
case ${1:condition}:
${0:${VISUAL}}
endsnippet
snippet default "Default clause" !b
snippet default "Default clause" b
default:
${0:${VISUAL}}
endsnippet
@ -86,22 +106,26 @@ func ${1:name}(${2:params})${3/(.+)/ /}${3:type} {
endsnippet
# types and variables
snippet map "Map type" !b
snippet map "Map type" b
map[${1:keytype}]${2:valtype}
endsnippet
snippet : "Variable declaration :=" !b
snippet : "Variable declaration :=" b
${1:name} := ${0:value}
endsnippet
snippet var "Variable declaration" !b
snippet var "Variable declaration" b
var ${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value}}
endsnippet
snippet vars "Variables declaration" !b
snippet vars "Variables declaration" b
var (
${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value} }
)
endsnippet
snippet json "JSON field"
\`json:"${1:displayName}"\`
endsnippet
# vim:ft=snippets:

View File

@ -1,13 +1,15 @@
snippet ife "if ... then ... else ..."
priority -50
snippet if "if ... then ... else ..."
if ${1:condition}
then ${2:expression}
else ${3:expression}
then ${2:expression}
else ${3:expression}
endsnippet
snippet case "case ... of ..."
case ${1} of
${2} -> ${3}
${4} -> ${5}
case ${1:expression} of
${2:pattern} -> ${3:expression}
${4:pattern} -> ${5:expression}
endsnippet
snippet :: "Type signature"

View File

@ -1,10 +1,12 @@
# Snippets for VIM Help Files
priority -50
global !p
def sec_title(snip, t):
file_start = snip.fn.split('.')[0]
sec_name = t[1].strip("1234567890. ").lower().replace(' ', '-')
return ("*%s-%s*" % (file_start, sec_name)).rjust(78-len(t[1]))
file_start = snip.fn.split('.')[0]
sec_name = t[1].strip("1234567890. ").lower().replace(' ', '-')
return ("*%s-%s*" % (file_start, sec_name)).rjust(78-len(t[1]))
endglobal
snippet sec "Section marker" b

View File

@ -1,13 +1,15 @@
priority -50
###########################################################################
# TextMate Snippets #
###########################################################################
global !p
def x(snip):
if snip.ft.startswith("x"):
snip.rv = '/'
else:
snip.rv = ""
if snip.ft.startswith("x"):
snip.rv = '/'
else:
snip.rv = ""
endglobal
############
@ -123,21 +125,21 @@ endsnippet
#############
# HTML TAGS #
#############
snippet input "Input with Label"
snippet input "Input with Label" w
<label for="${2:${1/[[:alpha:]]+|( )/(?1:_:\L$0)/g}}">$1</label><input type="${3:text/submit/hidden/button}" name="${4:$2}" value="$5"${6: id="${7:$2}"}`!p x(snip)`>
endsnippet
snippet input "XHTML <input>"
snippet input "XHTML <input>" w
<input type="${1:text/submit/hidden/button}" name="${2:some_name}" value="$3"${4: id="${5:$2}"}`!p x(snip)`>
endsnippet
snippet opt "Option"
snippet opt "Option" w
<option${1: value="${2:option}"}>${3:$2}</option>
endsnippet
snippet select "Select Box"
snippet select "Select Box" w
<select name="${1:some_name}" id="${2:$1}"${3:${4: multiple}${5: onchange="${6:}"}${7: size="${8:1}"}}>
<option${9: value="${10:option1}"}>${11:$10}</option>
<option${12: value="${13:option2}"}>${14:$13}</option>${15:}
@ -146,18 +148,22 @@ snippet select "Select Box"
endsnippet
snippet textarea "XHTML <textarea>"
snippet textarea "XHTML <textarea>" w
<textarea name="${1:Name}" rows="${2:8}" cols="${3:40}">$0</textarea>
endsnippet
snippet mailto "XHTML <a mailto: >"
snippet mailto "XHTML <a mailto: >" w
<a href="mailto:${1:joe@example.com}?subject=${2:feedback}">${3:email me}</a>
endsnippet
snippet base "XHTML <base>"
snippet base "XHTML <base>" w
<base href="$1"${2: target="$3"}`!p x(snip)`>
endsnippet
snippet img "XHTML <img>" w
<img src="${1:imgsrc}">
endsnippet
snippet body "XHTML <body>"
<body id="${1:`!p
snip.rv = snip.fn and 'Hallo' or 'Nothin'
@ -166,13 +172,13 @@ snip.rv = snip.fn and 'Hallo' or 'Nothin'
</body>
endsnippet
snippet div "XHTML <div>"
<div`!p snip.rv=' id="' if t[1] else ""`${1:name}`!p snip.rv = '"' if t[1] else ""`>
$0
snippet div "XHTML <div>" w
<div`!p snip.rv=' id="' if t[1] else ""`${1:name}`!p snip.rv = '"' if t[1] else ""``!p snip.rv=' class="' if t[2] else ""`${2:name}`!p snip.rv = '"' if t[2] else ""`>
$0
</div>
endsnippet
snippet form "XHTML <form>"
snippet form "XHTML <form>" w
<form action="${1:`!p
snip.rv = (snip.basename or 'unnamed') + '_submit'
`}" method="${2:get}" accept-charset="utf-8">
@ -182,7 +188,7 @@ snip.rv = (snip.basename or 'unnamed') + '_submit'
</form>
endsnippet
snippet h1 "XHTML <h1>"
snippet h1 "XHTML <h1>" w
<h1 id="${1/[\w\d]+|( )/(?1:_:\L$0\E)/g}">${1}</h1>
endsnippet
@ -194,71 +200,70 @@ snippet head "XHTML <head>"
</head>
endsnippet
snippet link "XHTML <link>"
snippet link "XHTML <link>" w
<link rel="${1:stylesheet}" href="${2:/css/master.css}" type="text/css" media="${3:screen}" title="${4:no title}" charset="${5:utf-8}"`!p x(snip)`>
endsnippet
snippet meta "XHTML <meta>"
snippet meta "XHTML <meta>" w
<meta name="${1:name}" content="${2:content}"`!p x(snip)`>
endsnippet
snippet scriptsrc "XHTML <script src...>"
snippet scriptsrc "XHTML <script src...>" w
<script src="$1" type="text/javascript" charset="${3:utf-8}"></script>
endsnippet
snippet script "XHTML <script>"
snippet script "XHTML <script>" w
<script type="text/javascript" charset="utf-8">
$0
</script>
endsnippet
snippet style "XHTML <style>"
snippet style "XHTML <style>" w
<style type="text/css" media="screen">
$0
</style>
endsnippet
snippet table "XHTML <table>"
snippet table "XHTML <table>" w
<table border="${1:0}"${2: cellspacing="${3:5}" cellpadding="${4:5}"}>
<tr><th>${5:Header}</th></tr>
<tr><td>${0:Data}</td></tr>
</table>
endsnippet
snippet a "Link"
snippet a "Link" w
<a href="${1:http://www.${2:url.com}}"${3: target="_blank"}>${4:Anchor Text}</a>
endsnippet
snippet p "paragraph"
snippet p "paragraph" w
<p>$0</p>
endsnippet
snippet li "list item"
<li></li>
snippet li "list item" w
<li>$0</li>
endsnippet
snippet ul "unordered list"
snippet ul "unordered list" w
<ul>
$0
</ul>
endsnippet
snippet td "table cell"
snippet td "table cell" w
<td>$0</td>
endsnippet
snippet tr "table row"
snippet tr "table row" w
<tr>$0</tr>
endsnippet
snippet title "XHTML <title>"
snippet title "XHTML <title>" w
<title>${1:`!p snip.rv = snip.basename or "Page Title"`}</title>
endsnippet
snippet fieldset "Fieldset"
snippet fieldset "Fieldset" w
<fieldset id="${1/[\w\d]+|( )/(?1:_:\L$0\E)/g}" ${2:class="${3:}"}>
<legend>$1</legend>
$0
</fieldset>
endsnippet
@ -282,7 +287,7 @@ snippet html5 "HTML5 Template"
<html>
<head>
<title>${1}</title>
<meta charset="utf-8">
<meta charset="utf-8" />
</head>
<body>
<header>

View File

@ -1,6 +1,8 @@
# more can be found in snippets/html_minimal.snippets
# these UltiSnips override snippets because nested placeholders are being used
priority -50
snippet id
id="${1}"${2}
endsnippet

View File

@ -1 +1,3 @@
priority -50
extends html, django

View File

@ -0,0 +1,3 @@
priority -50
extends html, jinja2

View File

@ -1,27 +1,75 @@
###########################################################################
# TEXTMATE SNIPPETS #
###########################################################################
priority -50
# Many of the snippets here use a global option called
# "g:ultisnips_java_brace_style" which, if set to "nl" will put a newline
# before '{' braces.
# Setting "g:ultisnips_java_junit" will change how the test method snippet
# looks, it is defaulted to junit4, setting this option to 3 will remove the
# @Test annotation from the method
global !p
def junit(snip):
if snip.opt("g:ultisnips_java_junit", "") == "3":
snip += ""
else:
snip.rv += "@Test\n\t"
def nl(snip):
if snip.opt("g:ultisnips_java_brace_style", "") == "nl":
snip += ""
else:
snip.rv += " "
if snip.opt("g:ultisnips_java_brace_style", "") == "nl":
snip += ""
else:
snip.rv += " "
def getArgs(group):
import re
word = re.compile('[a-zA-Z><.]+ \w+')
return [i.split(" ") for i in word.findall(group) ]
def camel(word):
return word[0].upper() + word[1:]
endglobal
snippet sleep "try sleep catch" b
try {
Thread.sleep(${1:1000});
} catch (InterruptedException e){
e.printStackTrace();
}
endsnippet
snippet /i|n/ "new primitive or int" br
${1:int} ${2:i} = ${3:1};
$0
endsnippet
snippet /o|v/ "new Object or variable" br
${1:Object} ${2:var} = new $1(${3});
endsnippet
snippet f "field" b
${1:private} ${2:String} ${3:`!p snip.rv = t[2].lower()`};
endsnippet
snippet ab "abstract" b
abstract
abstract $0
endsnippet
snippet as "assert" b
assert ${1:test}${2/(.+)/(?1: \: ")/}${2:Failure message}${2/(.+)/(?1:")/};$0
endsnippet
snippet at "assert true" b
assertTrue(${1:actual});
endsnippet
snippet af "assert false" b
assertFalse(${1:actual});$0
endsnippet
snippet ae "assert equals" b
assertEquals(${1:expected}, ${2:actual});
endsnippet
snippet br "break"
break;
@ -39,19 +87,85 @@ catch (${1:Exception} ${2:e})`!p nl(snip)`{
}
endsnippet
snippet cl "class" b
class ${1:`!p
snippet cle "class extends" b
public class ${1:`!p
snip.rv = snip.basename or "untitled"`} ${2:extends ${3:Parent} }${4:implements ${5:Interface} }{
$0
}
endsnippet
snippet clc "class with constructor, fields, setter and getters" b
public class `!p
snip.rv = snip.basename or "untitled"` {
`!p
args = getArgs(t[1])
if len(args) == 0: snip.rv = ""
for i in args:
snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";"
if len(args) > 0:
snip.rv += "\n"`
public `!p snip.rv = snip.basename or "unknown"`($1) { `!p
args = getArgs(t[1])
for i in args:
snip.rv += "\n\t\tthis." + i[1] + " = " + i[1] + ";"
if len(args) == 0:
snip.rv += "\n"`
}$0
`!p
args = getArgs(t[1])
if len(args) == 0: snip.rv = ""
for i in args:
snip.rv += "\n\tpublic void set" + camel(i[1]) + "(" + i[0] + " " + i[1] + ") {\n" + "\
\tthis." + i[1] + " = " + i[1] + ";\n\t}\n"
snip.rv += "\n\tpublic " + i[0] + " get" + camel(i[1]) + "() {\
\n\t\treturn " + i[1] + ";\n\t}\n"
`
}
endsnippet
snippet clc "class with constructor, with field names" b
public class `!p
snip.rv = snip.basename or "untitled"` {
`!p
args = getArgs(t[1])
for i in args:
snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";"
if len(args) > 0:
snip.rv += "\n"`
public `!p snip.rv = snip.basename or "unknown"`($1) { `!p
args = getArgs(t[1])
for i in args:
snip.rv += "\n\t\tthis." + i[1] + " = " + i[1]
if len(args) == 0:
snip.rv += "\n"`
}
}
endsnippet
snippet clc "class and constructor" b
public class `!p
snip.rv = snip.basename or "untitled"` {
public `!p snip.rv = snip.basename or "untitled"`($2) {
$0
}
}
endsnippet
snippet cl "class" b
public class ${1:`!p
snip.rv = snip.basename or "untitled"`} {
$0
}
endsnippet
snippet cos "constant string" b
static public final String ${1:var} = "$2";$0
public static final String ${1:var} = "$2";$0
endsnippet
snippet co "constant" b
static public final ${1:String} ${2:var} = $3;$0
public static final ${1:String} ${2:var} = $3;$0
endsnippet
snippet de "default" b
@ -59,7 +173,7 @@ default:
$0
endsnippet
snippet eif "else if" b
snippet elif "else if" b
else if ($1)`!p nl(snip)`{
$0
}
@ -72,7 +186,7 @@ else`!p nl(snip)`{
endsnippet
snippet fi "final" b
final
final $0
endsnippet
snippet fore "for (each)" b
@ -81,6 +195,12 @@ for ($1 : $2)`!p nl(snip)`{
}
endsnippet
snippet fori "for" b
for (int ${1:i} = 0; $1 < ${2:10}; $1++)`!p nl(snip)`{
$0
}
endsnippet
snippet for "for" b
for ($1; $2; $3)`!p nl(snip)`{
$0
@ -99,7 +219,7 @@ $0
endsnippet
snippet im "import" b
import
import ${1:java}.${2:util}.$0
endsnippet
snippet in "interface" b
@ -108,6 +228,48 @@ interface ${1:`!p snip.rv = snip.basename or "untitled"`} ${2:extends ${3:Parent
}
endsnippet
snippet cc "constructor call or setter body"
this.${1:var} = $1;
endsnippet
snippet list "Collections List" b
List<${1:String}> ${2:list} = new ${3:Array}List<$1>();
endsnippet
snippet map "Collections Map" b
Map<${1:String}, ${2:String}> ${3:map} = new ${4:Hash}Map<$1, $2>();
endsnippet
snippet set "Collections Set" b
Set<${1:String}> ${2:set} = new ${3:Hash}Set<$1>();
endsnippet
snippet /Str?|str/ "String" br
String $0
endsnippet
snippet cn "Constructor" b
public `!p snip.rv = snip.basename or "untitled"`(${1:}) {
$0
}
endsnippet
snippet cn "constructor, \w fields + assigments" b
`!p
args = getArgs(t[1])
for i in args:
snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";"
if len(args) > 0:
snip.rv += "\n"`
public `!p snip.rv = snip.basename or "unknown"`($1) { `!p
args = getArgs(t[1])
for i in args:
snip.rv += "\n\t\tthis." + i[1] + " = " + i[1]
if len(args) == 0:
snip.rv += "\n"`
}
endsnippet
snippet j.b "java_beans_" i
java.beans.
endsnippet
@ -134,15 +296,70 @@ public static void main(String[] args)`!p nl(snip)`{
}
endsnippet
snippet m "method" b
${1:void} ${2:method}($3) ${4:throws $5 }{
snippet try "try/catch" b
try {
$1
} catch(${2:Exception} ${3:e}){
${4:e.printStackTrace();}
}
endsnippet
snippet mt "method throws" b
${1:private} ${2:void} ${3:method}(${4}) ${5:throws $6 }{
$0
}
endsnippet
snippet m "method" b
${1:private} ${2:void} ${3:method}(${4}) {
$0
}
endsnippet
snippet md "Method With javadoc" b
/**
* ${7:Short Description}`!p
for i in getArgs(t[4]):
snip.rv += "\n\t * @param " + i[1] + " usage..."`
* `!p
if "throws" in t[5]:
snip.rv = "\n\t * @throws " + t[6]
else:
snip.rv = ""` `!p
if not "void" in t[2]:
snip.rv = "\n\t * @return object"
else:
snip.rv = ""`
**/
${1:public} ${2:void} ${3:method}($4) ${5:throws $6 }{
$0
}
endsnippet
snippet /get(ter)?/ "getter" br
public ${1:String} get${2:Name}() {
return `!p snip.rv = t[2].lower()`;
}
endsnippet
snippet /set(ter)?/ "setter" br
public void set${1:Name}(${2:String} $1) {
return this.`!p snip.rv = t[1].lower()` = `!p snip.rv = t[1].lower()`;
}
endsnippet
snippet /se?tge?t|ge?tse?t|gs/ "setter and getter" br
public void set${1:Name}(${2:String} `!p snip.rv = t[1].lower()`) {
this.`!p snip.rv = t[1].lower()` = `!p snip.rv = t[1].lower()`;
}
public $2 get$1() {
return `!p snip.rv = t[1].lower()`;
}
endsnippet
snippet pa "package" b
package
package $0
endsnippet
snippet p "print" b
@ -154,33 +371,33 @@ System.out.println($1);$0
endsnippet
snippet pr "private" b
private
private $0
endsnippet
snippet po "protected" b
protected
protected $0
endsnippet
snippet pu "public" b
public
public $0
endsnippet
snippet re "return" b
return
return $0
endsnippet
snippet st "static"
static
static $0
endsnippet
snippet sw "switch" b
switch ($1)`!p nl(snip)`{
$0
case $2: $0
}
endsnippet
snippet sy "synchronized"
synchronized
synchronized $0
endsnippet
snippet tc "test case"
@ -190,17 +407,19 @@ public class ${1:`!p snip.rv = snip.basename or "untitled"`} extends ${2:TestCas
endsnippet
snippet t "test" b
public void test${1:Name}() throws Exception`!p nl(snip)`{
`!p junit(snip)`public void test${1:Name}() {
$0
}
endsnippet
snippet tt "test throws" b
`!p junit(snip)`public void test${1:Name}() ${2:throws Exception }{
$0
}
endsnippet
snippet th "throw" b
throw $0
endsnippet
snippet v "variable" b
${1:String} ${2:var}${3: = ${0:null}};
throw new $0
endsnippet
snippet wh "while" b

View File

@ -1,3 +1,5 @@
priority -50
###########################################################################
# TextMate Snippets #
###########################################################################
@ -6,19 +8,19 @@ getElement${1/(T)|.*/(?1:s)/}By${1:T}${1/(T)|(I)|.*/(?1:agName)(?2:d)/}('$2')
endsnippet
snippet '':f "object method string"
'${1:${2:#thing}:${3:click}}': function(element){
$0
'${1:${2:#thing}:${3:click}}': function(element) {
${VISUAL}$0
}${10:,}
endsnippet
snippet :f "Object Method"
${1:method_name}: function(${3:attribute}){
$0
${1:method_name}: function(${3:attribute}) {
${VISUAL}$0
}${10:,}
endsnippet
snippet :, "Object Value JS"
${1:value_name}:${0:value},
${1:value_name}: ${0:value},
endsnippet
snippet : "Object key key: 'value'"
@ -26,47 +28,135 @@ ${1:key}: ${2:"${3:value}"}${4:, }
endsnippet
snippet proto "Prototype (proto)"
${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) ,,{
${0}
}
${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) {
${VISUAL}$0
};
endsnippet
snippet for "for (...) {...} (faster)"
for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2--){
${3:$1[$2]}$0
snippet for "for (...) {...} (counting up)" b
for (var ${1:i} = 0, ${2:len} = ${3:Things.length}; $1 < $2; $1++) {
${VISUAL}$0
}
endsnippet
snippet for "for (...) {...}"
for (var ${2:i}=0; $2 < ${1:Things}.length; $2++) {
${3:$1[$2]}$0
snippet ford "for (...) {...} (counting down, faster)" b
for (var ${2:i} = ${1:Things.length} - 1; $2 >= 0; $2--) {
${VISUAL}$0
}
endsnippet
snippet fun "function (fun)"
function ${1:function_name} (${2:argument}) {
${0}
function ${1:function_name}(${2:argument}) {
${VISUAL}$0
}
endsnippet
# for one line if .. else you usually use a ? b : c
snippet iife "Immediately-Invoked Function Expression (iife)"
(function (${1:argument}) {
${VISUAL}$0
}(${2:$1}));
endsnippet
snippet ife "if ___ else"
if (${1}) {
${2}
} else {
${3}
if (${1:condition}) {
${2://code}
}
else {
${3://code}
}
endsnippet
snippet if "if"
if (${1}) {
${2}
if (${1:condition}) {
${VISUAL}$0
}
endsnippet
snippet timeout "setTimeout function"
setTimeout(function() {$0}${2:}, ${1:10})
setTimeout(function() {
${VISUAL}$0
}${2:.bind(${3:this})}, ${1:10});
endsnippet
# Snippets for Console Debug Output
snippet ca "console.assert" b
console.assert(${1:assertion}, ${2:"${3:message}"});
endsnippet
snippet cclear "console.clear" b
console.clear();
endsnippet
snippet cdir "console.dir" b
console.dir(${1:object});
endsnippet
snippet cdirx "console.dirxml" b
console.dirxml(${1:object});
endsnippet
snippet ce "console.error" b
console.error(${1:"${2:value}"});
endsnippet
snippet cgroup "console.group" b
console.group("${1:label}");
${VISUAL}$0
console.groupEnd();
endsnippet
snippet cgroupc "console.groupCollapsed" b
console.groupCollapsed("${1:label}");
${VISUAL}$0
console.groupEnd();
endsnippet
snippet ci "console.info" b
console.info(${1:"${2:value}"});
endsnippet
snippet cl "console.log" b
console.log(${1:"${2:value}"});
endsnippet
snippet cprof "console.profile" b
console.profile("${1:label}");
${VISUAL}$0
console.profileEnd();
endsnippet
snippet ctable "console.table" b
console.table(${1:"${2:value}"});
endsnippet
snippet ctime "console.time" b
console.time("${1:label}");
${VISUAL}$0
console.timeEnd("$1");
endsnippet
snippet ctimestamp "console.timeStamp" b
console.timeStamp("${1:label}");
endsnippet
snippet ctrace "console.trace" b
console.trace();
endsnippet
snippet cw "console.warn" b
console.warn(${1:"${2:value}"});
endsnippet
# AMD (Asynchronous Module Definition) snippets
snippet def "define an AMD module"
define(${1:optional_name, }[${2:'jquery'}], ${3:callback});
endsnippet
snippet req "require an AMD module"
require([${1:'dependencies'}], ${2:callback});
endsnippet
# vim:ft=snippets:

View File

@ -2,6 +2,8 @@
# Ember snippets #
###################################################################
priority -50
# Application
snippet eapp "App.Name = Ember.Application.create({});"
${1:App.Name} = Ember.Application.create({});
@ -10,48 +12,48 @@ endsnippet
# Models
snippet emod "App.ModelName = Ember.Model.extend({...});"
${1:model_name} = Ember.Model.extend({
${0://Properties here...}
${0://Properties here...}
});
endsnippet
# View
snippet eview "App.ViewName = Ember.Model.extend({...});"
${1:view_name} = Ember.View.extend({
${0://Properties here...}
${0://Properties here...}
});
endsnippet
# Controller
snippet econtroller "App.ControllerName = Ember.Model.extend({...});"
${1:controller_name} = Ember.ObjectController.extend({
${0://Properties here...}
${0://Properties here...}
});
endsnippet
# Route
snippet eroute "App.RouteName = Ember.Route.extend({...});"
${1:route_name} = Ember.Route.extend({
${0://Properties here...}
${0://Properties here...}
});
endsnippet
snippet eview "App.ViewName = Ember.Model.create({...});"
${1:view_name} = Ember.View.create({
${0://Properties here...}
${0://Properties here...}
});
endsnippet
# Object
snippet eobj "App.ObjectName = Ember.Object.extend({...});"
${1:object_name} = Ember.Object.create({
${0://Properties here...}
${0://Properties here...}
});
endsnippet
# Mixin
snippet emix "App.MixinName = Ember.Model.extend({...});"
${1:view_name} = Ember.Mixin.create({
${0://Properties here...}
${0://Properties here...}
});
endsnippet
@ -67,13 +69,13 @@ endsnippet
# Computer properties
snippet cpro "property_name: function() {...}.property(),"
${1:property_name}: function() {
${0://body...}
${0://body...}
}.property('${3:argumenet}'),
endsnippet
snippet cpro ": function() {...}.property('property'),"
${1:property_name}: function() {
${0://body...}
${0://body...}
}.property(),
endsnippet
@ -81,7 +83,7 @@ endsnippet
# Observes
snippet proo "property_name: function() {...}.property()"
${1:property_name}: function() {
${0://body...}
${0://body...}
}.observes('${3:property}'),
endsnippet

View File

@ -1,8 +1,8 @@
#
priority -50
# JavaScript versions -- from the TextMate bundle + some additions
# for jasmine-jquery matchers
#
extends javascript
snippet des "Describe (js)" b
describe('${1:description}', function() {
@ -165,4 +165,3 @@ endsnippet
snippet noscw "expect was not called with (js)" b
expect(${1:target}).wasNotCalledWith(${2:arguments});
endsnippet

View File

@ -0,0 +1,51 @@
priority -50
# JSDoc snippets
snippet /* "A JSDoc comment" b
/**
* ${1:${VISUAL}}$0
*/
endsnippet
snippet @au "@author email (First Last)"
@author ${1:`!v g:snips_author_email`} (${2:`!v g:snips_author`})
endsnippet
snippet @li "@license Description"
@license ${1:MIT}$0
endsnippet
snippet @ver "@version Semantic version"
@version ${1:0.1.0}$0
endsnippet
snippet @fileo "@fileoverview Description" b
/**
* @fileoverview ${1:${VISUAL:A description of the file}}$0
*/
endsnippet
snippet @constr "@constructor"
@constructor
endsnippet
snippet @p "@param {Type} varname Description"
@param {${1:Type}} ${2:varname} ${3:Description}
endsnippet
snippet @ret "@return {Type} Description"
@return {${1:Type}} ${2:Description}
endsnippet
snippet @pri "@private"
@private
endsnippet
snippet @over "@override"
@override
endsnippet
snippet @pro "@protected"
@protected
endsnippet

View File

@ -1,3 +1,4 @@
priority -50
# http://jinja.pocoo.org/
@ -11,7 +12,7 @@
snippet block "block" b
{% block ${1:name} %}
$2
$2
{% endblock $1 %}
endsnippet
@ -33,7 +34,7 @@ endsnippet
snippet raw "escaped block" b
{% raw %}
$1
$1
{% endraw %}
endsnippet
@ -60,7 +61,7 @@ endsnippet
snippet filter "filter" b
{% filter ${1:filter} %}
$2
$2
{% endfilter %}
endsnippet
@ -78,57 +79,57 @@ endsnippet
snippet for "for" b
{% for ${1:item} in ${2:sequence} %}
$3
$3
{% endfor %}
endsnippet
snippet for "for/else" b
{% for ${1:item} in ${2:sequence} %}
$3
$3
{% else %}
$4
$4
{% endfor %}
endsnippet
snippet if "if" b
{% if ${1:expr} %}
$2
$2
{% endif %}
endsnippet
snippet if "if/else" b
{% if ${1:expr} %}
$2
$2
{% else %}
$3
$3
{% endif %}
endsnippet
snippet if "if/elif/else" b
{% if ${1:expr} %}
$2
$2
{% elif %}
$3
$3
{% else %}
$4
$4
{% endif %}
endsnippet
snippet macro "macro" b
{% macro ${1:name}(${2:args}) %}
$3
$3
{% endmacro %}
endsnippet
snippet call "call" b
{% call ${1:name}(${2:args}) %}
$3
$3
{% endcall %}
endsnippet
@ -140,21 +141,20 @@ endsnippet
snippet trans "translation" b
{% trans %}
$1
$1
{% endtrans %}
endsnippet
snippet with "with" b
{% with %}
$1
$1
{% endwith %}
endsnippet
snippet autoescape "autoescape" b
{% autoescape ${1:true} %}
$2
$2
{% endautoescape %}
endsnippet

View File

@ -1,3 +1,5 @@
priority -50
snippet s "String" b
"${1:key}": "${0:value}",
endsnippet
@ -8,12 +10,11 @@ endsnippet
snippet a "Array" b
[
${VISUAL}$0
${VISUAL}$0
],
endsnippet
snippet o "Object" b
{
${VISUAL}$0
${VISUAL}$0
},
endsnippet

View File

@ -0,0 +1,8 @@
priority -50
snippet t "Transaction" b
${1:`!v strftime("%Y")`}-${2:`!v strftime("%m")`}-${3:`!v strftime("%d")`} ${4:*} ${5:Payee}
${6:Expenses} \$${7:0.00}
${8:Assets:Checking}
$0
endsnippet

View File

@ -0,0 +1,3 @@
priority -50
extends haskell

View File

@ -1,3 +1,5 @@
priority -50
#################################
# Snippets for the Lua language #
#################################
@ -8,25 +10,25 @@ endsnippet
snippet !fun(ction)?! "New function" br
function ${1:new_function}(${2:args})
$0
$0
end
endsnippet
snippet forp "pair for loop" b
for ${1:name},${2:val} in pairs(${3:table_name}) do
$0
$0
end
endsnippet
snippet fori "ipair for foop" b
for ${1:idx},${2:val} in ipairs(${3:table_name}) do
$0
$0
end
endsnippet
snippet for "numeric for loop" b
for ${1:i}=${2:first},${3:last}${4/^..*/(?0:,:)/}${4:step} do
$0
$0
end
endsnippet

View File

@ -1,3 +1,5 @@
priority -50
#################
# From snipmate #
#################

View File

@ -1,6 +1,4 @@
###########################################################################
# SNIPPETS for MARKDOWN #
###########################################################################
priority -50
###########################
# Sections and Paragraphs #

View File

@ -1,3 +1,5 @@
priority -50
###########################################################################
# TextMate Snippets #
###########################################################################
@ -13,9 +15,9 @@ endsnippet
snippet cl "020 Class (objc)"
@interface ${1:`!p
if len(fn):
snip.rv = re.sub(r'\..*$', '', fn)
snip.rv = re.sub(r'\..*$', '', fn)
else:
snip.rv = "object"
snip.rv = "object"
`} : ${2:NSObject}
{
}
@ -189,7 +191,7 @@ if(choice == NSAlertDefaultReturn) // "$3"
}
else if(choice == NSAlertAlternateReturn) // "$4"
{
$0
}
endsnippet
@ -217,7 +219,7 @@ endsnippet
snippet responds "Responds to Selector"
if ([${1:self} respondsToSelector:@selector(${2:someSelector:})])
{
[$1 ${3:${2/((:\s*$)|(:\s*))/:<>(?3: )/g}}];
[$1 ${3:${2/((:\s*$)|(:\s*))/:<>(?3: )/g}}];
}
endsnippet

View File

@ -1,20 +1,22 @@
priority -50
snippet rs "raise" b
raise (${1:Not_found})
endsnippet
snippet open "open"
let open ${1:module} in
${2}
${2:e}
endsnippet
snippet try "try"
try ${1}
try ${1:e}
with ${2:Not_found} -> ${3:()}
endsnippet
snippet ref "ref"
let ${1} = ref ${2} in
${3}
let ${1:name} = ref ${2:val} in
${3:e}
endsnippet
snippet matchl "pattern match on a list"
@ -24,83 +26,88 @@ match ${1:list} with
endsnippet
snippet matcho "pattern match on an option type"
match ${1} with
| Some(${2}) -> ${3:()}
match ${1:x} with
| Some(${2:y}) -> ${3:()}
| None -> ${4:()}
endsnippet
snippet fun "anonymous function"
(fun ${1} -> ${2})
(fun ${1:x} -> ${2:x})
endsnippet
snippet cc "commment"
(* ${1} *)
(* ${1:comment} *)
endsnippet
snippet let "let .. in binding"
let ${1} = ${2} in
${3}
let ${1:x} = ${2:v} in
${3:e}
endsnippet
snippet lr "let rec"
let rec ${1} =
${2}
let rec ${1:f} =
${2:expr}
endsnippet
snippet ife "if"
if ${1} then
${2}
snippet if "if"
if ${1:(* condition *)} then
${2:(* A *)}
else
${3}
${3:(* B *)}
endsnippet
snippet if "If"
if ${1} then
${2}
snippet If "If"
if ${1:(* condition *)} then
${2:(* A *)}
endsnippet
snippet wh "while"
while ${1} do
${2}
snippet while "while"
while ${1:(* condition *)} do
${2:(* A *)}
done
endsnippet
snippet for "for"
for ${1:i} = ${2:1} to ${3:10} do
${4}
${4:(* BODY *)}
done
endsnippet
snippet match "match"
match ${1} with
| ${2} -> ${3}
match ${1:(* e1 *)} with
| ${2:p} -> ${3:e2}
endsnippet
snippet Match "match"
match ${1:(* e1 *)} with
| ${2:p} -> ${3:e2}
endsnippet
snippet class "class"
class ${1:name} = object
${2}
${2:methods}
end
endsnippet
snippet obj "obj"
object
${2}
${2:methods}
end
endsnippet
snippet Obj "object"
object (self)
${2}
${2:methods}
end
endsnippet
snippet {{ "object functional update"
{< ${1} = ${2} >}
{< ${1:x} = ${2:y} >}
endsnippet
snippet beg "beg"
begin
${1}${VISUAL}
${1:block}
end
endsnippet
@ -110,19 +117,19 @@ endsnippet
snippet mod "module - no signature"
module ${1:(* Name *)} = struct
${2}
${2:(* BODY *)}
end
endsnippet
snippet Mod "module with signature"
module ${1:(* Name *)} : ${2:(* SIG *)} = struct
${3}
${3:(* BODY *)}
end
endsnippet
snippet sig "anonymous signature"
sig
${2}
${2:(* BODY *)}
end
endsnippet
@ -132,36 +139,36 @@ endsnippet
snippet func "define functor - no signature"
module ${1:M} (${2:Arg} : ${3:ARG}) = struct
${4}
${4:(* BODY *)}
end
endsnippet
snippet Func "define functor - with signature"
module ${1:M} (${2:Arg} : ${3:ARG}) : ${4:SIG} = struct
${5}
${5:(* BODY *)}
end
endsnippet
snippet mot "Declare module signature"
module type ${1:(* Name *)} = sig
${2}
${2:(* BODY *)}
end
endsnippet
snippet module "Module with anonymous signature"
module ${1:(* Name *)} : sig
${2}
${2:(* SIGNATURE *)}
end = struct
${3}
${3:(* BODY *)}
end
endsnippet
snippet oo "odoc"
(** ${1} *)
(** ${1:odoc} *)
endsnippet
snippet qt "inline qtest"
(*$T ${1:name}
${2:test}
${2:test}
*)
endsnippet

View File

@ -1,10 +1,13 @@
priority -50
###########################################################################
# TextMate Snippets #
###########################################################################
snippet ife "Conditional if..else (ife)"
if ($1) {
${2:# body...}
} else {
}
else {
${3:# else...}
}
@ -13,9 +16,11 @@ endsnippet
snippet ifee "Conditional if..elsif..else (ifee)"
if ($1) {
${2:# body...}
} elsif ($3) {
}
elsif ($3) {
${4:# elsif...}
} else {
}
else {
${5:# else...}
}
@ -49,7 +54,7 @@ ${1:expression} while ${2:condition};
endsnippet
snippet test "Test"
#!/usr/bin/perl -w
#!/usr/bin/env perl -w
use strict;
use Test::More tests => ${1:1};
@ -62,7 +67,7 @@ endsnippet
snippet class "class"
package ${1:ClassName};
${2:use base qw(${3:ParentClass});}${2/.+/\n\n/}sub new {
${2:use parent qw(${3:ParentClass});}${2/.+/\n\n/}sub new {
my $class = shift;
$class = ref $class if ref $class;
my $self = bless {}, $class;
@ -74,11 +79,12 @@ ${2:use base qw(${3:ParentClass});}${2/.+/\n\n/}sub new {
endsnippet
snippet eval "eval"
local $@;
eval {
${1:# do something risky...}
};
if ($@) {
${2:# handle failure...}
if (my $${2:exception} = $@) {
${3:# handle failure...}
}
endsnippet
@ -105,8 +111,7 @@ if ($1) {
endsnippet
snippet slurp "slurp"
my $${1:var};
{ local $/ = undef; local *FILE; open FILE, "<${2:file}"; $$1 = <FILE>; close FILE }
my $${1:var} = do { local $/ = undef; open my $fh, '<', ${2:$file}; <$fh> };
endsnippet
@ -117,7 +122,7 @@ unless ($1) {
endsnippet
snippet wh "while"
snippet while "while"
while ($1) {
${2:# body...}
}

View File

@ -1,108 +1,264 @@
snippet <? "php open tag" b
<?php
priority -50
## Snippets from SnipMate, taken from
## https://github.com/scrooloose/snipmate-snippets.git
snippet array "array"
$${1:arrayName} = array('${2}' => ${3});${4}
endsnippet
snippet vdd "php var_dump and die"
var_dump(${1}); die();
snippet def "def"
define('${1}'${2});${3}
endsnippet
snippet ns "php namespace" b
namespace ${1:`!p
abspath = os.path.abspath(path)
m = re.search(r'[A-Z].+(?=/)', abspath)
if m:
snip.rv = m.group().replace('/', '\\')
`};
snippet do "do"
do {
${2:// code... }
} while (${1:/* condition */});"
endsnippet
snippet nc "php namespace and class or interface" b
namespace ${1:`!p
abspath = os.path.abspath(path)
m = re.search(r'[A-Z].+(?=/)', abspath)
if m:
snip.rv = m.group().replace('/', '\\')
`};
snippet doc_f "doc_f"
/**
* ${3:@author `whoami`}${4}
*/
`!p
m = re.search(r'Abstract', path)
if m:
snip.rv = 'abstract '
``!p
if re.search(r'Interface', path):
snip.rv = 'interface'
elif re.search(r'Trait', path):
snip.rv = 'trait'
else:
snip.rv = 'class'
` ${2:`!p
snip.rv = re.match(r'.*(?=\.)', fn).group()
`}
{
* $2
* @return ${4:void}
* @author ${5:`!v g:snips_author`}
**/
${1:public }function ${2:someFunc}(${3})
{${6}
}
endsnippet
snippet st "php static function" b
${1:public} static function $2($3)
{
${4}
}
endsnippet
snippet __ "php constructor" b
${1:public} function __construct($2)
{
${3}
}
endsnippet
snippet sg "Setter and Getter" b
snippet doc_i "doc_i"
/**
* @var ${3:`!p snip.rv = t[2][0:1].upper() + t[2][1:]`}
*
* ${4}
* $1
* @package ${2:default}
* @author ${3:`!v g:snips_author`}
**/
interface ${1:someClass}
{${4}
} // END interface $1"
endsnippet
snippet else "else"
else {
${1:// code...}
}
endsnippet
snippet for "for"
for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {
${4:// code...}
}
endsnippet
snippet foreachk "foreachk"
foreach ($${1:variable} as $${2:key} => $${3:value}){
${4:// code...}
}
endsnippet
snippet get "get"
$_GET['${1}']${2}
endsnippet
snippet if "if"
if (${1:/* condition */}) {
${2:// code...}
}
endsnippet
snippet inc "inc"
include '${1:file}';${2}
endsnippet
snippet log "log"
error_log(var_export(${1}, true));${2}
endsnippet
snippet post "post"
$_POST['${1}']${2}
endsnippet
snippet req1 "req1"
require_once '${1:file}';${2}
endsnippet
snippet session "session"
$_SESSION['${1}']${2}
endsnippet
snippet t "t"
$${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b};${5}
endsnippet
snippet var "var"
var_export(${1});${2}
endsnippet
snippet getter "PHP Class Getter" b
/*
* Getter for $1
*/
${1:protected} $${2};
public function set`!p snip.rv = t[2][0:1].upper() + t[2][1:]`(`!p
if re.match(r'^(\\|[A-Z]).*', t[3]):
snip.rv = t[3] + ' '
else:
snip.rv = ''
`$$2)
public function get${1/\w+\s*/\u$0/}()
{
$this->$2 = $$2;
return $this;
}
public function get`!p snip.rv = t[2][0:1].upper() + t[2][1:]`()
{
return $this->$2;
return $this->$1;$2
}
$4
endsnippet
snippet if "php if" !b
if (${1}) {
${2}
snippet setter "PHP Class Setter" b
/*
* Setter for $1
*/
public function set${1/\w+\s*/\u$0/}($$1)
{
$this->$1 = $$1;$3
${4:return $this;}
}
$0
endsnippet
snippet ife "php ife" !b
if (${1}) {
${2}
snippet gs "PHP Class Getter Setter" b
/*
* Getter for ${1/(\w+)\s*;/$1/}
*/
public function get${1/(\w+)\s*;/\u$1/}()
{
return $this->${1/(\w+)\s*;/$1/};$2
}
/*
* Setter for ${1/(\w+)\s*;/$1/}
*/
public function set${1/(\w+)\s*;/\u$1/}($${1/(\w+)\s*;/$1/})
{
$this->${1/(\w+)\s*;/$1/} = $${1/(\w+)\s*;/$1/};$3
${4:return $this;}
}
$0
endsnippet
snippet pub "Public function" b
public function ${1:name}(${2:$param})
{
${VISUAL}${3:return null;}
}
$0
endsnippet
snippet pro "Protected function" b
protected function ${1:name}(${2:$param})
{
${VISUAL}${3:return null;}
}
$0
endsnippet
snippet pri "Private function" b
private function ${1:name}(${2:$param})
{
${VISUAL}${3:return null;}
}
$0
endsnippet
snippet pubs "Public static function" b
public static function ${1:name}(${2:$param})
{
${VISUAL}${3:return null;}
}
$0
endsnippet
snippet pros "Protected static function" b
protected static function ${1:name}(${2:$param})
{
${VISUAL}${3:return null;}
}
$0
endsnippet
snippet pris "Private static function" b
private static function ${1:name}(${2:$param})
{
${VISUAL}${3:return null;}
}
$0
endsnippet
snippet fu "Function snip" b
function ${1:name}(${2:$param})
{
${VISUAL}${3:return null;}
}
$0
endsnippet
snippet fore "Foreach loop"
foreach ($${1:variable} as $${3:value}){
${VISUAL}${4}
}
$0
endsnippet
snippet new "New class instance" b
$$1 = new $1($2);
$0
endsnippet
snippet ife "if else"
if (${1:/* condition */}) {
${2:// code...}
} else {
${3:// code...}
}
$0
endsnippet
snippet class "Class declaration template" b
/**
* Class ${1:`!p snip.rv=snip.fn.split('.')[0]`}
* @author ${2:`!v g:snips_author`}
*/
class $1
{
public function ${3:__construct}(${4:$options})
{
${4:// code}
}
}
$0
endsnippet
snippet construct "__construct()" b
/**
* @param $2mixed ${1/, /\n * \@param mixed /g}
*/
public function __construct(${1:$dependencies})
{${1/\$(\w+)(, )*/\n $this->$1 = $$1;/g}
}
$0
endsnippet
snippet pr "Dumb debug helper in HTML"
echo '<pre>' . var_export($1, 1) . '</pre>';$0
endsnippet
snippet pc "Dumb debug helper in cli"
var_export($1);$0
endsnippet
# Symfony 2 based snippets
snippet sfa "Symfony 2 Controller action"
/**
* @Route("/${1:route_name}", name="$1")
* @Template()
*/
public function $1Action($2)
{
$3
return ${4:array();}$0
}
endsnippet
snippet /** "php comment block" b
/**
* @${1}
*/
endsnippet
# :vim:ft=snippets:

View File

@ -1,5 +1,7 @@
# sugguestion? report bugs?
# suggestion? report bugs?
# please go to https://github.com/chrisyue/vim-snippets/issues
priority -50
snippet test "phpunit test class" b
namespace `!p
abspath = os.path.abspath(path)

View File

@ -1,6 +1,8 @@
# sugguestion? report bugs?
# go to https://github.com/chrisyue/vim-snippets/issues
priority -50
snippet contr "Symfony2 controller" b
namespace `!p
abspath = os.path.abspath(path)
@ -210,22 +212,22 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
` extends AbstractType
{
/**
* {@inheritDoc}
* {@inheritDoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
}
/**
* {@inheritDoc}
* {@inheritDoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults();
$resolver->setDefaults();
}
/**
* {@inheritDoc}
* {@inheritDoc}
*/
public function getName()
{

View File

@ -1,78 +1,232 @@
# Snippets for Puppet
priority -50
snippet /^class/ "Class declaration" r
class ${1:name} {
${0:# body}
#########################################################################
# Python helper code #
#########################################################################
global !p
import vim
import os.path
def get_module_namespace_and_basename():
"""This function will try to guess the current class or define name you are
trying to create. Note that for this to work you should be using the module
structure as per the style guide. Examples inputs and it's output
* /home/nikolavp/puppet/modules/collectd/manifests/init.pp -> collectd
* /home/nikolavp/puppet/modules/collectd/manfistes/mysql.pp -> collectd::mysql
"""
first_time = True
current_file_path_without_ext = vim.eval('expand("%:p:r")') or ""
if not current_file_path_without_ext:
return "name"
parts = os.path.split(current_file_path_without_ext)
namespace = ''
while parts[0] and parts[0] != '/':
if parts[1] == 'init' and first_time and not namespace:
first_time = False
parts = os.path.split(parts[0])
continue
if parts[1] == 'manifests':
return os.path.split(parts[0])[1] + ('::' + namespace).rstrip(':')
else:
namespace = parts[1] + '::' + namespace
parts = os.path.split(parts[0])
# couldn't guess the namespace. The user is editing a raw file in no module like the site.pp file
return "name"
endglobal
###############################################################################
# Puppet Language Constructs #
# See http://docs.puppetlabs.com/puppet/latest/reference/lang_summary.html #
###############################################################################
snippet class "Class declaration" b
class ${1:`!p snip.rv = get_module_namespace_and_basename()`} {
${0:# body}
}
endsnippet
snippet File "Defaults for file" b
File {
owner => ${1:username},
group => ${2:groupname},
snippet define "Definition" b
define ${1:`!p snip.rv = get_module_namespace_and_basename()`} {
${0:# body}
}
endsnippet
# Resource types
snippet package "Package resource type" b
package { "${1:name}":
ensure => ${2:installed},
#################################################################
# Puppet Types #
# See http://docs.puppetlabs.com/references/latest/type.html #
#################################################################
snippet cron "Cron resource type" b
cron { '${1:name}':
user => ${2:user},
command => '${3:command}',
minute => ${3:minute},
hour => ${4:hour},
}
endsnippet
snippet exec "Exec resource type" b
exec { '${1:command}':
refreshonly => true,
}
endsnippet
snippet file "File resource type" b
file { "${1:name}":
source => "puppet://${2:path}",
mode => ${3:mode},
file { '${1:name}':
source => "puppet://${2:path}",
mode => ${3:mode},
endsnippet
snippet File "Defaults for file" b
File {
owner => ${1:username},
group => ${2:groupname},
}
endsnippet
snippet group "Group resource type" b
group { "${1:groupname}":
ensure => ${3:present},
gid => ${2:gid},
endsnippet
snippet user "user resource type" b
group { "${1:username}":
ensure => ${2:present},
uid => ${3:uid},
gid => ${4:gid},
comment => ${5:gecos},
home => ${6:homedirectory},
managehome => false,
require => Group["${7:group"],
endsnippet
snippet exec "Exec resource type" b
exec { "${1:command}":
refreshonly => true,
}
endsnippet
snippet cron "Cron resource type" b
cron { "${1:name}":
user => ${2:user},
command => "${3:command}",
minute => ${3:minute},
hour => ${4:hour},
}
group { '${1:groupname}':
ensure => ${3:present},
gid => ${2:gid},
endsnippet
snippet mount "Mount resource type" b
mount { "${1:path}":
device => "${2:/dev}",
fstype => "${3:filesystem}",
ensure => mounted,
options => "rw,errors=remount-ro",
mount { '${1:path}':
device => '${2:/dev}',
fstype => '${3:filesystem}',
ensure => mounted,
options => 'rw,errors=remount-ro',
}
endsnippet
snippet package "Package resource type" b
package { '${1:name}':
ensure => ${2:installed},
}
endsnippet
snippet user "user resource type" b
user { '${1:username}':
ensure => ${2:present},
uid => ${3:uid},
gid => ${4:gid},
comment => ${5:gecos},
home => ${6:homedirectory},
managehome => false,
require => Group['${7:group'}],
endsnippet
snippet service "Service resource type" b
service { "${1:name}":
hasstatus => true,
enable => true,
ensure => running,
service { '${1:name}':
hasstatus => true,
enable => true,
ensure => running,
}
endsnippet
########################################################################
# Puppet Functions #
# See http://docs.puppetlabs.com/references/latest/function.html #
########################################################################
snippet alert "Alert Function" b
alert("${1:message}")${0}
endsnippet
snippet crit "Crit Function" b
crit("${1:message}")${0}
endsnippet
snippet debug "Debug Function" b
debug("${1:message}")${0}
endsnippet
snippet defined "Defined Function" b
defined(${1:Resource}["${2:name}"])${0}
endsnippet
snippet emerg "Emerg Function" b
emerg("${1:message}")${0}
endsnippet
snippet extlookup "Simple Extlookup" b
$${1:Variable} = extlookup("${2:Lookup}")${0}
endsnippet
snippet extlookup "Extlookup with defaults" b
$${1:Variable} = extlookup("${2:Lookup}", ${3:Default})${0}
endsnippet
snippet extlookup "Extlookup with defaults and custom data file" b
$${1:Variable} = extlookup("${2:Lookup}", ${3:Default}, ${4:Data Source})${0}
endsnippet
snippet fail "Fail Function" b
fail("${1:message}")${0}
endsnippet
snippet hiera "Hiera Function" b
$${1:Variable} = hiera("${2:Lookup}")${0}
endsnippet
snippet hiera "Hiera with defaults" b
$${1:Variable} = hiera("${2:Lookup}", ${3:Default})${0}
endsnippet
snippet hiera "Hiera with defaults and override" b
$${1:Variable} = hiera("${2:Lookup}", ${3:Default}, ${4:Override})${0}
endsnippet
snippet hiera_hash "Hiera Hash Function" b
$${1:Variable} = hiera_hash("${2:Lookup}")${0}
endsnippet
snippet hiera_hash "Hiera Hash with defaults" b
$${1:Variable} = hiera_hash("${2:Lookup}", ${3:Default})${0}
endsnippet
snippet hiera_hash "Hiera Hash with defaults and override" b
$${1:Variable} = hiera_hash("${2:Lookup}", ${3:Default}, ${4:Override})${0}
endsnippet
snippet hiera_include "Hiera Include Function" b
hiera_include("${1:Lookup}")${0}
endsnippet
snippet include "Include Function" b
include ${1:classname}${0}
endsnippet
snippet info "Info Function" b
info("${1:message}")${0}
endsnippet
snippet inline_template "Inline Template Function" b
inline_template("<%= ${1:template} %>")${0}
endsnippet
snippet notice "Notice Function" b
notice("${1:message}")${0}
endsnippet
snippet realize "Realize Function" b
realize(${1:Resource}["${2:name}"])${0}
endsnippet
snippet regsubst "Regsubst Function" b
regsubst($${1:Target}, '${2:regexp}', '${3:replacement}')${0}
endsnippet
snippet split "Split Function" b
$${1:Variable} = split($${1:Target}, '${2:regexp}')${0}
endsnippet
snippet versioncmp "Version Compare Function" b
$${1:Variable} = versioncmp('${1:version}', '${2:version}')${0}
endsnippet
snippet warning "Warning Function" b
warning("${1:message}")${0}
endsnippet
# vim:ft=snippets:

View File

@ -1,3 +1,5 @@
priority -50
###########################################################################
# TEXTMATE SNIPPETS #
###########################################################################
@ -14,6 +16,10 @@ if __name__ == '__main__':
${1:main()}$0
endsnippet
snippet for "for loop" b
for ${1:item} in ${2:iterable}:
${3:pass}
endsnippet
##########
# COMMON #
@ -29,67 +35,81 @@ NORMAL = 0x1
DOXYGEN = 0x2
SPHINX = 0x3
SINGLE_QUOTES = 0x1
DOUBLE_QUOTES = 0x2
def get_args(arglist):
args = [arg.split('=')[0].strip() for arg in arglist.split(',') if arg]
args = [arg for arg in args if arg and arg != "self"]
args = [arg.split('=')[0].strip() for arg in arglist.split(',') if arg]
args = [arg for arg in args if arg and arg != "self"]
return args
return args
def get_quoting_style(snip):
style = snip.opt("g:ultisnips_python_quoting_style", "double")
if style == 'single':
return SINGLE_QUOTES
return DOUBLE_QUOTES
def tripple_quotes(snip):
if get_quoting_style(snip) == SINGLE_QUOTES:
return "'''"
return '"""'
def get_style(snip):
style = snip.opt("g:ultisnips_python_style", "normal")
style = snip.opt("g:ultisnips_python_style", "normal")
if style == "doxygen": return DOXYGEN
elif style == "sphinx": return SPHINX
else: return NORMAL
if style == "doxygen": return DOXYGEN
elif style == "sphinx": return SPHINX
else: return NORMAL
def format_arg(arg, style):
if style == DOXYGEN:
return "@param %s @todo" % arg
elif style == SPHINX:
return ":param %s: @todo" % arg
elif style == NORMAL:
return ":%s: @todo" % arg
if style == DOXYGEN:
return "@param %s @todo" % arg
elif style == SPHINX:
return ":param %s: @todo" % arg
elif style == NORMAL:
return ":%s: @todo" % arg
def format_return(style):
if style == DOXYGEN:
return "@return: @todo"
elif style in (NORMAL, SPHINX):
return ":returns: @todo"
if style == DOXYGEN:
return "@return: @todo"
elif style in (NORMAL, SPHINX):
return ":returns: @todo"
def write_docstring_args(args, snip):
if not args:
snip.rv += ' """'
return
if not args:
snip.rv += ' {0}'.format(tripple_quotes(snip))
return
snip.rv += '\n' + snip.mkline('', indent='')
snip.rv += '\n' + snip.mkline('', indent='')
style = get_style(snip)
style = get_style(snip)
for arg in args:
snip += format_arg(arg, style)
for arg in args:
snip += format_arg(arg, style)
def write_init_body(args, parents, snip):
parents = [p.strip() for p in parents.split(",")]
parents = [p for p in parents if p != 'object']
parents = [p.strip() for p in parents.split(",")]
parents = [p for p in parents if p != 'object']
for p in parents:
snip += p + ".__init__(self)"
for p in parents:
snip += p + ".__init__(self)"
if parents:
snip.rv += '\n' + snip.mkline('', indent='')
if parents:
snip.rv += '\n' + snip.mkline('', indent='')
for arg in args:
snip += "self._%s = %s" % (arg, arg)
for arg in args:
snip += "self._%s = %s" % (arg, arg)
def write_slots_args(args, snip):
args = ['"%s"' % arg for arg in args]
snip += '__slots__ = (%s,)' % ', '.join(args)
args = ['"_%s"' % arg for arg in args]
snip += '__slots__ = (%s,)' % ', '.join(args)
endglobal
@ -99,10 +119,11 @@ endglobal
snippet class "class with docstrings" b
class ${1:MyClass}(${2:object}):
"""${3:Docstring for $1 }"""
`!p snip.rv = tripple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = tripple_quotes(snip)`
def __init__(self$4):
"""${5:@todo: to be defined}`!p
`!p snip.rv = tripple_quotes(snip)`${5:@todo: to be defined1.}`!p
snip.rv = ""
snip >> 2
@ -110,8 +131,8 @@ args = get_args(t[4])
write_docstring_args(args, snip)
if args:
snip.rv += '\n' + snip.mkline('', indent='')
snip += '"""'
snip.rv += '\n' + snip.mkline('', indent='')
snip += '{0}'.format(tripple_quotes(snip))
write_init_body(args, t[2], snip)
`
@ -121,7 +142,8 @@ endsnippet
snippet slotclass "class with slots and docstrings" b
class ${1:MyClass}(${2:object}):
"""${3:Docstring for $1 }"""
`!p snip.rv = tripple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = tripple_quotes(snip)`
`!p
snip >> 1
args = get_args(t[4])
@ -129,7 +151,7 @@ write_slots_args(args, snip)
`
def __init__(self$4):
"""${5:@todo: to be defined}`!p
`!p snip.rv = tripple_quotes(snip)`${5:@todo: to be defined.}`!p
snip.rv = ""
snip >> 2
@ -137,8 +159,8 @@ args = get_args(t[4])
write_docstring_args(args, snip)
if args:
snip.rv += '\n' + snip.mkline('', indent='')
snip += '"""'
snip.rv += '\n' + snip.mkline('', indent='')
snip += tripple_quotes(snip)
write_init_body(args, t[2], snip)
`
@ -330,19 +352,19 @@ endsnippet
snippet def "function with docstrings" b
def ${1:function}(`!p
if snip.indent:
snip.rv = 'self' + (", " if len(t[2]) else "")`${2:arg1}):
"""${4:@todo: Docstring for $1}`!p
snip.rv = 'self' + (", " if len(t[2]) else "")`${2:arg1}):
`!p snip.rv = tripple_quotes(snip)`${4:@todo: Docstring for $1.}`!p
snip.rv = ""
snip >> 1
args = get_args(t[2])
if args:
write_docstring_args(args, snip)
write_docstring_args(args, snip)
style = get_style(snip)
snip += format_return(style)
snip.rv += '\n' + snip.mkline('', indent='')
snip += '"""' `
snip += tripple_quotes(snip) `
${0:pass}
endsnippet
@ -362,23 +384,57 @@ endsnippet
##############
snippet roprop "Read Only Property" b
@property
def ${1:property}(self):
def ${1:name}(self):
${2:return self._$1}$0
endsnippet
snippet rwprop "Read write property" b
def ${1:property}():
${2/.+/(?0:""")/}${2:The RW property $1}`!p if t[2]:
snip.rv += '"""'
snip >> 1
snip += ""
def ${1:name}():
`!p snip.rv = tripple_quotes(snip) if t[2] else ''
`${2:@todo: Docstring for $1.}`!p
if t[2]:
snip >> 1
style = get_style(snip)
snip.rv += '\n' + snip.mkline('', indent='')
snip += format_return(style)
snip.rv += '\n' + snip.mkline('', indent='')
snip += tripple_quotes(snip)
else:
snip.rv = ""`def fget(self):
snip.rv = ""`
def fget(self):
return self._$1$0
def fset(self, value):
self._$1 = value
return locals()
$1 = property(**$1())
$1 = property(**$1(), doc=$1.__doc__)
endsnippet
####################
# If / Else / Elif #
####################
snippet if "If" b
if ${1:condition}:
${2:pass}
endsnippet
snippet ife "If / Else" b
if ${1:condition}:
${2:pass}
else:
${3:pass}
endsnippet
snippet ifee "If / Elif / Else" b
if ${1:condition}:
${2:pass}
elif ${3:condition}:
${4:pass}
else:
${5:pass}
endsnippet
@ -430,6 +486,14 @@ snippet pdb "Set PDB breakpoint" b
import pdb; pdb.set_trace()
endsnippet
snippet ipdb "Set IPDB breakpoint" b
import ipdb; ipdb.set_trace()
endsnippet
snippet pudb "Set PUDB breakpoint" b
import pudb; pudb.set_trace()
endsnippet
snippet ae "Assert equal" b
self.assertEqual(${1:first},${2:second})
endsnippet
@ -453,7 +517,8 @@ endsnippet
snippet testcase "pyunit testcase" b
class Test${1:Class}(${2:unittest.TestCase}):
"""${3:Test case docstring}"""
`!p snip.rv = tripple_quotes(snip)`${3:Test case docstring.}`!p snip.rv = tripple_quotes(snip)`
def setUp(self):
${4:pass}

View File

@ -1,6 +1,4 @@
###########################################################################
# GENERATED FROM get_tm_snippets.py #
###########################################################################
priority -50
snippet anaf "accepts_nested_attributes_for"
accepts_nested_attributes_for :${1:association_name}${2:${3:, :allow_destroy => true}${4:, :reject_if => proc \{ |obj| ${5:obj.blank?} \}}}
@ -77,90 +75,90 @@ endsnippet
snippet resources "Create resources controller class"
class ${1:Model}sController < ApplicationController
before_filter :find_${1/./\l$0/}, :only => [:show, :edit, :update, :destroy]
before_filter :find_${1/./\l$0/}, :only => [:show, :edit, :update, :destroy]
# GET /${1/./\l$0/}s
# GET /${1/./\l$0/}s.xml
def index
@${1/./\l$0/}s = ${1:Model}.all
# GET /${1/./\l$0/}s
# GET /${1/./\l$0/}s.xml
def index
@${1/./\l$0/}s = ${1:Model}.all
respond_to do |wants|
wants.html # index.html.erb
wants.xml { render :xml => @${1/./\l$0/}s }
end
end
respond_to do |wants|
wants.html # index.html.erb
wants.xml { render :xml => @${1/./\l$0/}s }
end
end
# GET /${1/./\l$0/}s/1
# GET /${1/./\l$0/}s/1.xml
def show
respond_to do |wants|
wants.html # show.html.erb
wants.xml { render :xml => @${1/./\l$0/} }
end
end
# GET /${1/./\l$0/}s/1
# GET /${1/./\l$0/}s/1.xml
def show
respond_to do |wants|
wants.html # show.html.erb
wants.xml { render :xml => @${1/./\l$0/} }
end
end
# GET /${1/./\l$0/}s/new
# GET /${1/./\l$0/}s/new.xml
def new
@${1/./\l$0/} = ${1:Model}.new
# GET /${1/./\l$0/}s/new
# GET /${1/./\l$0/}s/new.xml
def new
@${1/./\l$0/} = ${1:Model}.new
respond_to do |wants|
wants.html # new.html.erb
wants.xml { render :xml => @${1/./\l$0/} }
end
end
respond_to do |wants|
wants.html # new.html.erb
wants.xml { render :xml => @${1/./\l$0/} }
end
end
# GET /${1/./\l$0/}s/1/edit
def edit
end
# GET /${1/./\l$0/}s/1/edit
def edit
end
# POST /${1/./\l$0/}s
# POST /${1/./\l$0/}s.xml
def create
@${1/./\l$0/} = ${1:Model}.new(params[:${1/./\l$0/}])
# POST /${1/./\l$0/}s
# POST /${1/./\l$0/}s.xml
def create
@${1/./\l$0/} = ${1:Model}.new(params[:${1/./\l$0/}])
respond_to do |wants|
if @${1/./\l$0/}.save
flash[:notice] = '${1:Model} was successfully created.'
wants.html { redirect_to(@${1/./\l$0/}) }
wants.xml { render :xml => @${1/./\l$0/}, :status => :created, :location => @${1/./\l$0/} }
else
wants.html { render :action => "new" }
wants.xml { render :xml => @${1/./\l$0/}.errors, :status => :unprocessable_entity }
end
end
end
respond_to do |wants|
if @${1/./\l$0/}.save
flash[:notice] = '${1:Model} was successfully created.'
wants.html { redirect_to(@${1/./\l$0/}) }
wants.xml { render :xml => @${1/./\l$0/}, :status => :created, :location => @${1/./\l$0/} }
else
wants.html { render :action => "new" }
wants.xml { render :xml => @${1/./\l$0/}.errors, :status => :unprocessable_entity }
end
end
end
# PUT /${1/./\l$0/}s/1
# PUT /${1/./\l$0/}s/1.xml
def update
respond_to do |wants|
if @${1/./\l$0/}.update_attributes(params[:${1/./\l$0/}])
flash[:notice] = '${1:Model} was successfully updated.'
wants.html { redirect_to(@${1/./\l$0/}) }
wants.xml { head :ok }
else
wants.html { render :action => "edit" }
wants.xml { render :xml => @${1/./\l$0/}.errors, :status => :unprocessable_entity }
end
end
end
# PUT /${1/./\l$0/}s/1
# PUT /${1/./\l$0/}s/1.xml
def update
respond_to do |wants|
if @${1/./\l$0/}.update_attributes(params[:${1/./\l$0/}])
flash[:notice] = '${1:Model} was successfully updated.'
wants.html { redirect_to(@${1/./\l$0/}) }
wants.xml { head :ok }
else
wants.html { render :action => "edit" }
wants.xml { render :xml => @${1/./\l$0/}.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /${1/./\l$0/}s/1
# DELETE /${1/./\l$0/}s/1.xml
def destroy
@${1/./\l$0/}.destroy
# DELETE /${1/./\l$0/}s/1
# DELETE /${1/./\l$0/}s/1.xml
def destroy
@${1/./\l$0/}.destroy
respond_to do |wants|
wants.html { redirect_to(${1/./\l$0/}s_url) }
wants.xml { head :ok }
end
end
respond_to do |wants|
wants.html { redirect_to(${1/./\l$0/}s_url) }
wants.xml { head :ok }
end
end
private
def find_${1/./\l$0/}
@${1/./\l$0/} = ${1:Model}.find(params[:id])
end
private
def find_${1/./\l$0/}
@${1/./\l$0/} = ${1:Model}.find(params[:id])
end
end
@ -227,31 +225,31 @@ assert_response :${1:success}, @response.body$0
endsnippet
snippet aftc "after_create"
after_create
after_create $0
endsnippet
snippet aftd "after_destroy"
after_destroy
after_destroy $0
endsnippet
snippet afts "after_save"
after_save
after_save $0
endsnippet
snippet aftu "after_update"
after_update
after_update $0
endsnippet
snippet aftv "after_validation"
after_validation
after_validation $0
endsnippet
snippet aftvoc "after_validation_on_create"
after_validation_on_create
after_validation_on_create $0
endsnippet
snippet aftvou "after_validation_on_update"
after_validation_on_update
after_validation_on_update $0
endsnippet
snippet asg "assert(var = assigns(:var))"
@ -261,13 +259,13 @@ endsnippet
snippet asd "assert_difference"
assert_difference "${1:Model}.${2:count}", ${3:1} do
$0
$0
end
endsnippet
snippet asnd "assert_no_difference"
assert_no_difference "${1:Model}.${2:count}" do
$0
$0
end
endsnippet
@ -298,27 +296,27 @@ end}
endsnippet
snippet befc "before_create"
before_create
before_create $0
endsnippet
snippet befd "before_destroy"
before_destroy
before_destroy $0
endsnippet
snippet befs "before_save"
before_save
before_save $0
endsnippet
snippet befu "before_update"
before_update
before_update $0
endsnippet
snippet befv "before_validation"
before_validation
before_validation $0
endsnippet
snippet befvoc "before_validation_on_create"
before_validation_on_create
before_validation_on_create $0
endsnippet
snippet befvou "before_validation_on_update"
@ -456,13 +454,13 @@ endsnippet
snippet mapr "map.resource"
${1:map}.resource :${2:resource}${10: do |${11:$2}|
$0
$0
end}
endsnippet
snippet maprs "map.resources"
${1:map}.resources :${2:resource}${10: do |${11:$2}|
$0
$0
end}
endsnippet
@ -605,7 +603,7 @@ endsnippet
snippet resw "respond_with"
respond_with(${1:@${2:model}})${3: do |format|
format.${4:html} { $0 \}
format.${4:html} { $0 \}
end}
endsnippet
@ -807,32 +805,32 @@ endsnippet
snippet sweeper "Create sweeper class"
class ${1:Model}Sweeper < ActionController::Caching::Sweeper
observe ${1:Model}
observe ${1:Model}
def after_save(${1/./\l$0/})
expire_cache(${1/./\l$0/})
end
def after_save(${1/./\l$0/})
expire_cache(${1/./\l$0/})
end
def after_destroy(${1/./\l$0/})
expire_cache(${1/./\l$0/})
end
def after_destroy(${1/./\l$0/})
expire_cache(${1/./\l$0/})
end
private
private
def expire_cache(${1/./\l$0/})
${0:expire_page ${1/./\l$0/}s_path
expire_page ${1/./\l$0/}_path(${1/./\l$0/})}
end
def expire_cache(${1/./\l$0/})
${0:expire_page ${1/./\l$0/}s_path
expire_page ${1/./\l$0/}_path(${1/./\l$0/})}
end
end
endsnippet
snippet col "collection routes"
collection do
${1:get :${2:action}}
${3:put :${4:action}}
${5:post :${6:action}}
${7:delete :${8:action}}
${1:get :${2:action}}
${3:put :${4:action}}
${5:post :${6:action}}
${7:delete :${8:action}}
end
endsnippet
@ -854,16 +852,16 @@ endsnippet
snippet member "member routes"
member do
${1:get :${2:action}}
${3:put :${4:action}}
${5:post :${6:action}}
${7:delete :${8:action}}
${1:get :${2:action}}
${3:put :${4:action}}
${5:post :${6:action}}
${7:delete :${8:action}}
end
endsnippet
snippet res "resources"
resources :${1:posts}${2: do
$3
$3
end}
endsnippet
@ -877,9 +875,9 @@ endsnippet
snippet scopee "scope with extension"
scope :${1:name}, ${2:where(${3::${4:field} => ${5:'${6:value}'}})} do
def ${7:method_name}
$0
end
def ${7:method_name}
$0
end
end
endsnippet
@ -899,7 +897,7 @@ endsnippet
snippet route_spec
it 'routes to #${1:action}' do
${2:get}('/${3:url}').should route_to('`!v substitute(expand('%:t:r'), '_routing_spec$', '', '')`#$1'${4:, ${5:params}})${6}
${2:get}('/${3:url}').should route_to('`!v substitute(expand('%:t:r'), '_routing_spec$', '', '')`#$1'${4:, ${5:params}})${6}
end
endsnippet

View File

@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-
priority -50
###########################################################################
# General Stuff #
# General Stuff #
###########################################################################
global !p
import vim
@ -12,25 +14,25 @@ from collections import Counter
#http://docutils.sourceforge.net/docs/ref/rst/roles.html
TEXT_ROLES = ['emphasis','literal','code','math',
'pep-reference','rfc-reference',
'strong','subscript','superscript',
'title-reference','raw']
'pep-reference','rfc-reference',
'strong','subscript','superscript',
'title-reference','raw']
TEXT_ROLES_REGEX = r'\.\.\srole::?\s(w+)'
#http://docutils.sourceforge.net/docs/ref/rst/directives.html#specific-admonitions
SPECIFIC_ADMONITIONS = ["attention", "caution", "danger",
"error", "hint", "important", "note",
"tip", "warning"]
"error", "hint", "important", "note",
"tip", "warning"]
#http://docutils.sourceforge.net/docs/ref/rst/directives.html
DIRECTIVES = ['topic','sidebar','math','epigraph',
'parsed-literal','code','highlights',
'pull-quote','compound','container',
'list-table','class','sectnum',
'role','default-role','unicode',
'raw']
'parsed-literal','code','highlights',
'pull-quote','compound','container',
'list-table','class','sectnum',
'role','default-role','unicode',
'raw']
NONE_CONTENT_DIRECTIVES = ['rubric', 'contents', 'header',
'footer', 'date', 'include', 'title']
'footer', 'date', 'include', 'title']
INCLUDABLE_DIRECTIVES = ['image', 'figure', 'include']
# CJK chars
@ -39,115 +41,115 @@ CJK_RE = re.compile(u'[⺀-⺙⺛-⻳⼀-⿕々〇〡-〩〸-〺〻㐀-䶵一-
def has_cjk(char):
"""
Detect char contains CJK character
"""
Detect char contains CJK character
:param char: characters needs to be detect
"""
try:
CJK_RE.finditer(char).next()
except StopIteration:
return False
else:
return True
:param char: characters needs to be detect
"""
try:
CJK_RE.finditer(char).next()
except StopIteration:
return False
else:
return True
def real_filename(filename):
"""peal extension name off if possible
# i.e. "foo.bar.png will return "foo.bar"
"""pealeextension name off if possible
# i.e. "foo.bar.png will return "foo.bar"
"""
return ospath.splitext(filename)[0]
return ospath.splitext(filename)[0]
def check_file_exist(rst_path, relative_path):
"""
For RST file, it can just include files as relative path.
"""
For RST file, it can just include files as relative path.
:param rst_path: absolute path to rst file
:param relative_path: path related to rst file
:return: relative file's absolute path if file exist
"""
abs_path = ospath.join(ospath.dirname(rst_path), relative_path)
if ospath.isfile(abs_path):
return abs_path
:param rst_path: absolute path to rst file
:param relative_path: path related to rst file
:return: relative file's absolute path if file exist
"""
abs_path = ospath.join(ospath.dirname(rst_path), relative_path)
if ospath.isfile(abs_path):
return abs_path
def rst_char_len(char):
"""
return len of string which fit in rst
For instance:chinese "我" decode as only one character,
However, the rst interpreter needs 2 "=" instead of 1.
"""
return len of string which fit in rst
For instance:chinese "我" decode as only one character,
However, the rst interpreter needs 2 "=" instead of 1.
:param: char needs to be count
"""
return len(re.findall(r'[^\u4e00-\u9fff\s]', char))+len(char)
:param: char needs to be count
"""
return len(re.findall(r'[^\u4e00-\u9fff\s]', char))+len(char)
def make_items(times, leading='+'):
"""
make lines with leading char multitimes
"""
make lines with leading char multitimes
:param: times, how many times you need
:param: leading, leading character
"""
times = int(times)
if leading == 1:
msg = ""
for x in xrange(1, times+1):
msg += "%s. Item\n" % x
return msg
else:
return ("%s Item\n" % leading) * times
:param: times, how many times you need
:param: leading, leading character
"""
times = int(times)
if leading == 1:
msg = ""
for x in xrange(1, times+1):
msg += "%s. Item\n" % x
return msg
else:
return ("%s Item\n" % leading) * times
def look_up_directives(regex, fpath):
"""
find all directive args in given file
:param: regex, the regex that needs to match
:param: path, to path to rst file
"""
find all directive args in given file
:param: regex, the regex that needs to match
:param: path, to path to rst file
:return: list, empty list if nothing match
"""
try:
with open(fpath) as source:
match = re.findall(regex, source.read())
except IOError:
match = []
return match
:return: list, empty list if nothing match
"""
try:
with open(fpath) as source:
match = re.findall(regex, source.read())
except IOError:
match = []
return match
def get_popular_code_type():
"""
find most popular code type in the given rst
"""
find most popular code type in the given rst
:param path: file to detect
:param path: file to detect
:return: string, most popular code type in file
"""
buf = "".join(vim.current.buffer)
types = re.findall(r'[:|\.\.\s]code::?\s(\w+)', buf)
try:
popular_type = Counter(types).most_common()[0][0]
except IndexError:
popular_type = "lua" # Don't break default
return popular_type
:return: string, most popular code type in file
"""
buf = "".join(vim.current.buffer)
types = re.findall(r'[:|\.\.\s]code::?\s(\w+)', buf)
try:
popular_type = Counter(types).most_common()[0][0]
except IndexError:
popular_type = "lua" # Don't break default
return popular_type
def complete(t, opts):
"""
get options that start with t
"""
get options that start with t
:param t: query string
:param opts: list that needs to be completed
:param t: query string
:param opts: list that needs to be completed
:return: a string that start with t
"""
msg = "({0})"
if t:
opts = [ m[len(t):] for m in opts if m.startswith(t) ]
if len(opts) == 1:
return opts[0]
:return: a string that start with t
"""
msg = "({0})"
if t:
opts = [ m[len(t):] for m in opts if m.startswith(t) ]
if len(opts) == 1:
return opts[0]
if not len(opts):
msg = "{0}"
return msg.format("|".join(opts))
if not len(opts):
msg = "{0}"
return msg.format("|".join(opts))
endglobal
@ -199,22 +201,22 @@ snippet em "Emphasize string" i
`!p
# dirty but works with CJK charactor detection
if has_cjk(vim.current.line):
snip.rv ="\ "`*${1:${VISUAL:Em}}*`!p
snip.rv ="\ "`*${1:${VISUAL:Em}}*`!p
if has_cjk(vim.current.line):
snip.rv ="\ "
snip.rv ="\ "
else:
snip.rv = " "
snip.rv = " "
`$0
endsnippet
snippet st "Strong string" i
`!p
if has_cjk(vim.current.line):
snip.rv ="\ "`**${1:${VISUAL:Strong}}**`!p
snip.rv ="\ "`**${1:${VISUAL:Strong}}**`!p
if has_cjk(vim.current.line):
snip.rv ="\ "
snip.rv ="\ "
else:
snip.rv = " "
snip.rv = " "
`$0
endsnippet
@ -236,12 +238,12 @@ snip.rv = make_items(match.groupdict()['num'], 1)
`
endsnippet
###########################################################################
# More Specialized Stuff. #
# More Specialized Stuff. #
###########################################################################
snippet cb "Code Block" b
.. code-block:: ${1:`!p snip.rv = get_popular_code_type()`}
${2:code}
${2:code}
$0
endsnippet
@ -257,28 +259,28 @@ link=""
content=""
if di == 'im':
link = "|{0}|".format(real_name)
link = "|{0}|".format(real_name)
if di == 'fi':
content="""
:alt: {0}
{0}""".format(real_name)
content="""
:alt: {0}
{0}""".format(real_name)
`
..`!p snip.rv = " %s" % link if link else ""` $1`!p snip.rv=complete(t[1], INCLUDABLE_DIRECTIVES)`:: ${2:file}`!p if content:
snip.rv +=" "+content`
snip.rv +=" "+content`
`!p
# Tip of whether file is exist in comment type
if not check_file_exist(path, t[2]):
snip.rv='.. FILE {0} does not exist'.format(t[2])
snip.rv='.. FILE {0} does not exist'.format(t[2])
else:
snip.rv=""
snip.rv=""
`$0
endsnippet
snippet di "Directives" b
.. $1`!p snip.rv=complete(t[1], DIRECTIVES)`:: $2
${3:Content}
${3:Content}
$0
endsnippet
@ -290,7 +292,7 @@ endsnippet
snippet sa "Specific Admonitions" b
.. $1`!p snip.rv =complete(t[1], SPECIFIC_ADMONITIONS)`::
${2:Content}
${2:Content}
$0
endsnippet
@ -298,8 +300,8 @@ endsnippet
#it will be trigger at start of line or after a word
snippet ro "Text Roles" w
\ :$1`!p snip.rv=complete(t[1],
TEXT_ROLES+look_up_directives(TEXT_ROLES_REGEX,
path))`:\`$2\`\
TEXT_ROLES+look_up_directives(TEXT_ROLES_REGEX,
path))`:\`$2\`\
endsnippet
############
@ -309,6 +311,6 @@ endsnippet
snippet sid "SideBar" b
.. sidebar:: ${1:SideBar Title}
${2:SideBar Content}
${2:SideBar Content}
endsnippet
# vim:ft=snippets:

View File

@ -1,3 +1,5 @@
priority -50
snippet "^#!" "#!/usr/bin/env ruby" r
#!/usr/bin/env ruby
$0
@ -25,7 +27,7 @@ endsnippet
snippet if "if <condition> ... end"
if ${1:condition}
${2}
${2:# TODO}
end
endsnippet
@ -33,9 +35,9 @@ endsnippet
snippet ife "if <condition> ... else ... end"
if ${1:condition}
${2}
${2:# TODO}
else
${3}
${3:# TODO}
end
endsnippet
@ -43,11 +45,11 @@ endsnippet
snippet ifee "if <condition> ... elseif <condition> ... else ... end"
if ${1:condition}
${2}
${2:# TODO}
elsif ${3:condition}
${4}
${4:# TODO}
else
${0}
${0:# TODO}
end
endsnippet
@ -55,7 +57,7 @@ endsnippet
snippet unless "unless <condition> ... end"
unless ${1:condition}
${0}
${0:# TODO}
end
endsnippet
@ -63,9 +65,9 @@ endsnippet
snippet unlesse "unless <condition> ... else ... end"
unless ${1:condition}
${2}
${2:# TODO}
else
${0}
${0:# TODO}
end
endsnippet
@ -73,11 +75,11 @@ endsnippet
snippet unlesee "unless <condition> ... elseif <condition> ... else ... end"
unless ${1:condition}
${2}
${2:# TODO}
elsif ${3:condition}
${4}
${4:# TODO}
else
${0}
${0:# TODO}
end
endsnippet
@ -85,7 +87,7 @@ endsnippet
snippet "\b(de)?f" "def <name>..." r
def ${1:function_name}${2: ${3:*args}}
${0}
${0:# TODO}
end
endsnippet
@ -93,7 +95,7 @@ endsnippet
snippet defi "def initialize ..."
def initialize${1: ${2:*args}}
${0}
${0:# TODO}
end
endsnippet
@ -101,23 +103,23 @@ endsnippet
snippet defr "def <name> ... rescue ..."
def ${1:function_name}${2: ${3:*args}}
${4}
${4:# TODO}
rescue
${0}
${0:# TODO}
end
endsnippet
snippet For "(<from>..<to>).each { |<i>| <block> }"
(${1:from}..${2:to}).each { |${3:i}| ${4} }
(${1:from}..${2:to}).each { |${3:i}| ${4:# TODO} }
endsnippet
snippet for "(<from>..<to>).each do |<i>| <block> end"
(${1:from}..${2:to}).each do |${3:i}|
${0}
${0:# TODO}
end
endsnippet
@ -138,42 +140,42 @@ endsnippet
snippet "(\S+)\.Del(ete)?_?if" ".delete_if { |<key>,<value>| <block> }" r
`!p snip.rv=match.group(1)`.delete_if { |${1:key},${2:value}| ${3} }
`!p snip.rv=match.group(1)`.delete_if { |${1:key},${2:value}| ${3:# TODO} }
endsnippet
snippet "(\S+)\.del(ete)?_?if" ".delete_if do |<key>,<value>| <block> end" r
`!p snip.rv=match.group(1)`.delete_if do |${1:key},${2:value}|
${0}
${0:# TODO}
end
endsnippet
snippet "(\S+)\.Keep_?if" ".keep_if { |<key>,<value>| <block> }" r
`!p snip.rv=match.group(1)`.keep_if { |${1:key},${2:value}| ${3} }
`!p snip.rv=match.group(1)`.keep_if { |${1:key},${2:value}| ${3:# TODO} }
endsnippet
snippet "(\S+)\.keep_?if" ".keep_if do <key>,<value>| <block> end" r
`!p snip.rv=match.group(1)`.keep_if do |${1:key},${2:value}|
${0}
${0:# TODO}
end
endsnippet
snippet "(\S+)\.Reject" ".reject { |<key>,<value>| <block> }" r
`!p snip.rv=match.group(1)`.reject { |${1:key},${2:value}| ${3} }
`!p snip.rv=match.group(1)`.reject { |${1:key},${2:value}| ${3:# TODO} }
endsnippet
snippet "(\S+)\.reject" ".reject do <key>,<value>| <block> end" r
`!p snip.rv=match.group(1)`.reject do |${1:key},${2:value}|
${0}
${0:# TODO}
end
endsnippet
@ -194,71 +196,71 @@ endsnippet
snippet "(\S+)\.Sort" ".sort { |<a>,<b>| <block> }" r
`!p snip.rv=match.group(1)`.sort { |${1:a},${2:b}| ${3} }
`!p snip.rv=match.group(1)`.sort { |${1:a},${2:b}| ${3:# TODO} }
endsnippet
snippet "(\S+)\.sort" ".sort do |<a>,<b>| <block> end" r
`!p snip.rv=match.group(1)`.sort do |${1:a},${2:b}|
${0}
${0:# TODO}
end
endsnippet
snippet "(\S+)\.Each_?k(ey)?" ".each_key { |<key>| <block> }" r
`!p snip.rv=match.group(1)`.each_key { |${1:key}| ${2} }
`!p snip.rv=match.group(1)`.each_key { |${1:key}| ${2:# TODO} }
endsnippet
snippet "(\S+)\.each_?k(ey)?" ".each_key do |key| <block> end" r
`!p snip.rv=match.group(1)`.each_key do |${1:key}|
${0}
${0:# TODO}
end
endsnippet
snippet "(\S+)\.Each_?val(ue)?" ".each_value { |<value>| <block> }" r
`!p snip.rv=match.group(1)`.each_value { |${1:value}| ${2} }
`!p snip.rv=match.group(1)`.each_value { |${1:value}| ${2:# TODO} }
endsnippet
snippet "(\S+)\.each_?val(ue)?" ".each_value do |<value>| <block> end" r
`!p snip.rv=match.group(1)`.each_value do |${1:value}|
${0}
${0:# TODO}
end
endsnippet
snippet Each "<elements>.each { |<element>| <block> }"
${1:elements}.each { |${2:${1/s$//}}| ${3} }
${1:elements}.each { |${2:${1/s$//}}| ${3:# TODO} }
endsnippet
snippet each "<elements>.each do |<element>| <block> end"
${1:elements}.each do |${2:${1/s$//}}|
${0}
${0:# TODO}
end
endsnippet
snippet each_?s(lice)? "<array>.each_slice(n) do |slice| <block> end"
each_slice(${1:2}) do |${2:slice}|
${0}
snippet "each_?s(lice)?" "<array>.each_slice(n) do |slice| <block> end" r
${1:elements}.each_slice(${2:2}) do |${3:slice}|
${0:# TODO}
end
endsnippet
snippet Each_?s(lice)? "<array>.each_slice(n) { |slice| <block> }"
each_slice(${1:2}) { |${2:slice}| ${3} }
snippet "Each_?s(lice)?" "<array>.each_slice(n) { |slice| <block> }" r
${1:elements}.each_slice(${2:2}) { |${3:slice}| ${0:# TODO} }
endsnippet
@ -273,7 +275,7 @@ try:
snip.rv = wmatch.group(1).lower()
except:
snip.rv = 'element'
`}| ${2} }
`}| ${2:# TODO} }
endsnippet
@ -288,7 +290,7 @@ try:
except:
snip.rv = 'element'
`}|
${0}
${0:# TODO}
end
endsnippet
@ -303,7 +305,7 @@ try:
snip.rv = wmatch.group(1).lower()
except:
snip.rv = 'element'
`}| ${2} }
`}| ${2:# TODO} }
endsnippet
@ -318,7 +320,7 @@ try:
except:
snip.rv = 'element'
`}|
${0}
${0:# TODO}
end
endsnippet
@ -333,7 +335,7 @@ try:
snip.rv = wmatch.group(1).lower()
except:
snip.rv = 'element'
`}| ${2} }
`}| ${2:# TODO} }
endsnippet
@ -348,14 +350,14 @@ try:
except:
snip.rv = 'element'
`}|
${0}
${0:# TODO}
end
endsnippet
snippet "(\S+)\.Each_w(ith)?_?i(ndex)?" ".each_with_index { |<element>,<i>| <block> }" r
snippet "(\S+)\.Each_?w(ith)?_?i(ndex)?" ".each_with_index { |<element>,<i>| <block> }" r
`!p snip.rv=match.group(1)`.each_with_index { |${1:`!p
element_name = match.group(1).lstrip('$@')
ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name)
@ -364,7 +366,7 @@ try:
snip.rv = wmatch.group(1).lower()
except:
snip.rv = 'element'
`},${2:i}| ${3} }$0
`},${2:i}| ${3:# TODO} }$0
endsnippet
@ -379,7 +381,7 @@ try:
except:
snip.rv = 'element'
`},${2:i}|
${0}
${0:# TODO}
end
endsnippet
@ -387,14 +389,14 @@ endsnippet
snippet "(\S+)\.Each_?p(air)?" ".each_pair { |<key>,<value>| <block> }" r
`!p snip.rv=match.group(1)`.each_pair { |${1:key},${2:value}| ${3} }
`!p snip.rv=match.group(1)`.each_pair { |${1:key},${2:value}| ${3:# TODO} }
endsnippet
snippet "(\S+)\.each_?p(air)?" ".each_pair do |<key>,<value>| <block> end" r
`!p snip.rv=match.group(1)`.each_pair do |${1:key},${2:value}|
${0}
${0:# TODO}
end
endsnippet
@ -424,24 +426,26 @@ snippet "(\S+)\.Index" ".index do |item| ... end" r
end
endsnippet
# comments about do and dov see snippets/ruby.snippets
snippet do "do ... end" i
snippet do "do |<key>| ... end" i
do |${1:args}|
$0
end
endsnippet
snippet Do "do ... end" i
do
$0
end
endsnippet
snippet dov "do |<key>| ... end" i
do |${1:v}|
$2
end
endsnippet
snippet until "until <expression> ... end"
until ${1:expression}
${0}
${0:# TODO}
end
endsnippet
@ -449,15 +453,15 @@ endsnippet
snippet Until "begin ... end until <expression>"
begin
${0}
${0:# TODO}
end until ${1:expression}
endsnippet
snippet wh "while <expression> ... end"
snippet while "while <expression> ... end"
while ${1:expression}
${0}
${0:# TODO}
end
endsnippet
@ -465,7 +469,7 @@ endsnippet
snippet While "begin ... end while <expression>"
begin
${0}
${0:# TODO}
end while ${1:expression}
endsnippet
@ -491,9 +495,9 @@ endsnippet
snippet begin "begin ... rescue ... end"
begin
${1}
${1:# TODO}
rescue
${0}
${0:# TODO}
end
endsnippet
@ -559,7 +563,7 @@ endsnippet
snippet ###
=begin
$0
$0
=end
endsnippet

55
UltiSnips/scss.snippets Normal file
View File

@ -0,0 +1,55 @@
priority -50
snippet /@?imp/ "@import '...';" br
@import '${1:file}';
endsnippet
snippet /@?inc/ "@include mixin(...);" br
@include ${1:mixin}(${2:arguments});
endsnippet
snippet /@?ext?/ "@extend %placeholder;" br
@extend %${1:placeholder};
endsnippet
snippet /@?mixin/ "@mixin (...) { ... }" br
@mixin ${1:name}(${2:arguments}) {
${VISUAL}$0
}
endsnippet
snippet /@?fun/ "@function (...) { ... }" br
@function ${1:name}(${2:arguments}) {
${VISUAL}$0
}
endsnippet
snippet /@?if/ "@if (...) { ... }" br
@if ${1:condition} {
${VISUAL}$0
}
endsnippet
snippet /(} )?@?else/ "@else { ... }" br
@else ${1:condition} {
${VISUAL}$0
}
endsnippet
snippet /@?for/ "@for loop" br
@for ${1:$i} from ${2:1} through ${3:3} {
${VISUAL}$0
}
endsnippet
snippet /@?each/ "@each loop" br
@each ${1:$item} in ${2:item, item, item} {
${VISUAL}$0
}
endsnippet
snippet /@?while/ "@while loop" br
@while ${1:$i} ${2:>} ${3:0} {
${VISUAL}$0
}
endsnippet

View File

@ -1,21 +1,25 @@
priority -50
global !p
import vim
# Tests for the existence of a variable declared by Vim's filetype detection
# suggesting the type of shell script of the current file
def testShell(scope, shell):
return vim.eval("exists('" + scope + ":is_" + shell + "')")
return vim.eval("exists('" + scope + ":is_" + shell + "')")
# Loops over the possible variables, checking for global variables
# first since they indicate an override by the user.
def getShell():
for scope in ["g", "b"]:
for shell in ["bash", "sh", "kornshell"]:
if testShell(scope, shell) == "1":
if shell == "kornshell":
return "ksh"
return shell
return "sh"
for scope in ["g", "b"]:
for shell in ["bash", "posix", "sh", "kornshell"]:
if testShell(scope, shell) == "1":
if shell == "kornshell":
return "ksh"
if shell == "posix":
return "sh"
return shell
return "sh"
endglobal
###########################################################################
@ -79,7 +83,7 @@ until ${2:[[ ${1:condition} ]]}; do
done
endsnippet
snippet wh "while ... (done)"
snippet while "while ... (done)"
while ${2:[[ ${1:condition} ]]}; do
${0:#statements}
done

View File

@ -1,16 +1,14 @@
#########################
# SNIPPETS for SNIPPETS #
#########################
priority -50
# We use a little hack so that the snippet is expanded
# and parsed correctly
snippet snip "Snippet definition" !
`!p snip.rv = "snippet"` ${1:Tab_trigger} "${2:Description}" ${3:!b}
snippet snip "Snippet definition" b
`!p snip.rv = "snippet"` ${1:Tab_trigger} "${2:Description}" ${3:b}
$0
`!p snip.rv = "endsnippet"`
endsnippet
snippet global "Global snippet" !
snippet global "Global snippet" b
`!p snip.rv = "global"` !p
$0
`!p snip.rv = "endglobal"`

View File

@ -1,3 +1,5 @@
priority -50
###########################################################################
# TEXTMATE SNIPPETS #
###########################################################################
@ -16,14 +18,14 @@ foreach ${1:var} ${2:\$list} {
endsnippet
snippet if "if... (if)" b
if {${1}} {
if {${1:condition}} {
${2}
}
endsnippet
snippet proc "proc... (proc)" b
proc ${1} {${2}} \
proc ${1:name} {${2:args}} \
{
${3}
}
@ -40,8 +42,8 @@ switch ${1:-exact} -- ${2:\$var} {
endsnippet
snippet wh "while... (while)" b
while {${1}} {
snippet while "while... (while)" b
while {${1:condition}} {
${2}
}

View File

@ -1,38 +1,28 @@
priority -50
###########################################################################
# LATEX SNIPPETS #
###########################################################################
extends texmath
snippet r "\ref{}" w
\ref{$1}
endsnippet
###########################################################################
# TEXTMATE SNIPPETS #
###########################################################################
#################
# GENERAL STUFF #
#################
snippet "b(egin)?" "begin{} / end{}" br
\begin{${1:something}}
${0:${VISUAL}}
\end{$1}
endsnippet
####################
# TABULARS, ARRAYS #
####################
snippet tab
\begin{${1:t}${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}{${2:c}}
$0${2/((?<=.)c|l|r)|./(?1: & )/g}
\end{$1${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}
endsnippet
########################
# ENUM, DESCR, ITEMIZE #
########################
snippet fig "Figure environment" b
\begin{figure}${2:[htpb]}
\centering
\includegraphics[width=${3:0.8}\linewidth]{${4:name.ext}}
\caption{${4/(\w+)\.\w+/\u$1/}$0}
\label{fig:${4/(\w+)\.\w+/$1/}}
\end{figure}
endsnippet
snippet enum "Enumerate" b
\begin{enumerate}
\item $0
@ -51,74 +41,70 @@ snippet desc "Description" b
\end{description}
endsnippet
#####################################
# SECTIONS, CHAPTERS AND THERE LIKE #
#####################################
snippet it "Individual item" b
\item ${1}
$0
endsnippet
snippet part "Part" b
\part{${1:part name}}
\label{prt:${2:${1/(\w+)|\W+/(?1:\L$0\E:_)/g}}}
\label{prt:${2:${1/(\w+)|\W+/(?1:\L$0\E:_)/ga}}}
${0}
% part $2 (end)
endsnippet
snippet cha "Chapter" b
\chapter{${1:chapter name}}
\label{cha:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/g}}}
\label{cha:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
${0}
% chapter $2 (end)
endsnippet
snippet sec "Section" b
\section{${1:section name}}
\label{sec:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/g}}}
\label{sec:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
${0}
% section $2 (end)
endsnippet
snippet sub "Subsection" b
\subsection{${1:subsection name}}
\label{sub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/g}}}
\label{sub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
${0}
% subsection $2 (end)
endsnippet
snippet ssub "Subsubsection" b
\subsubsection{${1:subsubsection name}}
\label{ssub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/g}}}
\label{ssub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
${0}
% subsubsection $2 (end)
endsnippet
snippet par "Paragraph" b
\paragraph{${1:paragraph name}}
\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/g}}}
\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
${0}
% paragraph $2 (end)
endsnippet
snippet subp "Subparagraph" b
\subparagraph{${1:subparagraph name}}
\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/g}}}
\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}}
${0}
% subparagraph $2 (end)
endsnippet
snippet ni "Non-indented paragraph" b
\noindent
${0}
endsnippet
snippet pac "Package" b
\usepackage[${1:options}]{${2:package}}$0
endsnippet
snippet lp "Long parenthesis"
\left(${1:${VISUAL:contents}}\right)$0
endsnippet
# vim:ft=snippets:

View File

@ -1,3 +1,5 @@
priority -50
##############
# MATH STUFF #
##############

View File

@ -1,3 +1,5 @@
priority -50
snippet bl "twig block" b
{% block ${1} %}
${2}

View File

@ -1,3 +1,5 @@
priority -50
###########################################################################
# SnipMate Snippets #
###########################################################################
@ -25,30 +27,30 @@ endsnippet
snippet f
fun ${1:function_name}(${2})
${3}
${3:" code}
endf
endsnippet
snippet for
for ${1} in ${2}
${3}
for ${1:needle} in ${2:haystack}
${3:" code}
endfor
endsnippet
snippet wh
while ${1}
${2}
while ${1:condition}
${2:" code}
endw
endsnippet
snippet if
if ${1}
${2}
if ${1:condition}
${2:" code}
endif
endsnippet
snippet ife
if ${1}
if ${1:condition}
${2}
else
${3}

View File

@ -0,0 +1,3 @@
priority -50
extends html

View File

@ -1,3 +1,10 @@
priority -50
snippet xml "XML declaration" b
<?xml version="1.0"?>
endsnippet
snippet t "Simple tag" b
<${1:tag}>
${2:content}

View File

@ -1,9 +1,15 @@
snippet #! "shebang" !
priority -50
extends sh
priority -49
snippet #! "shebang" b
#!/bin/zsh
endsnippet
snippet !env "#!/usr/bin/env (!env)" !
snippet !env "#!/usr/bin/env (!env)" b
#!/usr/bin/env zsh
endsnippet