diff --git a/UltiSnips/html_minimal.snippets b/UltiSnips/html_minimal.snippets
index 1f77ad7b9..48ff4b723 100644
--- a/UltiSnips/html_minimal.snippets
+++ b/UltiSnips/html_minimal.snippets
@@ -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
diff --git a/UltiSnips/htmldjango.snippets b/UltiSnips/htmldjango.snippets
index 9df5f7884..5836a2f69 100644
--- a/UltiSnips/htmldjango.snippets
+++ b/UltiSnips/htmldjango.snippets
@@ -1 +1,3 @@
+priority -50
+
extends html, django
diff --git a/UltiSnips/htmljinja.snippets b/UltiSnips/htmljinja.snippets
new file mode 100644
index 000000000..fa3b3c22a
--- /dev/null
+++ b/UltiSnips/htmljinja.snippets
@@ -0,0 +1,3 @@
+priority -50
+
+extends html, jinja2
diff --git a/UltiSnips/java.snippets b/UltiSnips/java.snippets
index 617c16166..02b95e1e2 100644
--- a/UltiSnips/java.snippets
+++ b/UltiSnips/java.snippets
@@ -1,25 +1,78 @@
-###########################################################################
-# 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):
+ if not word: return ''
+ return word[0].upper() + word[1:]
+
+def mixedCase(word):
+ if not word: return ''
+ return word[0].lower() + 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
+assert ${1:test}${2/(.+)/(?1: \: ")/}${2:Failure message}${2/(.+)/(?1:")/};
+endsnippet
+
+snippet at "assert true" b
+assertTrue(${1:actual});
+endsnippet
+
+snippet af "assert false" b
+assertFalse(${1:actual});
+endsnippet
+
+snippet ae "assert equals" b
+assertEquals(${1:expected}, ${2:actual});
endsnippet
snippet br "break"
@@ -39,19 +92,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.%s = %s;" % (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,20 +178,20 @@ default:
$0
endsnippet
-snippet eif "else if" b
+snippet elif "else if"
else if ($1)`!p nl(snip)`{
$0
}
endsnippet
-snippet /el(se)?/ "else" br
+snippet /el(se)?/ "else" r
else`!p nl(snip)`{
$0
}
endsnippet
snippet fi "final" b
-final
+final $0
endsnippet
snippet fore "for (each)" b
@@ -81,6 +200,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 +224,7 @@ $0
endsnippet
snippet im "import" b
-import
+import ${1:java}.${2:util}.$0;
endsnippet
snippet in "interface" b
@@ -108,6 +233,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.%s = %s;" % (i[1], i[1])
+if len(args) == 0:
+ snip.rv += "\n"`
+}
+endsnippet
+
snippet j.b "java_beans_" i
java.beans.
endsnippet
@@ -134,15 +301,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 = mixedCase(t[2])`;
+}
+endsnippet
+
+snippet /set(ter)?/ "setter" br
+public void set${1:Name}(${2:String} `!p snip.rv = mixedCase(t[1])`) {
+ this.`!p snip.rv = mixedCase(t[1])` = `!p snip.rv = mixedCase(t[1])`;
+}
+endsnippet
+snippet /se?tge?t|ge?tse?t|gs/ "setter and getter" br
+public void set${1:Name}(${2:String} `!p snip.rv = mixedCase(t[1])`) {
+ this.`!p snip.rv = mixedCase(t[1])` = `!p snip.rv = mixedCase(t[1])`;
+}
+
+public $2 get$1() {
+ return `!p snip.rv = mixedCase(t[1])`;
+}
endsnippet
snippet pa "package" b
-package
+package $0
endsnippet
snippet p "print" b
@@ -154,33 +376,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 +412,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 th "throw" b
-throw $0
+snippet tt "test throws" b
+`!p junit(snip)`public void test${1:Name}() ${2:throws Exception }{
+ $0
+}
endsnippet
-snippet v "variable" b
-${1:String} ${2:var}${3: = ${0:null}};
+snippet th "throw" b
+throw new $0
endsnippet
snippet wh "while" b
diff --git a/UltiSnips/javascript.snippets b/UltiSnips/javascript.snippets
index 439ec874c..5889e0591 100644
--- a/UltiSnips/javascript.snippets
+++ b/UltiSnips/javascript.snippets
@@ -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,147 @@ ${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
+
+snippet fi "for prop in obj using hasOwnProperty" b
+for (${1:prop} in ${2:obj}){
+ if ($2.hasOwnProperty($1)) {
+ ${VISUAL}$0
+ }
+}
+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 cd "console.debug" b
+console.debug(${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:
diff --git a/UltiSnips/javascript_angular.snippets b/UltiSnips/javascript_angular.snippets
new file mode 100644
index 000000000..76e9ca1da
--- /dev/null
+++ b/UltiSnips/javascript_angular.snippets
@@ -0,0 +1,25 @@
+priority -50
+
+snippet iti "it (js, inject)" b
+it('${1:description}', inject(function($2) {
+ $0
+}));
+endsnippet
+
+snippet befi "before each (js, inject)" b
+beforeEach(inject(function($1) {
+ $0
+}));
+endsnippet
+
+snippet aconf "angular config" i
+config(function($1) {
+ $0
+});
+endsnippet
+
+snippet acont "angular controller" i
+controller('${1:name}', function($2) {
+ $0
+});
+endsnippet
diff --git a/UltiSnips/javascript_ember.snippets b/UltiSnips/javascript_ember.snippets
index 543a26adc..1b7e7b8db 100644
--- a/UltiSnips/javascript_ember.snippets
+++ b/UltiSnips/javascript_ember.snippets
@@ -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
diff --git a/UltiSnips/javascript_jasmine.snippets b/UltiSnips/javascript_jasmine.snippets
index 49e38a35d..3a8729857 100644
--- a/UltiSnips/javascript_jasmine.snippets
+++ b/UltiSnips/javascript_jasmine.snippets
@@ -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
-
diff --git a/UltiSnips/javascript_jsdoc.snippets b/UltiSnips/javascript_jsdoc.snippets
new file mode 100644
index 000000000..ca943fc7a
--- /dev/null
+++ b/UltiSnips/javascript_jsdoc.snippets
@@ -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
diff --git a/UltiSnips/jinja2.snippets b/UltiSnips/jinja2.snippets
index 6fef6edfa..ded01dcf0 100644
--- a/UltiSnips/jinja2.snippets
+++ b/UltiSnips/jinja2.snippets
@@ -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,25 +141,24 @@ 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
-# Filters
+# Filters
# @todo: expand only when snippet is preceeded by a |
snippet batch "batch items" w
diff --git a/UltiSnips/json.snippets b/UltiSnips/json.snippets
index 81e65611d..b0cad8303 100644
--- a/UltiSnips/json.snippets
+++ b/UltiSnips/json.snippets
@@ -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
-
diff --git a/UltiSnips/ledger.snippets b/UltiSnips/ledger.snippets
new file mode 100644
index 000000000..4bf46916f
--- /dev/null
+++ b/UltiSnips/ledger.snippets
@@ -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
diff --git a/UltiSnips/lhaskell.snippets b/UltiSnips/lhaskell.snippets
new file mode 100644
index 000000000..29169a555
--- /dev/null
+++ b/UltiSnips/lhaskell.snippets
@@ -0,0 +1,3 @@
+priority -50
+
+extends haskell
diff --git a/UltiSnips/lua.snippets b/UltiSnips/lua.snippets
index 1b82a245b..bc59c60cc 100644
--- a/UltiSnips/lua.snippets
+++ b/UltiSnips/lua.snippets
@@ -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
diff --git a/UltiSnips/mako.snippets b/UltiSnips/mako.snippets
index 92a7be38a..fb31ec848 100644
--- a/UltiSnips/mako.snippets
+++ b/UltiSnips/mako.snippets
@@ -1,3 +1,5 @@
+priority -50
+
#################
# From snipmate #
#################
diff --git a/UltiSnips/markdown.snippets b/UltiSnips/markdown.snippets
index c3189b8a1..0720cbfce 100644
--- a/UltiSnips/markdown.snippets
+++ b/UltiSnips/markdown.snippets
@@ -1,6 +1,4 @@
-###########################################################################
-# SNIPPETS for MARKDOWN #
-###########################################################################
+priority -50
###########################
# Sections and Paragraphs #
@@ -41,4 +39,15 @@ snippet img "Image"
$0
endsnippet
+snippet ilc "Inline Code" i
+\`$1\`$0
+endsnippet
+
+snippet cbl "Codeblock" b
+\`\`\`
+$1
+\`\`\`
+$0
+endsnippet
+
# vim:ft=snippets:
diff --git a/UltiSnips/objc.snippets b/UltiSnips/objc.snippets
index 0c6766417..45e41fc15 100644
--- a/UltiSnips/objc.snippets
+++ b/UltiSnips/objc.snippets
@@ -1,3 +1,5 @@
+priority -50
+
###########################################################################
# TextMate Snippets #
###########################################################################
@@ -11,11 +13,11 @@ snippet Imp "#import <> (Imp)"
endsnippet
snippet cl "020 Class (objc)"
-@interface ${1:`!p
+@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}
{
}
@@ -118,7 +120,7 @@ snippet arracc "LoD array (arracc)"
[${3:${1/./\l$0/}} addObject:anObject];
}
-- (void)insertObject:($2)anObject in$1AtIndex:(unsigned int)i
+- (void)insertObject:($2)anObject in$1AtIndex:(unsigned int)i
{
[$3 insertObject:anObject atIndex:i];
}
@@ -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
diff --git a/UltiSnips/ocaml.snippets b/UltiSnips/ocaml.snippets
index 157eb91a3..1ebc3477f 100644
--- a/UltiSnips/ocaml.snippets
+++ b/UltiSnips/ocaml.snippets
@@ -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
diff --git a/UltiSnips/pandoc.snippets b/UltiSnips/pandoc.snippets
new file mode 100644
index 000000000..157c9ef06
--- /dev/null
+++ b/UltiSnips/pandoc.snippets
@@ -0,0 +1,3 @@
+priority -49
+
+extends markdown
diff --git a/UltiSnips/perl.snippets b/UltiSnips/perl.snippets
index e183b115e..abaae3f5a 100644
--- a/UltiSnips/perl.snippets
+++ b/UltiSnips/perl.snippets
@@ -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 = ; 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...}
}
diff --git a/UltiSnips/php.snippets b/UltiSnips/php.snippets
index 7cc3e3c67..84003a722 100644
--- a/UltiSnips/php.snippets
+++ b/UltiSnips/php.snippets
@@ -1,107 +1,264 @@
-snippet "php open tag" b
- ${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"
+/**
+ * $2
+ * @return ${4:void}
+ * @author ${5:`!v g:snips_author`}
+ **/
+${1:public }function ${2:someFunc}(${3})
+{${6}
+}
+endsnippet
+snippet doc_i "doc_i"
/**
- * ${3:@author `whoami`}${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
*/
-`!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()
-`}
+public function get${1/\w+\s*/\u$0/}()
{
+ return $this->$1;$2
}
+$4
endsnippet
-snippet st "php static function" b
-${1:public} static function $2($3)
+snippet setter "PHP Class Setter" b
+/*
+ * Setter for $1
+ */
+public function set${1/\w+\s*/\u$0/}($$1)
{
- ${4}
+ $this->$1 = $$1;$3
+ ${4:return $this;}
}
+$0
endsnippet
-snippet __ "php constructor" b
-${1:public} function __construct($2)
+snippet gs "PHP Class Getter Setter" b
+/*
+ * Getter for $1
+ */
+public function get${1/\w+\s*/\u$0/}()
+{
+ return $this->$1;$2
+}
+
+/*
+ * Setter for $1
+ */
+public function set${1/\w+\s*/\u$0/}($$1)
{
- ${3}
+ $this->$1 = $$1;$3
+ ${4:return $this;}
}
+$0
endsnippet
-snippet sg "Setter and Getter" b
+snippet pub "Public function" b
+public function ${1:name}(${2:$param})
+{
+ ${VISUAL}${3:return null;}
+}
+$0
+endsnippet
-/**
- * @var ${3:`!p snip.rv = t[2].capitalize()`}
- */
-${1:protected} $$2;
-
-public function set`!p snip.rv = t[2].capitalize()`(`!p
-if re.match(r'[A-Z].*', t[3]):
- snip.rv = t[3] + ' '
-else:
- snip.rv = ''
-`$$2)
+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})
{
- $this->$2 = $$2;
+ ${VISUAL}${3:return null;}
+}
+$0
+endsnippet
- return $this;
+snippet pros "Protected static function" b
+protected static function ${1:name}(${2:$param})
+{
+ ${VISUAL}${3:return null;}
}
+$0
+endsnippet
-public function get`!p snip.rv = t[2].capitalize()`()
+snippet pris "Private static function" b
+private static function ${1:name}(${2:$param})
{
- return $this->$2;
+ ${VISUAL}${3:return null;}
}
+$0
endsnippet
-snippet if "php if" !b
-if (${1}) {
- ${2}
+snippet fu "Function snip" b
+function ${1:name}(${2:$param})
+{
+ ${VISUAL}${3:return null;}
}
+$0
endsnippet
-snippet ife "php ife" !b
-if (${1}) {
- ${2}
+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 /** "php comment block" b
+snippet construct "__construct()" b
/**
- * @${1}
+ * @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 '' . var_export($1, 1) . '
';$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
+
+# :vim:ft=snippets:
diff --git a/UltiSnips/php/phpunit.snippets b/UltiSnips/php_phpunit.snippets
similarity index 90%
rename from UltiSnips/php/phpunit.snippets
rename to UltiSnips/php_phpunit.snippets
index 6609f3fa6..1a310a191 100644
--- a/UltiSnips/php/phpunit.snippets
+++ b/UltiSnips/php_phpunit.snippets
@@ -1,7 +1,9 @@
-# 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
+namespace `!p
abspath = os.path.abspath(path)
m = re.search(r'[A-Z].+(?=/)', abspath)
if m:
diff --git a/UltiSnips/php/symfony2.snippets b/UltiSnips/php_symfony2.snippets
similarity index 77%
rename from UltiSnips/php/symfony2.snippets
rename to UltiSnips/php_symfony2.snippets
index 8fba46b9f..3d433169d 100644
--- a/UltiSnips/php/symfony2.snippets
+++ b/UltiSnips/php_symfony2.snippets
@@ -1,8 +1,10 @@
-# sugguestion? report bugs?
+# sugguestion? report bugs?
# go to https://github.com/chrisyue/vim-snippets/issues
-snippet contr "symfony2 controller" b
-namespace `!p
+priority -50
+
+snippet contr "Symfony2 controller" b
+namespace `!p
abspath = os.path.abspath(path)
m = re.search(r'[A-Z].+(?=/)', abspath)
if m:
@@ -25,19 +27,19 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
}
endsnippet
-snippet act "symfony2 action" b
+snippet act "Symfony2 action" b
/**
* @Route("${3}", name="${4}")
* @Method({${5:"POST"}})
+ * @Template()
*/
public function ${1}Action(${2})
{
${6}
- return $this->redirect($this->generate('home', [], false));
}
endsnippet
-snippet actt "symfony2 action and template" b
+snippet actt "Symfony2 action and template" b
/**
* @Route("${3}", name="${4}")
* @Method({${5:"GET"}})
@@ -51,8 +53,8 @@ public function ${1}Action(${2})
abspath = os.path.abspath(path)`
endsnippet
-snippet comm "symfony2 command" b
-namespace `!p
+snippet comm "Symfony2 command" b
+namespace `!p
abspath = os.path.abspath(path)
m = re.search(r'[A-Z].+(?=/)', abspath)
if m:
@@ -74,14 +76,12 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
{
protected function configure()
{
- $this
- ->setName('${1}')
+ $this->setName('${1}')
->setDescription('${2}')
->setDefinition([
new InputArgument('', InputArgument::REQUIRED, ''),
new InputOption('', null, InputOption::VALUE_NONE, ''),
- ])
- ;
+ ]);
}
protected function execute(InputInterface $input, OutputInterface $output)
@@ -90,8 +90,8 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
}
endsnippet
-snippet subs "symfony2 subscriber" b
-namespace `!p
+snippet subs "Symfony2 subscriber" b
+namespace `!p
abspath = os.path.abspath(path)
m = re.search(r'[A-Z].+(?=/)', abspath)
if m:
@@ -121,8 +121,8 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
}
endsnippet
-snippet transf "symfony2 form data transformer" b
-namespace `!p
+snippet transf "Symfony2 form data transformer" b
+namespace `!p
abspath = os.path.abspath(path)
m = re.search(r'[A-Z].+(?=/)', abspath)
if m:
@@ -155,8 +155,8 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
}
endsnippet
-snippet ent "symfony2 doctrine entity" b
-namespace `!p
+snippet ent "Symfony2 doctrine entity" b
+namespace `!p
abspath = os.path.abspath(path)
m = re.search(r'[A-Z].+(?=/)', abspath)
if m:
@@ -169,13 +169,17 @@ use Doctrine\ORM\Mapping as ORM;
* ${3:@author `whoami`}
*
* @ORM\Entity()
- * @ORM\Table(name="`!p
+ * @ORM\Table(name="`!p
tmp = re.match(r'.*(?=\.)', fn).group()
tmp = re.sub(r'\B([A-Z])', r'_\1', tmp)
snip.rv = tmp.lower()
`")
*/
-class `!p
+`!p
+m = re.search(r'Abstract', path)
+if m:
+ snip.rv = 'abstract '
+`class `!p
snip.rv = re.match(r'.*(?=\.)', fn).group()
`
{
@@ -188,8 +192,8 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
}
endsnippet
-snippet form "symfony2 form type" b
-namespace `!p
+snippet form "Symfony2 form type" b
+namespace `!p
abspath = os.path.abspath(path)
m = re.search(r'[A-Z].+(?=/)', abspath)
if m:
@@ -207,27 +211,51 @@ class `!p
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()
- {
+ {
return '${1}';
}
}
endsnippet
+
+snippet ev "Symfony2 event" b
+namespace `!p
+abspath = os.path.abspath(path)
+m = re.search(r'[A-Z].+(?=/)', abspath)
+if m:
+ snip.rv = m.group().replace('/', '\\')
+`;
+
+use Symfony\Component\EventDispatcher\Event;
+
+/**
+ * ${2:@author `whoami`}
+ */
+class `!p
+snip.rv = re.match(r'.*(?=\.)', fn).group()
+` extends Event
+{
+}
+endsnippet
+
+snippet redir "Symfony2 redirect"
+$this->redirect($this->generateUrl('${1}', ${2}));
+endsnippet
diff --git a/UltiSnips/proto.snippets b/UltiSnips/proto.snippets
new file mode 100644
index 000000000..923be5786
--- /dev/null
+++ b/UltiSnips/proto.snippets
@@ -0,0 +1,52 @@
+priority -50
+
+global !p
+from vimsnippets import complete
+
+FIELD_TYPES = [
+ 'double',
+ 'float',
+ 'int32',
+ 'int64',
+ 'uint32',
+ 'uint64',
+ 'sint32',
+ 'sint64',
+ 'fixed32',
+ 'fixed64',
+ 'sfixed32',
+ 'sfixed64',
+ 'bool',
+ 'string',
+ 'bytes']
+endglobal
+
+snippet mess "Proto message" b
+// ${2:TODO(`whoami`): Describe this message.}
+message ${1:Name} {
+ $0
+
+ // Next available id: 1
+}
+endsnippet
+
+snippet reqf "Required field" b
+// ${4:TODO(`whoami`): Describe this field.}
+optional ${1}`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1}; // Required
+endsnippet
+
+snippet optf "Optional field" b
+// ${4:TODO(`whoami`): Describe this field.}
+optional ${1}`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1};
+endsnippet
+
+snippet repf "Repeated field" b
+// ${4:TODO(`whoami`): Describe this field.}
+repeated ${1}`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1};
+endsnippet
+
+snippet enum "Enumeration" b
+// ${2:TODO(`whoami`): Describe this enum.}
+enum ${1:Name} {
+}
+endsnippet
diff --git a/UltiSnips/puppet.snippets b/UltiSnips/puppet.snippets
index 68ae0fe44..1b2cfc574 100644
--- a/UltiSnips/puppet.snippets
+++ b/UltiSnips/puppet.snippets
@@ -1,78 +1,235 @@
-# 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 group "Group resource type" b
-group { "${1:groupname}":
- ensure => ${3:present},
- gid => ${2:gid},
+snippet File "Defaults for file" b
+File {
+ owner => ${1:username},
+ group => ${2:groupname},
+}
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"],
+snippet group "Group resource type" b
+group { '${1:groupname}':
+ ensure => ${3:present},
+ gid => ${2:gid},
+}
endsnippet
-snippet exec "Exec resource type" b
-exec { "${1:command}":
- refreshonly => true,
+snippet mount "Mount resource type" b
+mount { '${1:path}':
+ device => '${2:/dev}',
+ fstype => '${3:filesystem}',
+ ensure => mounted,
+ options => 'rw,errors=remount-ro',
}
endsnippet
-snippet cron "Cron resource type" b
-cron { "${1:name}":
- user => ${2:user},
- command => "${3:command}",
- minute => ${3:minute},
- hour => ${4:hour},
+snippet package "Package resource type" b
+package { '${1:name}':
+ ensure => ${2:installed},
}
endsnippet
-snippet mount "Mount resource type" b
-mount { "${1:path}":
- device => "${2:/dev}",
- fstype => "${3:filesystem}",
- ensure => mounted,
- options => "rw,errors=remount-ro",
+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:
diff --git a/UltiSnips/python.snippets b/UltiSnips/python.snippets
index a770d2a98..64b5cfd2c 100644
--- a/UltiSnips/python.snippets
+++ b/UltiSnips/python.snippets
@@ -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 #
@@ -28,68 +34,128 @@ global !p
NORMAL = 0x1
DOXYGEN = 0x2
SPHINX = 0x3
+GOOGLE = 0x4
+
+SINGLE_QUOTES = 0x1
+DOUBLE_QUOTES = 0x2
+
+
+class Arg(object):
+ def __init__(self, arg):
+ self.arg = arg
+ self.name = arg.split('=')[0].strip()
+
+ def __str__(self):
+ return self.name
+
+ def __unicode__(self):
+ return self.name
+
+ def is_kwarg(self):
+ return '=' in self.arg
+
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(arg) for arg in arglist.split(',') if arg]
+ args = [arg for arg in args if arg.name != '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 triple_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
+ elif style == "google": return GOOGLE
+ 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
+ elif style == GOOGLE:
+ return "%s (@todo): @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"
+ elif style == GOOGLE:
+ return "Returns: @todo"
def write_docstring_args(args, snip):
- if not args:
- snip.rv += ' """'
- return
+ if not args:
+ snip.rv += ' {0}'.format(triple_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)
+ if style == GOOGLE:
+ write_google_docstring_args(args, snip)
+ else:
+ for arg in args:
+ snip += format_arg(arg, style)
+
+
+def write_google_docstring_args(args, snip):
+ kwargs = [arg for arg in args if arg.is_kwarg()]
+ args = [arg for arg in args if not arg.is_kwarg()]
+
+ if args:
+ snip += "Args:"
+ snip.shift()
+ for arg in args:
+ snip += format_arg(arg, GOOGLE)
+ snip.unshift()
+ snip.rv += '\n' + snip.mkline('', indent='')
+
+ if kwargs:
+ snip += "Kwargs:"
+ snip.shift()
+ for kwarg in kwargs:
+ snip += format_arg(kwarg, GOOGLE)
+ snip.unshift()
+ snip.rv += '\n' + snip.mkline('', indent='')
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 +165,11 @@ endglobal
snippet class "class with docstrings" b
class ${1:MyClass}(${2:object}):
- """${3:Docstring for $1 }"""
+
+ `!p snip.rv = triple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = triple_quotes(snip)`
def __init__(self$4):
- """${5:@todo: to be defined}`!p
+ `!p snip.rv = triple_quotes(snip)`${5:@todo: to be defined1.}`!p
snip.rv = ""
snip >> 2
@@ -110,8 +177,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(triple_quotes(snip))
write_init_body(args, t[2], snip)
`
@@ -121,7 +188,8 @@ endsnippet
snippet slotclass "class with slots and docstrings" b
class ${1:MyClass}(${2:object}):
- """${3:Docstring for $1 }"""
+
+ `!p snip.rv = triple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = triple_quotes(snip)`
`!p
snip >> 1
args = get_args(t[4])
@@ -129,7 +197,7 @@ write_slots_args(args, snip)
`
def __init__(self$4):
- """${5:@todo: to be defined}`!p
+ `!p snip.rv = triple_quotes(snip)`${5:@todo: to be defined.}`!p
snip.rv = ""
snip >> 2
@@ -137,8 +205,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 += triple_quotes(snip)
write_init_body(args, t[2], snip)
`
@@ -330,19 +398,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 = triple_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 += triple_quotes(snip) `
${0:pass}
endsnippet
@@ -362,23 +430,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 = triple_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 += triple_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 +532,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 +563,8 @@ endsnippet
snippet testcase "pyunit testcase" b
class Test${1:Class}(${2:unittest.TestCase}):
- """${3:Test case docstring}"""
+
+ `!p snip.rv = triple_quotes(snip)`${3:Test case docstring.}`!p snip.rv = triple_quotes(snip)`
def setUp(self):
${4:pass}
diff --git a/UltiSnips/r.snippets b/UltiSnips/r.snippets
new file mode 100644
index 000000000..10c818c01
--- /dev/null
+++ b/UltiSnips/r.snippets
@@ -0,0 +1,177 @@
+priority -50
+
+global !p
+import os
+from vimsnippets import complete
+
+FIELD_TYPES = [
+'character',
+'data.frame',
+'integer',
+'list',
+'logical',
+'matrix',
+'numeric',
+'vector']
+endglobal
+
+snippet #! "Hashbang for Rscript (#!)" b
+#!/usr/bin/env Rscript
+endsnippet
+
+snippet setwd "Set workingdir" b
+setwd("${1:`!p snip.rv = os.getcwd()`}")
+endsnippet
+
+snippet as "Apply type on variable" w
+as.$1`!p snip.rv = complete(t[1], FIELD_TYPES)`(${2}${VISUAL})
+endsnippet
+
+snippet is "Test type on variable" w
+is.$1`!p snip.rv = complete(t[1], FIELD_TYPES)`(${2}${VISUAL})
+endsnippet
+
+snippet dl "Download and install a package" b
+download.file("${1:${VISUAL:url to package}}", destfile = "${2:${1/.*\/(\S*)$/(?1:$1)/ga}}")
+install.packages("$2", type = "source", repos = NULL)
+library("${3:${2/^(\w+)_.*$/(?1:$1)/ga}}")
+endsnippet
+
+snippet lib "Import a library"
+library(${0:package})
+endsnippet
+
+snippet req "Require a file"
+require(${0:package})
+endsnippet
+
+snippet source "Source a file"
+source('${0:file}')
+endsnippet
+
+snippet if "If statement"
+if (${1}) {
+ ${0}
+}
+endsnippet
+
+snippet eif "Else-If statement"
+else if (${1}) {
+ ${0}
+}
+
+snippet el "Else statement"
+else {
+ ${0}
+}
+endsnippet
+
+snippet ife "if .. else"
+if (${1}) {
+ ${2}
+} else {
+ ${3}
+}
+endsnippet
+
+snippet wh "while loop"
+while(${1}) {
+ ${2}
+}
+endsnippet
+
+snippet for "for loop"
+for (${1:item} in ${2:list}) {
+ ${3}
+}
+endsnippet
+
+snippet fun "Function definition"
+${1:name} <- function (${2}) {
+ ${0}
+}
+endsnippet
+
+snippet ret "Return call"
+return(${0})
+endsnippet
+
+snippet df "Data frame"
+${1:name}[${2:rows}, ${0:cols}]
+endsnippet
+
+snippet c "c function"
+c(${0:items})
+endsnippet
+
+snippet li "list function"
+list(${0:items})
+endsnippet
+
+snippet mat "matrix function"
+matrix(${1:data}, nrow = ${2:rows}, ncol = ${0:cols})
+endsnippet
+
+snippet apply "apply function"
+apply(${1:array}, ${2:margin}, ${0:function})
+endsnippet
+
+snippet lapply "lapply function"
+lapply(${1:list}, ${0:function})
+endsnippet
+
+snippet sapply "sapply function"
+sapply(${1:list}, ${0:function})
+endsnippet
+
+snippet vapply "vapply function"
+vapply(${1:list}, ${2:function}, ${0:type})
+endsnippet
+
+snippet mapply "mapply function"
+mapply(${1:function}, ${0:...})
+endsnippet
+
+snippet tapply "tapply function"
+tapply(${1:vector}, ${2:index}, ${0:function})
+endsnippet
+
+snippet rapply "rapply function"
+rapply(${1:list}, ${0:function})
+endsnippet
+
+snippet pl "Plot function"
+plot(${1:x}, ${0:y})
+endsnippet
+
+snippet ggp "ggplot2 plot"
+ggplot(${1:data}, aes(${0:aesthetics}))
+endsnippet
+
+snippet fis "Fisher test"
+fisher.test(${1:x}, ${0:y})
+endsnippet
+
+snippet chi "Chi Squared test"
+chisq.test(${1:x}, ${0:y})
+endsnippet
+
+snippet tt "t-test"
+t.test(${1:x}, ${0:y})
+endsnippet
+
+snippet wil "Wilcox test"
+wilcox.test(${1:x}, ${0:y})
+endsnippet
+
+snippet cor "Correlation test"
+cor.test(${1:x}, ${0:y})
+endsnippet
+
+snippet fte "FTE test"
+var.test(${1:x}, ${0:y})
+endsnippet
+
+snippet kvt "KV test"
+kv.test(${1:x}, ${0:y})
+endsnippet
diff --git a/UltiSnips/rails.snippets b/UltiSnips/rails.snippets
index 9e0e29f88..5c5217958 100644
--- a/UltiSnips/rails.snippets
+++ b/UltiSnips/rails.snippets
@@ -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]
-
- # 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
-
- # 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
-
- 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
-
- # 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
-
- # 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
-
- 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
+ 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
+
+ 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/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
+
+ # 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/}])
+
+ 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
+
+ # 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
+
+ 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
@@ -893,13 +891,13 @@ setup do
end
endsnippet
-snippet trans "Translation snippet"
+snippet trans "Translation snippet"
I18n.t('`!v substitute(substitute(substitute(@%, substitute(getcwd() . "/", "\/", "\\\\/", "g"), "", ""), "\\(\\.\\(html\\|js\\)\\.\\(haml\\|erb\\)\\|\\(_controller\\)\\?\\.rb\\)$", "", ""), "/", ".", "g")`.${2:${1/[^\w]/_/g}}${3}', :default => "${1:some_text}"${4})${5:$0}
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
diff --git a/UltiSnips/rnoweb.snippets b/UltiSnips/rnoweb.snippets
new file mode 100644
index 000000000..773b9aa9d
--- /dev/null
+++ b/UltiSnips/rnoweb.snippets
@@ -0,0 +1,3 @@
+priority -50
+
+extends tex, r
diff --git a/UltiSnips/rst.snippets b/UltiSnips/rst.snippets
index 88e0caafb..3763a95e9 100644
--- a/UltiSnips/rst.snippets
+++ b/UltiSnips/rst.snippets
@@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-
+priority -50
+
###########################################################################
-# General Stuff #
+# General Stuff #
###########################################################################
global !p
import vim
@@ -10,27 +12,29 @@ from string import Template
import re
from collections import Counter
+from vimsnippets import complete
+
#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"]
+SPECIFIC_ADMONITIONS = ["attention", "caution", "danger",
+ "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,116 +43,95 @@ CJK_RE = re.compile(u'[⺀-⺙⺛-⻳⼀-⿕々〇〡-〩〸-〺〻㐀-䶵一-
def has_cjk(char):
- """
- 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
+ """
+ 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
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.
-
- :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
+ """
+ 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
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
-
- :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
+ """
+ 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
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
-
- :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
-
-
-def complete(t, opts):
- """
- get options that start with t
-
- :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]
-
- if not len(opts):
- msg = "{0}"
- return msg.format("|".join(opts))
+ """
+ find most popular code type in the given rst
+
+ :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
endglobal
snippet part "Part" b
@@ -199,22 +182,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
-if has_cjk(vim.current.line):
- snip.rv ="\ "
+ snip.rv ="\ "`*${1:${VISUAL:Em}}*`!p
+if has_cjk(vim.current.line):
+ snip.rv ="\ "
else:
- snip.rv = " "
+ snip.rv = " "
`$0
endsnippet
snippet st "Strong string" i
-`!p
+`!p
+if has_cjk(vim.current.line):
+ snip.rv ="\ "`**${1:${VISUAL:Strong}}**`!p
if has_cjk(vim.current.line):
- 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 +219,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
@@ -249,7 +232,7 @@ endsnippet
# match snippets :
# img, inc, fig
snippet id "Includable Directives" b
-`!p
+`!p
real_name=real_filename(ospath.basename(t[2]))
di=t[1][:2]
@@ -257,28 +240,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
@@ -289,8 +272,8 @@ endsnippet
snippet sa "Specific Admonitions" b
.. $1`!p snip.rv =complete(t[1], SPECIFIC_ADMONITIONS)`::
-
- ${2:Content}
+
+ ${2:Content}
$0
endsnippet
@@ -298,8 +281,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 +292,6 @@ endsnippet
snippet sid "SideBar" b
.. sidebar:: ${1:SideBar Title}
- ${2:SideBar Content}
+ ${2:SideBar Content}
endsnippet
# vim:ft=snippets:
diff --git a/UltiSnips/ruby.snippets b/UltiSnips/ruby.snippets
index 90001b1a4..09a114f6c 100644
--- a/UltiSnips/ruby.snippets
+++ b/UltiSnips/ruby.snippets
@@ -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 ... end"
if ${1:condition}
- ${2}
+ ${2:# TODO}
end
endsnippet
@@ -33,9 +35,9 @@ endsnippet
snippet ife "if ... else ... end"
if ${1:condition}
- ${2}
+ ${2:# TODO}
else
- ${3}
+ ${3:# TODO}
end
endsnippet
@@ -43,11 +45,11 @@ endsnippet
snippet ifee "if ... elseif ... 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 ... end"
unless ${1:condition}
- ${0}
+ ${0:# TODO}
end
endsnippet
@@ -63,9 +65,9 @@ endsnippet
snippet unlesse "unless ... else ... end"
unless ${1:condition}
- ${2}
+ ${2:# TODO}
else
- ${0}
+ ${0:# TODO}
end
endsnippet
@@ -73,11 +75,11 @@ endsnippet
snippet unlesee "unless ... elseif ... 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 ..." 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 ... rescue ..."
def ${1:function_name}${2: ${3:*args}}
- ${4}
+ ${4:# TODO}
rescue
- ${0}
+ ${0:# TODO}
end
endsnippet
snippet For "(..).each { || }"
-(${1:from}..${2:to}).each { |${3:i}| ${4} }
+(${1:from}..${2:to}).each { |${3:i}| ${4:# TODO} }
endsnippet
snippet for "(..).each do || 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 { |,| }" 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 |,| 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 { |,| }" 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 ,| end" r
`!p snip.rv=match.group(1)`.keep_if do |${1:key},${2:value}|
- ${0}
+ ${0:# TODO}
end
endsnippet
snippet "(\S+)\.Reject" ".reject { |,| }" 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 ,| 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 { |,| }" 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 |,| 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 { || }" 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| 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 { || }" 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 || end" r
`!p snip.rv=match.group(1)`.each_value do |${1:value}|
- ${0}
+ ${0:# TODO}
end
endsnippet
snippet Each ".each { || }"
-${1:elements}.each { |${2:${1/s$//}}| ${3} }
+${1:elements}.each { |${2:${1/s$//}}| ${3:# TODO} }
endsnippet
snippet each ".each do || end"
${1:elements}.each do |${2:${1/s$//}}|
- ${0}
+ ${0:# TODO}
end
endsnippet
-snippet each_?s(lice)? ".each_slice(n) do |slice| end"
-each_slice(${1:2}) do |${2:slice}|
- ${0}
+snippet "each_?s(lice)?" ".each_slice(n) do |slice| end" r
+${1:elements}.each_slice(${2:2}) do |${3:slice}|
+ ${0:# TODO}
end
endsnippet
-snippet Each_?s(lice)? ".each_slice(n) { |slice| }"
-each_slice(${1:2}) { |${2:slice}| ${3} }
+snippet "Each_?s(lice)?" ".each_slice(n) { |slice| }" 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 { |,| }" r
+snippet "(\S+)\.Each_?w(ith)?_?i(ndex)?" ".each_with_index { |,| }" 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 { |,| }" 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 |,| 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
-do
+
+
+snippet do "do || ... end" i
+do |${1:args}|
$0
end
endsnippet
-snippet dov "do || ... end" i
-do |${1:v}|
- $2
+
+
+snippet Do "do ... end" i
+do
+ $0
end
endsnippet
-
snippet until "until ... end"
until ${1:expression}
- ${0}
+ ${0:# TODO}
end
endsnippet
@@ -449,15 +453,15 @@ endsnippet
snippet Until "begin ... end until "
begin
- ${0}
+ ${0:# TODO}
end until ${1:expression}
endsnippet
-snippet wh "while ... end"
+snippet while "while ... end"
while ${1:expression}
- ${0}
+ ${0:# TODO}
end
endsnippet
@@ -465,7 +469,7 @@ endsnippet
snippet While "begin ... end while "
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
diff --git a/UltiSnips/rust.snippets b/UltiSnips/rust.snippets
new file mode 100644
index 000000000..d7f0047c0
--- /dev/null
+++ b/UltiSnips/rust.snippets
@@ -0,0 +1,252 @@
+#######################################################################
+# Rust Snippets #
+#######################################################################
+
+priority -50
+
+snippet fn "A function, optionally with arguments and return type." b
+fn ${1:function_name}(${2})${3/..*/ -> /}${3} {
+ ${VISUAL}${0}
+}
+endsnippet
+
+snippet test "Test function" b
+#[test]
+fn ${1:test_function_name}() {
+ ${VISUAL}${0}
+}
+endsnippet
+
+
+snippet bench "Bench function" b
+#[bench]
+fn ${1:bench_function_name}(b: &mut test::Bencher) {
+ b.iter(|| {
+ ${VISUAL}${0}
+ })
+}
+endsnippet
+
+snippet new "A new function" b
+pub fn new(${2}) -> ${1:Name} {
+ ${VISUAL}${0}return $1 { ${3} };
+}
+endsnippet
+
+snippet main "The main function" b
+pub fn main() {
+ ${VISUAL}${0}
+}
+endsnippet
+
+snippet let "A let statement" b
+let ${1:name}${3} = ${VISUAL}${2};
+endsnippet
+
+snippet lmut "let mut = .." b
+let mut ${1:name}${3} = ${VISUAL}${2};
+endsnippet
+
+snippet pri "print!(..)" b
+print!("${1}"${2/..*/, /}${2});
+endsnippet
+
+snippet pln "println!(..)" b
+println!("${1}"${2/..*/, /}${2});
+endsnippet
+
+snippet fmt "format!(..)"
+format!("${1}"${2/..*/, /}${2});
+endsnippet
+
+snippet macro "macro_rules!" b
+macro_rules! ${1:name} (
+ (${2:matcher}) => (
+ ${3}
+ )
+)
+endsnippet
+
+snippet ec "extern crate ..." b
+extern crate ${1:sync};
+endsnippet
+
+snippet ecl "...extern crate log;" b
+#![feature(phase)]
+#[phase(syntax, link)] extern crate log;
+endsnippet
+
+snippet mod "A module" b
+mod ${1:`!p snip.rv = snip.basename.lower() or "name"`} {
+ ${VISUAL}${0}
+}
+endsnippet
+
+snippet crate "Create header information" b
+// Crate ID
+#![crate_id = "${1:crate_name}#${2:0.0.1}"]
+
+// Additional metadata attributes
+#![desc = "${3:Descrption.}"]
+#![license = "${4:BSD}"]
+#![comment = "${5:Comment.}"]
+
+// Specify the output type
+#![crate_type = "${6:lib}"]
+endsnippet
+
+snippet allow "#[allow(..)]" b
+#[allow(${1:unused_variable})]
+endsnippet
+
+snippet feat "#![feature(..)]" b
+#![feature(${1:macro_rules})]
+endsnippet
+
+snippet der "#[deriving(..)]" b
+#[deriving(${1:Show})]
+endsnippet
+
+snippet attr "#[..]" b
+#[${1:inline}]
+endsnippet
+
+snippet opt "Option<..>"
+Option<${1:int}>
+endsnippet
+
+snippet res "Result<.., ..>"
+Result<${1:int}, ${2:()}>
+endsnippet
+
+snippet if "if .. (if)" b
+if ${1} {
+ ${VISUAL}${0}
+}
+endsnippet
+
+snippet el "else .. (el)"
+else {
+ ${VISUAL}${0}
+}
+endsnippet
+
+snippet eli "else if .. (eli)"
+else if ${1} {
+ ${VISUAL}${0}
+}
+endsnippet
+
+snippet ife "if .. else (ife)"
+if ${1} {
+ ${2}
+} else {
+ ${3}
+}
+endsnippet
+
+snippet mat "match"
+match ${1} {
+ ${2} => ${3},
+}
+endsnippet
+
+snippet loop "loop {}" b
+loop {
+ ${VISUAL}${0}
+}
+endsnippet
+
+snippet while "while .. {}" b
+while ${1} {
+ ${VISUAL}${0}
+}
+endsnippet
+
+snippet for "for .. in .." b
+for ${1:i} in ${2:range(0u, 10)} {
+ ${VISUAL}${0}
+}
+endsnippet
+
+snippet spawn "spawn(proc() { .. });" b
+spawn(proc() {
+ ${VISUAL}${0}
+});
+endsnippet
+
+snippet chan "A channel" b
+let (${1:tx}, ${2:rx}): (Sender<${3:int}>, Receiver<${4:int}>) = channel();
+endsnippet
+
+snippet duplex "Duplex stream" b
+let (${1:from_child}, ${2:to_child}) = sync::duplex();
+endsnippet
+
+snippet todo "A Todo comment"
+// [TODO]: ${1:Description} - `!v strftime("%Y-%m-%d %I:%M%P")`
+endsnippet
+
+snippet fixme "FIXME comment"
+// FIXME: ${1}
+endsnippet
+
+snippet st "Struct" b
+struct ${1:`!p snip.rv = snip.basename.title() or "Name"`} {
+ ${VISUAL}${0}
+}
+endsnippet
+
+snippet stn "Struct with new constructor." b
+pub struct ${1:`!p snip.rv = snip.basename.title() or "Name"`} {
+ ${3}
+}
+
+impl $1 {
+ pub fn new(${2}) -> $1 {
+ ${4}return $1 {
+ ${5}
+ };
+ }
+}
+endsnippet
+
+snippet enum "An enum" b
+enum ${1:Name} {
+ ${VISUAL}${0},
+}
+endsnippet
+
+snippet type "A type" b
+type ${1:NewName} = ${VISUAL}${0};
+endsnippet
+
+snippet imp "An impl" b
+impl ${1:Name} {
+ ${VISUAL}${0}
+}
+endsnippet
+
+snippet drop "Drop implementation" b
+impl Drop for ${1:Name} {
+ fn drop(&mut self) {
+ ${VISUAL}${0}
+ }
+}
+endsnippet
+
+snippet trait "Trait definition" b
+trait ${1:Name} {
+ ${VISUAL}${0}
+}
+endsnippet
+
+snippet ss "A static string."
+static ${1}: &'static str = "${VISUAL}${0}";
+endsnippet
+
+snippet stat "A static variable."
+static ${1}: ${2:uint} = ${VISUAL}${0};
+endsnippet
+
+# vim:ft=snippets:
diff --git a/UltiSnips/scss.snippets b/UltiSnips/scss.snippets
new file mode 100644
index 000000000..70a44a076
--- /dev/null
+++ b/UltiSnips/scss.snippets
@@ -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
diff --git a/UltiSnips/sh.snippets b/UltiSnips/sh.snippets
index cce06ef3d..9cc45779e 100644
--- a/UltiSnips/sh.snippets
+++ b/UltiSnips/sh.snippets
@@ -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
diff --git a/UltiSnips/snippets.snippets b/UltiSnips/snippets.snippets
index 414f350ee..ee0c8c766 100644
--- a/UltiSnips/snippets.snippets
+++ b/UltiSnips/snippets.snippets
@@ -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"`
diff --git a/UltiSnips/soy.snippets b/UltiSnips/soy.snippets
new file mode 100644
index 000000000..9a22a57ce
--- /dev/null
+++ b/UltiSnips/soy.snippets
@@ -0,0 +1,63 @@
+priority -50
+
+extends html
+
+snippet ns "Namespace" b
+{namespace ${1:name}}
+endsnippet
+
+snippet tmpl "Template" b
+/**
+ * ${2:TODO(`whoami`): Describe this template.}
+ */
+{template .${1:name}}
+ $0
+{/template}
+endsnippet
+
+snippet msg "Message" b
+{msg desc="${1:description}"}
+ $0
+{/msg}
+endsnippet
+
+snippet let "let command" b
+{let $${1:identifier}: ${2:expression} /}
+endsnippet
+
+snippet if "if .. (if)" b
+{if ${1:expression}}
+ $0
+{/if}
+endsnippet
+
+snippet ife "if .. else (ife)" b
+{if ${1:expression}}
+ $2
+{else}
+ $0
+{/if}
+endsnippet
+
+snippet eli "else if .. (eli)" b
+{elif ${1:expression}}
+ $0
+endsnippet
+
+snippet fore "foreach command" b
+{foreach $${1:var} in ${2:ref}}
+ $0
+{/foreach}
+endsnippet
+
+snippet for "for command" b
+{for $${1:var} in range(${2:rangeexpr})}
+ $0
+{/for}
+endsnippet
+
+snippet call "template call" b
+{call ${1:tmpl}}
+ $0
+{/call}
+endsnippet
diff --git a/UltiSnips/tcl.snippets b/UltiSnips/tcl.snippets
index fd53d2652..658491571 100644
--- a/UltiSnips/tcl.snippets
+++ b/UltiSnips/tcl.snippets
@@ -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}
}
diff --git a/UltiSnips/tex.snippets b/UltiSnips/tex.snippets
index 97ea8a82e..ede9090d9 100644
--- a/UltiSnips/tex.snippets
+++ b/UltiSnips/tex.snippets
@@ -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
+snippet tab "tabular / array environment" b
\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}}}
+\section{${1:section name}}
+\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}
+endsnippet
-% subparagraph $2 (end)
+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:
diff --git a/UltiSnips/texmath.snippets b/UltiSnips/texmath.snippets
index 03589f0f2..d0a25e9aa 100644
--- a/UltiSnips/texmath.snippets
+++ b/UltiSnips/texmath.snippets
@@ -1,3 +1,5 @@
+priority -50
+
##############
# MATH STUFF #
##############
diff --git a/UltiSnips/twig.snippets b/UltiSnips/twig.snippets
new file mode 100644
index 000000000..156b981b0
--- /dev/null
+++ b/UltiSnips/twig.snippets
@@ -0,0 +1,35 @@
+priority -50
+
+snippet bl "twig block" b
+{% block ${1} %}
+${2}
+{% endblock $1 %}
+endsnippet
+
+snippet js "twig javascripts" b
+{% javascripts '${1}' %}
+
+{% endjavascripts %}
+endsnippet
+
+snippet css "twig stylesheets" b
+{% stylesheets '${1}' %}
+
+{% endstylesheets %}
+endsnippet
+
+snippet if "twig if" b
+{% if ${1} %}
+${2}
+{% endif %}
+endsnippet
+
+snippet for "twig for" b
+{% for ${1} in ${2} %}
+${3}
+{% endfor %}
+endsnippet
+
+snippet ext "twig extends" b
+{% extends ${1} %}
+endsnippet
diff --git a/UltiSnips/vim.snippets b/UltiSnips/vim.snippets
index 5655c4b1b..dbb2396db 100644
--- a/UltiSnips/vim.snippets
+++ b/UltiSnips/vim.snippets
@@ -1,58 +1,24 @@
+priority -50
+
###########################################################################
# SnipMate Snippets #
###########################################################################
-snippet header
-" File: ${1:`!v expand('%:t')`}
-" Author: ${2:`!v g:snips_author`}
-" Description: ${3}
-${4:" Last Modified: `!v strftime("%B %d, %Y")`}
-
-$0
-endsnippet
-
-snippet gvar "Global / configuration variable"
+snippet gvar "Global / configuration variable" b
if !exists("g:${1:MyUltraImportantVar}")
let g:$1 = ${2:"${3:}"}
endif
endsnippet
-snippet guard
+snippet guard "script reload guard" b
if exists('${1:did_`!p snip.rv = snip.fn.replace('.','_')`}') || &cp${2: || version < 700}
finish
endif
let $1 = 1${3}
endsnippet
-snippet f
+snippet f "function" b
fun ${1:function_name}(${2})
- ${3}
+ ${3:" code}
endf
endsnippet
-
-snippet for
-for ${1} in ${2}
- ${3}
-endfor
-endsnippet
-
-snippet wh
-while ${1}
- ${2}
-endw
-endsnippet
-
-snippet if
-if ${1}
- ${2}
-endif
-endsnippet
-
-snippet ife
-if ${1}
- ${2}
-else
- ${3}
-endif
-endsnippet
-
# vim:ft=snippets:
diff --git a/UltiSnips/xhtml.snippets b/UltiSnips/xhtml.snippets
index e69de29bb..a9c5a29ad 100644
--- a/UltiSnips/xhtml.snippets
+++ b/UltiSnips/xhtml.snippets
@@ -0,0 +1,3 @@
+priority -50
+
+extends html
diff --git a/UltiSnips/xml.snippets b/UltiSnips/xml.snippets
index 80b017cea..92dfb6e1b 100644
--- a/UltiSnips/xml.snippets
+++ b/UltiSnips/xml.snippets
@@ -1,3 +1,10 @@
+priority -50
+
+snippet xml "XML declaration" b
+
+
+endsnippet
+
snippet t "Simple tag" b
<${1:tag}>
${2:content}
diff --git a/UltiSnips/zsh.snippets b/UltiSnips/zsh.snippets
index 803945970..f7986ea52 100644
--- a/UltiSnips/zsh.snippets
+++ b/UltiSnips/zsh.snippets
@@ -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
diff --git a/plugin/vimsnippets.vim b/plugin/vimsnippets.vim
new file mode 100644
index 000000000..3c3ecf923
--- /dev/null
+++ b/plugin/vimsnippets.vim
@@ -0,0 +1,37 @@
+if exists("b:done_vimsnippets")
+ finish
+endif
+let b:done_vimsnippets = 1
+
+" Expanding the path is not needed on Vim 7.4
+if &cp || version >= 704
+ finish
+endif
+
+" Add pythonx to the python search path if needed (i.e. <= Vim 7.3).
+if !has("python") && !has("python3")
+ finish
+end
+
+" This will fail if UltiSnips is not installed.
+try
+ call UltiSnips#bootstrap#Bootstrap()
+catch /E117/
+ finish
+endtry
+
+
+" This should have been set by UltiSnips, otherwise something is wrong.
+if !exists("g:_uspy")
+ finish
+end
+
+
+" Expand our path
+let s:SourcedFile=expand("")
+exec g:_uspy "import vim, os, sys"
+exec g:_uspy "sourced_file = vim.eval('s:SourcedFile')"
+exec g:_uspy "while not os.path.exists(os.path.join(sourced_file, 'pythonx')):
+ \ sourced_file = os.path.dirname(sourced_file)"
+exec g:_uspy "module_path = os.path.join(sourced_file, 'pythonx')"
+exec g:_uspy "sys.path.append(module_path)"
diff --git a/pythonx/vimsnippets.py b/pythonx/vimsnippets.py
new file mode 100644
index 000000000..b00edb150
--- /dev/null
+++ b/pythonx/vimsnippets.py
@@ -0,0 +1,20 @@
+"""Helper methods used in UltiSnips snippets."""
+
+def complete(tab, opts):
+ """
+ get options that start with tab
+
+ :param tab: query string
+ :param opts: list that needs to be completed
+
+ :return: a string that start with tab
+ """
+ msg = "({0})"
+ if tab:
+ opts = [m[len(tab):] for m in opts if m.startswith(tab)]
+ if len(opts) == 1:
+ return opts[0]
+
+ if not len(opts):
+ msg = "{0}"
+ return msg.format("|".join(opts))
diff --git a/snippets/_.snippets b/snippets/_.snippets
index 6a3d8b280..856160181 100644
--- a/snippets/_.snippets
+++ b/snippets/_.snippets
@@ -84,6 +84,24 @@ snippet LGPL3
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, see .
+ ${0}
+snippet AGPL3
+ ${1:one line to give the program's name and a brief description.}
+ Copyright (C) `strftime("%Y")` ${2:copyright holder}
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+
${0}
snippet BSD2
${1:one line to give the program's name and a brief description}
diff --git a/snippets/coffee/angular_coffee.snippets b/snippets/coffee/angular_coffee.snippets
new file mode 100644
index 000000000..f98cae355
--- /dev/null
+++ b/snippets/coffee/angular_coffee.snippets
@@ -0,0 +1,116 @@
+## Global Snippets
+# Define a new Angular Controller;
+# You can change the controller name and parameters
+snippet ngc
+ ${1:controllerName} = (${2:scope}, ${3:injectables}) ->
+ ${4}
+# angular.foreach loop
+snippet ngfor
+ angular.forEach ${1:iterateOver}, (value, key) ->
+ ${2}
+## Module Based Snippets
+# A new angular module without a config function
+snippet ngm
+ angular.module '${1:moduleName}', [${2:moduleDependencies}]
+ ${3}
+# A new angular module without a config function and a variable assignment
+snippet ngma
+ ${1:moduleName} = angular.module '$1', [${2:moduleDeps}]
+ ${3}
+# A new angular module with a config function
+snippet ngmc
+ ${1:moduleName} = angular.module('$1', [${2:moduleDeps}], (${3:configDeps}) ->
+ ${4}
+ )
+# A factory in a module
+snippet ngmfa
+ factory '${1:factoryName}', (${2:dependencies}) ->
+ ${3}
+# Define an Angular Module Service to be attached to a previously defined module
+# You can change the service name and service injectables
+snippet ngms
+ service '${1:serviceName}', (${2:injectables}) ->
+ ${3}
+# Define an Angular Module Filter to be attached to a previously defined module
+# You can change the filter name
+snippet ngmfi
+ filter '${1:filterName}', (${2:injectables}) ->
+ (input, ${3:args}) ->
+ ${4}
+## Route Based Snippets
+# Defines a when condition of an AngularJS route
+snippet ngrw
+ $routeProvider.when '${1:url}',
+ templateUrl: '${2:templateUrl}'
+ controller: '${3:controller}'
+ ${4}
+# Defines a when condition of an AngularJS route with the resolve block
+snippet ngrwr
+ $routeProvider.when '${1:url}',
+ templateUrl: '${2:templateUrl}'
+ controller: '${3:controller}'
+ resolve:
+ ${4}
+ ${5}
+# Defines an otherwise condition of an AngularJS route
+snippet ngro
+ $routeProvider.otherwise redirectTo: '${1:url}'
+ ${2}
+## Scope Related Snippets
+# Define a new $scope'd function (usually inside an AngularJS Controller)
+# You can change the function name and arguments
+snippet $f
+ $scope.${1:functionName} = (${2:args}) ->
+ ${3}
+# Defines a new $scope'd variable inside an AngularJS controller
+snippet $v
+ $scope.${1:variable} = ${2:value}
+ ${3}
+# Defines a new $scope'd variable inside an AngularJS controller and assigns a value from a constructor arguments
+snippet $va
+ $scope.${1:variable} = ${2:variable}
+ ${3}
+# Define a $watch for an expression
+# You can change the expression to be watched
+snippet $w
+ $scope.$watch '${1:watchExpr}', (newValue, oldValue) ->
+ ${2}
+# Define a $on for a $broadcast/$emit on the $scope inside an Angular Controller
+# You can change the event name to listen on
+snippet $on
+ $scope.$on '${1:eventName}', (event, ${2:args}) ->
+ ${3}
+# Define a $broadcast for a $scope inside an Angular Controller / Angular Controller Function
+# You can change the event name and optional event arguments
+snippet $b
+ $scope.$broadcast '${1:eventName}', ${2:eventArgs}
+ ${3}
+# Define an $emit for a $scope inside an Angular Controller / Angular Controller Function
+# You can change the event name and optional event arguments
+snippet $e
+ $scope.$emit '${1:eventName}', ${2:eventArgs}
+ ${3}
+## Directive related snippets
+# A compile function
+snippet ngdcf
+ compile = (tElement, tAttrs, transclude) ->
+ (scope, element, attrs) ->
+ ${1}
+# A linking function in a directive
+snippet ngdlf
+ (scope, element, attrs${1:ctrl}) ->
+ ${2}
+# A directive with a compile function
+snippet ngdc
+ directive '${1:directiveName}', factory = (${2:injectables}) ->
+ directiveDefinitionObject =
+ ${3:directiveAttrs}
+ compile: compile = (tElement, tAttrs, transclude) ->
+ (scope, element, attrs) ->
+ directiveDefinitionObject
+# A directive with a linking function only
+snippet ngdl
+ .directive('${1:directiveName}', (${2:directiveDeps}) ->
+ (scope, element, attrs${3:ctrl}) ->
+ ${4}
+ )
\ No newline at end of file
diff --git a/snippets/coffee.snippets b/snippets/coffee/coffee.snippets
similarity index 95%
rename from snippets/coffee.snippets
rename to snippets/coffee/coffee.snippets
index aca6e81aa..bb964346f 100644
--- a/snippets/coffee.snippets
+++ b/snippets/coffee/coffee.snippets
@@ -93,3 +93,9 @@ snippet req
# Export
snippet exp
${0:root} = exports ? this
+
+snippet jsonp
+ JSON.parse ${0:jstr}
+# JSON.stringify
+snippet jsons
+ JSON.stringify ${0:object}
diff --git a/snippets/coffee/jquery_coffee.snippets b/snippets/coffee/jquery_coffee.snippets
new file mode 100644
index 000000000..10bcd7756
--- /dev/null
+++ b/snippets/coffee/jquery_coffee.snippets
@@ -0,0 +1,524 @@
+snippet add
+ ${1:obj}.add('${2:selector expression}')
+snippet addClass
+ ${1:obj}.addClass('${2:class name}')
+snippet after
+ ${1:obj}.after('${2:Some text and bold!}')
+snippet ajax
+ $.ajax
+ url: "${1:mydomain.com/url}"
+ type: "${2:POST}"
+ dataType: "${3:xml/html/script/json}"
+ data: ${4:data}
+ complete: (jqXHR, textStatus) ->
+ ${5:// callback}
+ success: (data, textStatus, jqXHR) ->
+ ${6:// success callback}
+ error: (jqXHR, textStatus, errorThrown) ->
+ ${0:// error callback}
+snippet ajaxcomplete
+ ${1:obj}.ajaxComplete (${1:e}, xhr, settings) ->
+ ${0:// callback}
+snippet ajaxerror
+ ${1:obj}.ajaxError (${1:e}, xhr, settings, thrownError) ->
+ ${2:// error callback}
+ ${0}
+snippet ajaxget
+ $.get '${1:mydomain.com/url}',
+ ${2:{ param1: value1 },}
+ (data, textStatus, jqXHR) ->
+ ${0:// success callback}
+snippet ajaxpost
+ $.post '${1:mydomain.com/url}',
+ ${2:{ param1: value1 },}
+ (data, textStatus, jqXHR) ->
+ ${0:// success callback}
+snippet ajaxprefilter
+ $.ajaxPrefilter (${1:options}, ${2:originalOptions}, jqXHR) ->
+ ${0: // Modify options, control originalOptions, store jqXHR, etc}
+snippet ajaxsend
+ ${1:obj}.ajaxSend (${1:request, settings}) ->
+ ${2:// error callback}
+ ${0}
+snippet ajaxsetup
+ $.ajaxSetup({
+ url: "${1:mydomain.com/url}",
+ type: "${2:POST}",
+ dataType: "${3:xml/html/script/json}",
+ data: $.param( $("${4:Element or Expression}") ),
+ complete: (jqXHR, textStatus) ->
+ ${5:// callback}
+ ,
+ success: (data, textStatus, jqXHR) ->
+ ${6:// success callback}
+ ,
+ error: (jqXHR, textStatus, errorThrown) ->
+ ${0:// error callback}
+ })
+snippet ajaxstart
+ $.ajaxStart ->
+ ${1:// handler for when an AJAX call is started and no other AJAX calls are in progress}
+ ${0}
+snippet ajaxstop
+ $.ajaxStop ->
+ ${1:// handler for when all AJAX calls have been completed}
+ ${0}
+snippet ajaxsuccess
+ $.ajaxSuccess (${1:e}, xhr, settings) ->
+ ${2:// handler for when any AJAX call is successfully completed}
+ ${0}
+snippet andself
+ ${1:obj}.andSelf()
+snippet animate
+ ${1:obj}.animate({${2:param1: value1, param2: value2}}, ${3:speed})
+snippet append
+ ${1:obj}.append('${2:Some text and bold!}')
+snippet appendTo
+ ${1:obj}.appendTo('${2:selector expression}')
+snippet attr
+ ${1:obj}.attr('${2:attribute}', '${3:value}')
+snippet attrm
+ ${1:obj}.attr({'${2:attr1}': '${3:value1}', '${4:attr2}': '${5:value2}'})
+snippet before
+ ${1:obj}.before('${2:Some text and bold!}')
+snippet bind
+ ${1:obj}.bind('${2:event name}', (${3:e}) ->
+ ${0:// event handler}
+snippet blur
+ ${1:obj}.blur (${2:e}) ->
+ ${0:// event handler}
+snippet C
+ $.Callbacks()
+snippet Cadd
+ ${1:callbacks}.add(${2:callbacks})
+snippet Cdis
+ ${1:callbacks}.disable()
+snippet Cempty
+ ${1:callbacks}.empty()
+snippet Cfire
+ ${1:callbacks}.fire(${2:args})
+snippet Cfired
+ ${1:callbacks}.fired()
+snippet Cfirew
+ ${1:callbacks}.fireWith(${2:this}, ${3:args})
+snippet Chas
+ ${1:callbacks}.has(${2:callback})
+snippet Clock
+ ${1:callbacks}.lock()
+snippet Clocked
+ ${1:callbacks}.locked()
+snippet Crem
+ ${1:callbacks}.remove(${2:callbacks})
+snippet change
+ ${1:obj}.change (${2:e}) ->
+ ${0:// event handler}
+snippet children
+ ${1:obj}.children('${2:selector expression}')
+snippet clearq
+ ${1:obj}.clearQueue(${2:'queue name'})
+snippet click
+ ${1:obj}.click (${2:e}) ->
+ ${0:// event handler}
+snippet clone
+ ${1:obj}.clone()
+snippet contains
+ $.contains(${1:container}, ${0:contents})
+snippet css
+ ${1:obj}.css('${2:attribute}', '${3:value}')
+snippet csshooks
+ $.cssHooks['${1:CSS prop}'] = {
+ get: (elem, computed, extra) ->
+ ${2: // handle getting the CSS property}
+ set: (elem, value) ->
+ ${0: // handle setting the CSS value}
+ }
+snippet cssm
+ ${1:obj}.css({${2:attribute1}: '${3:value1}', ${4:attribute2}: '${5:value2}'})
+snippet D
+ $.Deferred()
+snippet Dalways
+ ${1:deferred}.always(${2:callbacks})
+snippet Ddone
+ ${1:deferred}.done(${2:callbacks})
+snippet Dfail
+ ${1:deferred}.fail(${2:callbacks})
+snippet Disrej
+ ${1:deferred}.isRejected()
+snippet Disres
+ ${1:deferred}.isResolved()
+snippet Dnotify
+ ${1:deferred}.notify(${2:args})
+snippet Dnotifyw
+ ${1:deferred}.notifyWith(${2:this}, ${3:args})
+snippet Dpipe
+ ${1:deferred}.then(${2:doneFilter}, ${3:failFilter}, ${4:progressFilter})
+snippet Dprog
+ ${1:deferred}.progress(${2:callbacks})
+snippet Dprom
+ ${1:deferred}.promise(${2:target})
+snippet Drej
+ ${1:deferred}.reject(${2:args})
+snippet Drejw
+ ${1:deferred}.rejectWith(${2:this}, ${3:args})
+snippet Dres
+ ${1:deferred}.resolve(${2:args})
+snippet Dresw
+ ${1:deferred}.resolveWith(${2:this}, ${3:args})
+snippet Dstate
+ ${1:deferred}.state()
+snippet Dthen
+ ${1:deferred}.then(${2:doneCallbacks}, ${3:failCallbacks}, ${4:progressCallbacks})
+snippet Dwhen
+ $.when(${1:deferreds})
+snippet data
+ ${1:obj}.data(${2:obj})
+snippet dataa
+ $.data('${1:selector expression}', '${2:key}'${3:, 'value'})
+snippet dblclick
+ ${1:obj}.dblclick (${2:e}) ->
+ ${0:// event handler}
+snippet delay
+ ${1:obj}.delay('${2:slow/400/fast}'${3:, 'queue name'})
+snippet dele
+ ${1:obj}.delegate '${2:selector expression}', '${3:event name}', (${4:e}) ->
+ ${0:// event handler}
+snippet deq
+ ${1:obj}.dequeue(${2:'queue name'})
+snippet deqq
+ $.dequeue('${1:selector expression}'${2:, 'queue name'})
+snippet detach
+ ${1:obj}.detach('${2:selector expression}')
+snippet die
+ ${1:obj}.die(${2:event}, ${3:handler})
+snippet each
+ ${1:obj}.each (index) ->
+ ${0:this.innerHTML = this + " is the element, " + index + " is the position"}
+snippet el
+ $('<${1}/>'${2:, {}})
+snippet eltrim
+ $.trim('${1:string}')
+snippet empty
+ ${1:obj}.empty()
+snippet end
+ ${1:obj}.end()
+snippet eq
+ ${1:obj}.eq(${2:element index})
+snippet error
+ ${1:obj}.error (${2:e}) ->
+ ${0:// event handler}
+snippet eventsmap
+ {
+ :f${0}
+ }
+snippet extend
+ $.extend(${1:true, }${2:target}, ${3:obj})
+snippet fadein
+ ${1:obj}.fadeIn('${2:slow/400/fast}')
+snippet fadeinc
+ ${1:obj}.fadeIn 'slow/400/fast', ->
+ ${0:// callback}
+snippet fadeout
+ ${1:obj}.fadeOut('${2:slow/400/fast}')
+snippet fadeoutc
+ ${1:obj}.fadeOut 'slow/400/fast', ->
+ ${0:// callback}
+snippet fadeto
+ ${1:obj}.fadeTo('${2:slow/400/fast}', ${3:0.5})
+snippet fadetoc
+ ${1:obj}.fadeTo 'slow/400/fast', ${2:0.5}, ->
+ ${0:// callback}
+snippet filter
+ ${1:obj}.filter('${2:selector expression}')
+snippet filtert
+ ${1:obj}.filter (${2:index}) ->
+ ${3}
+snippet find
+ ${1:obj}.find('${2:selector expression}')
+snippet focus
+ ${1:obj}.focus (${2:e}) ->
+ ${0:// event handler}
+snippet focusin
+ ${1:obj}.focusIn (${2:e}) ->
+ ${0:// event handler}
+snippet focusout
+ ${1:obj}.focusOut (${2:e}) ->
+ ${0:// event handler}
+snippet get
+ ${1:obj}.get(${2:element index})
+snippet getjson
+ $.getJSON '${1:mydomain.com/url}',
+ ${2:{ param1: value1 },}
+ (data, textStatus, jqXHR) ->
+ ${0:// success callback}
+snippet getscript
+ $.getScript '${1:mydomain.com/url}', (script, textStatus, jqXHR) ->
+ ${0:// callback}
+snippet grep
+ $.grep(${1:array}, (item, index) >
+ ${2}
+ ${0:, true})
+snippet hasc
+ ${1:obj}.hasClass('${2:className}')
+snippet hasd
+ $.hasData('${0:selector expression}')
+snippet height
+ ${1:obj}.height(${2:integer})
+snippet hide
+ ${1:obj}.hide('${2:slow/400/fast}')
+snippet hidec
+ ${1:obj}.hide '${2:slow/400/fast}', ->
+ ${0:// callback}
+snippet hover
+ ${1:obj}.hover (${2:e}) ->
+ ${3:// event handler}
+ , ($2) ->
+ ${4:// event handler}
+snippet html
+ ${1:obj}.html('${2:Some text and bold!}')
+snippet inarr
+ $.inArray(${1:value}, ${0:array})
+snippet insa
+ ${1:obj}.insertAfter('${2:selector expression}')
+snippet insb
+ ${1:obj}.insertBefore('${2:selector expression}')
+snippet is
+ ${1:obj}.is('${2:selector expression}')
+snippet isarr
+ $.isArray(${1:obj})
+snippet isempty
+ $.isEmptyObject(${1:obj})
+snippet isfunc
+ $.isFunction(${1:obj})
+snippet isnum
+ $.isNumeric(${1:value})
+snippet isobj
+ $.isPlainObject(${1:obj})
+snippet iswin
+ $.isWindow(${1:obj})
+snippet isxml
+ $.isXMLDoc(${1:node})
+snippet jj
+ $('${1:selector}')
+snippet kdown
+ ${1:obj}.keydown (${2:e}) ->
+ ${0:// event handler}
+snippet kpress
+ ${1:obj}.keypress (${2:e}) ->
+ ${0:// event handler}
+snippet kup
+ ${1:obj}.keyup (${2:e}) ->
+ ${0:// event handler}
+snippet last
+ ${1:obj}.last('${1:selector expression}')
+snippet live
+ ${1:obj}.live '${2:events}', (${3:e}) ->
+ ${0:// event handler}
+snippet load
+ ${1:obj}.load (${2:e}) ->
+ ${0:// event handler}
+snippet loadf
+ ${1:obj}.load('${2:mydomain.com/url}',
+ ${2:{ param1: value1 },}
+ (responseText, textStatus, xhr) ->
+ ${0:// success callback}
+ })
+snippet makearray
+ $.makeArray(${0:obj})
+snippet map
+ ${1:obj}.map (${2:index}, ${3:element}) ->
+ ${0:// callback}
+snippet mapp
+ $.map ${1:arrayOrObject}, (${2:value}, ${3:indexOrKey}) ->
+ ${0:// callback}
+snippet merge
+ $.merge(${1:target}, ${0:original})
+snippet mdown
+ ${1:obj}.mousedown (${2:e}) ->
+ ${0:// event handler}
+snippet menter
+ ${1:obj}.mouseenter (${2:e}) ->
+ ${0:// event handler}
+snippet mleave
+ ${1:obj}.mouseleave (${2:e}) ->
+ ${0:// event handler}
+snippet mmove
+ ${1:obj}.mousemove (${2:e}) ->
+ ${0:// event handler}
+snippet mout
+ ${1:obj}.mouseout (${2:e}) ->
+ ${0:// event handler}
+snippet mover
+ ${1:obj}.mouseover (${2:e}) ->
+ ${0:// event handler}
+snippet mup
+ ${1:obj}.mouseup (${2:e}) ->
+ ${0:// event handler}
+snippet next
+ ${1:obj}.next('${2:selector expression}')
+snippet nexta
+ ${1:obj}.nextAll('${2:selector expression}')
+snippet nextu
+ ${1:obj}.nextUntil('${2:selector expression}'${3:, 'filter expression'})
+snippet not
+ ${1:obj}.not('${2:selector expression}')
+snippet off
+ ${1:obj}.off('${2:events}', '${3:selector expression}'${4:, handler})
+snippet offset
+ ${1:obj}.offset()
+snippet offsetp
+ ${1:obj}.offsetParent()
+snippet on
+ ${1:obj}.on '${2:events}', '${3:selector expression}', (${4:e}) ->
+ ${0:// event handler}
+snippet one
+ ${1:obj}.one '${2:event name}', (${3:e}) ->
+ ${0:// event handler}
+snippet outerh
+ ${1:obj}.outerHeight()
+snippet outerw
+ ${1:obj}.outerWidth()
+snippet param
+ $.param(${1:obj})
+snippet parent
+ ${1:obj}.parent('${2:selector expression}')
+snippet parents
+ ${1:obj}.parents('${2:selector expression}')
+snippet parentsu
+ ${1:obj}.parentsUntil('${2:selector expression}'${3:, 'filter expression'})
+snippet parsejson
+ $.parseJSON(${1:data})
+snippet parsexml
+ $.parseXML(${1:data})
+snippet pos
+ ${1:obj}.position()
+snippet prepend
+ ${1:obj}.prepend('${2:Some text and bold!}')
+snippet prependto
+ ${1:obj}.prependTo('${2:selector expression}')
+snippet prev
+ ${1:obj}.prev('${2:selector expression}')
+snippet preva
+ ${1:obj}.prevAll('${2:selector expression}')
+snippet prevu
+ ${1:obj}.prevUntil('${2:selector expression}'${3:, 'filter expression'})
+snippet promise
+ ${1:obj}.promise(${2:'fx'}, ${3:target})
+snippet prop
+ ${1:obj}.prop('${2:property name}')
+snippet proxy
+ $.proxy(${1:function}, ${2:this})
+snippet pushstack
+ ${1:obj}.pushStack(${2:elements})
+snippet queue
+ ${1:obj}.queue(${2:name}${3:, newQueue})
+snippet queuee
+ $.queue(${1:element}${2:, name}${3:, newQueue})
+snippet ready
+ $(() ->
+ ${0}
+ )
+snippet rem
+ ${1:obj}.remove()
+snippet rema
+ ${1:obj}.removeAttr('${2:attribute name}')
+snippet remc
+ ${1:obj}.removeClass('${2:class name}')
+snippet remd
+ ${1:obj}.removeData('${2:key name}')
+snippet remdd
+ $.removeData(${1:element}${2:, 'key name}')
+snippet remp
+ ${1:obj}.removeProp('${2:property name}')
+snippet repa
+ ${1:obj}.replaceAll(${2:target})
+snippet repw
+ ${1:obj}.replaceWith(${2:content})
+snippet reset
+ ${1:obj}.reset (${2:e}) ->
+ ${0:// event handler}
+snippet resize
+ ${1:obj}.resize (${2:e}) ->
+ ${0:// event handler}
+snippet scroll
+ ${1:obj}.scroll (${2:e}) ->
+ ${0:// event handler}
+snippet scrolll
+ ${1:obj}.scrollLeft(${2:value})
+snippet scrollt
+ ${1:obj}.scrollTop(${2:value})
+snippet sdown
+ ${1:obj}.slideDown('${2:slow/400/fast}')
+snippet sdownc
+ ${1:obj}.slideDown('${2:slow/400/fast}', ->
+ ${0:// callback}
+snippet select
+ ${1:obj}.select (${2:e}) ->
+ ${0:// event handler}
+snippet serialize
+ ${1:obj}.serialize()
+snippet serializea
+ ${1:obj}.serializeArray()
+snippet show
+ ${1:obj}.show('${2:slow/400/fast}')
+snippet showc
+ ${1:obj}.show '${2:slow/400/fast}', ->
+ ${0:// callback}
+snippet sib
+ ${1:obj}.siblings('${2:selector expression}')
+snippet size
+ ${1:obj}.size()
+snippet slice
+ ${1:obj}.slice(${2:start}${3:, end})
+snippet stoggle
+ ${1:obj}.slideToggle('${2:slow/400/fast}')
+snippet stop
+ ${1:obj}.stop('${2:queue}', ${3:false}, ${4:false})
+snippet submit
+ ${1:obj}.submit (${2:e}) ->
+ ${0:// event handler}
+snippet sup
+ ${1:obj}.slideUp('${2:slow/400/fast}')
+snippet supc
+ ${1:obj}.slideUp '${2:slow/400/fast}', ->
+ ${0:// callback}
+snippet text
+ ${1:obj}.text(${2:'some text'})
+snippet this
+ $(this)
+snippet toarr
+ ${0:obj}.toArray()
+snippet tog
+ ${1:obj}.toggle (${2:e}) ->
+ ${3:// event handler}
+ , ($2) ->
+ ${4:// event handler}
+ ${0}
+snippet togclass
+ ${1:obj}.toggleClass('${2:class name}')
+snippet togsh
+ ${1:obj}.toggle('${2:slow/400/fast}')
+snippet trig
+ ${1:obj}.trigger('${2:event name}')
+snippet trigh
+ ${1:obj}.triggerHandler('${2:event name}')
+snippet $trim
+ $.trim(${1:str})
+snippet $type
+ $.type(${1:obj})
+snippet unbind
+ ${1:obj}.unbind('${2:event name}')
+snippet undele
+ ${1:obj}.undelegate(${2:selector expression}, ${3:event}, ${4:handler})
+snippet uniq
+ $.unique(${1:array})
+snippet unload
+ ${1:obj}.unload (${2:e}) ->
+ ${0:// event handler}
+snippet unwrap
+ ${1:obj}.unwrap()
+snippet val
+ ${1:obj}.val('${2:text}')
+snippet width
+ ${1:obj}.width(${2:integer})
+snippet wrap
+ ${1:obj}.wrap('${2:<div class="extra-wrapper"></div>}')
diff --git a/snippets/css.snippets b/snippets/css.snippets
index 8886643a4..c4a74dec9 100644
--- a/snippets/css.snippets
+++ b/snippets/css.snippets
@@ -965,3 +965,23 @@ snippet z:a
z-index: auto;
snippet zoo
zoom: 1;
+snippet :h
+ :hover
+snippet :fc
+ :first-child
+snippet :lc
+ :last-child
+snippet :nc
+ :nth-child(${0})
+snippet :nlc
+ :nth-last-child(${0})
+snippet :oc
+ :only-child
+snippet :a
+ :after
+snippet :b
+ :before
+snippet ::a
+ ::after
+snippet ::b
+ ::before
diff --git a/snippets/django.snippets b/snippets/django.snippets
index cad80eb24..e2a8d6d09 100644
--- a/snippets/django.snippets
+++ b/snippets/django.snippets
@@ -10,6 +10,10 @@
snippet auto
${1:FIELDNAME} = models.AutoField(${0})
+snippet bigint
+ ${1:FIELDNAME} = models.BigIntegerField(${0})
+snippet binary
+ ${1:FIELDNAME} = models.BinaryField(${0})
snippet bool
${1:FIELDNAME} = models.BooleanField(${0:default=True})
snippet char
@@ -80,7 +84,7 @@ snippet model
def __unicode__(self):
${5}
- def save(self, force_insert=False, force_update=False):
+ def save(self, *args, **kwargs):
${6}
@models.permalink
diff --git a/snippets/elixir.snippets b/snippets/elixir.snippets
index 54aa180b3..077cf0310 100644
--- a/snippets/elixir.snippets
+++ b/snippets/elixir.snippets
@@ -6,119 +6,95 @@ snippet if if .. do .. end
if ${1} do
${0}
end
-
snippet if if .. do: ..
if ${1:condition}, do: ${0}
-
snippet ife if .. do .. else .. end
if ${1:condition} do
${2}
else
${0}
end
-
snippet ife if .. do: .. else:
if ${1:condition}, do: ${2}, else: ${0}
-
snippet unless unless .. do .. end
unless ${1} do
${0}
end
-
snippet unless unless .. do: ..
unless ${1:condition}, do: ${0}
-
snippet unlesse unless .. do .. else .. end
unless ${1:condition} do
${2}
else
${0}
end
-
snippet unlesse unless .. do: .. else:
unless ${1:condition}, do: ${2}, else: ${0}
-
snippet cond
cond do
${1} ->
${0}
end
-
snippet case
case ${1} do
${2} ->
${0}
end
-
+snippet df
+ def ${1:name}, do: ${2}
snippet def
def ${1:name} do
${0}
end
-
snippet defim
defimpl ${1:protocol_name}, for: ${2:data_type} do
${0}
end
-
snippet defma
defmacro ${1:name} do
${0}
end
-
snippet defmo
defmodule ${1:module_name} do
${0}
end
-
snippet defp
defp ${1:name} do
${0}
end
-
snippet defpr
defprotocol ${1:name}, [${0:function}]
-
snippet defr
defrecord ${1:record_name}, ${0:fields}
-
snippet doc
@doc """
${0}
"""
-
snippet fn
fn(${1:args}) -> ${0} end
-
snippet fun
- function do
- ${0}
- end
-
+ function do
+ ${0}
+ end
snippet mdoc
@moduledoc """
${0}
"""
-
snippet rec
receive do
${1} ->
${0}
end
-
snippet req
require ${0:module_name}
-
snippet imp
import ${0:module_name}
-
snippet ali
alias ${0:module_name}
-
snippet test
test "${1:test_name}" do
${0}
end
-
snippet try try .. rescue .. end
try do
${1}
diff --git a/snippets/erlang.snippets b/snippets/erlang.snippets
index 799d7f57c..2a0d1a4c3 100644
--- a/snippets/erlang.snippets
+++ b/snippets/erlang.snippets
@@ -18,6 +18,9 @@ snippet exp
# include directive
snippet inc
-include("${1:file}").
+# include_lib directive
+snippet incl
+ -include_lib("${1:lib}/include/${1}.hrl").${2}
# behavior directive
snippet beh
-behaviour(${1:behaviour}).
@@ -117,8 +120,12 @@ snippet gen_server
]).
%% gen_server callbacks
- -export([init/1, handle_call/3, handle_cast/2, handle_info/2,
- terminate/2, code_change/3]).
+ -export([init/1,
+ handle_call/3,
+ handle_cast/2,
+ handle_info/2,
+ terminate/2,
+ code_change/3]).
-define(SERVER, ?MODULE).
@@ -154,6 +161,320 @@ snippet gen_server
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
+ %%%===================================================================
+ %%% Internal functions
+ %%%===================================================================
+# OTP gen_fsm
+snippet gen_fsm
+ -module(${0:`vim_snippets#Filename('', 'my')`}).
+
+ -behaviour(gen_fsm).
+
+ %% API
+ -export([start_link/0]).
+
+ %% gen_fsm callbacks
+ -export([init/1,
+ state_name/2,
+ state_name/3,
+ handle_event/3,
+ handle_sync_event/4,
+ handle_info/3,
+ terminate/3,
+ code_change/4]).
+
+ -record(state, {}).
+
+ %%%===================================================================
+ %%% API
+ %%%===================================================================
+
+ %%--------------------------------------------------------------------
+ %% @doc
+ %% Creates a gen_fsm process which calls Module:init/1 to
+ %% initialize. To ensure a synchronized start-up procedure, this
+ %% function does not return until Module:init/1 has returned.
+ %%
+ %% @spec start_link() -> {ok, Pid} | ignore | {error, Error}
+ %% @end
+ %%--------------------------------------------------------------------
+ start_link() ->
+ gen_fsm:start_link({local, ?MODULE}, ?MODULE, [], []).
+
+ %%%===================================================================
+ %%% gen_fsm callbacks
+ %%%===================================================================
+
+ %%--------------------------------------------------------------------
+ %% @private
+ %% @doc
+ %% Whenever a gen_fsm is started using gen_fsm:start/[3,4] or
+ %% gen_fsm:start_link/[3,4], this function is called by the new
+ %% process to initialize.
+ %%
+ %% @spec init(Args) -> {ok, StateName, State} |
+ %% {ok, StateName, State, Timeout} |
+ %% ignore |
+ %% {stop, StopReason}
+ %% @end
+ %%--------------------------------------------------------------------
+ init([]) ->
+ {ok, state_name, #state{}}.
+
+ %%--------------------------------------------------------------------
+ %% @private
+ %% @doc
+ %% There should be one instance of this function for each possible
+ %% state name. Whenever a gen_fsm receives an event sent using
+ %% gen_fsm:send_event/2, the instance of this function with the same
+ %% name as the current state name StateName is called to handle
+ %% the event. It is also called if a timeout occurs.
+ %%
+ %% @spec state_name(Event, State) ->
+ %% {next_state, NextStateName, NextState} |
+ %% {next_state, NextStateName, NextState, Timeout} |
+ %% {stop, Reason, NewState}
+ %% @end
+ %%--------------------------------------------------------------------
+ state_name(_Event, State) ->
+ {next_state, state_name, State}.
+
+ %%--------------------------------------------------------------------
+ %% @private
+ %% @doc
+ %% There should be one instance of this function for each possible
+ %% state name. Whenever a gen_fsm receives an event sent using
+ %% gen_fsm:sync_send_event/[2,3], the instance of this function with
+ %% the same name as the current state name StateName is called to
+ %% handle the event.
+ %%
+ %% @spec state_name(Event, From, State) ->
+ %% {next_state, NextStateName, NextState} |
+ %% {next_state, NextStateName, NextState, Timeout} |
+ %% {reply, Reply, NextStateName, NextState} |
+ %% {reply, Reply, NextStateName, NextState, Timeout} |
+ %% {stop, Reason, NewState} |
+ %% {stop, Reason, Reply, NewState}
+ %% @end
+ %%--------------------------------------------------------------------
+ state_name(_Event, _From, State) ->
+ Reply = ok,
+ {reply, Reply, state_name, State}.
+
+ %%--------------------------------------------------------------------
+ %% @private
+ %% @doc
+ %% Whenever a gen_fsm receives an event sent using
+ %% gen_fsm:send_all_state_event/2, this function is called to handle
+ %% the event.
+ %%
+ %% @spec handle_event(Event, StateName, State) ->
+ %% {next_state, NextStateName, NextState} |
+ %% {next_state, NextStateName, NextState, Timeout} |
+ %% {stop, Reason, NewState}
+ %% @end
+ %%--------------------------------------------------------------------
+ handle_event(_Event, StateName, State) ->
+ {next_state, StateName, State}.
+
+ %%--------------------------------------------------------------------
+ %% @private
+ %% @doc
+ %% Whenever a gen_fsm receives an event sent using
+ %% gen_fsm:sync_send_all_state_event/[2,3], this function is called
+ %% to handle the event.
+ %%
+ %% @spec handle_sync_event(Event, From, StateName, State) ->
+ %% {next_state, NextStateName, NextState} |
+ %% {next_state, NextStateName, NextState, Timeout} |
+ %% {reply, Reply, NextStateName, NextState} |
+ %% {reply, Reply, NextStateName, NextState, Timeout} |
+ %% {stop, Reason, NewState} |
+ %% {stop, Reason, Reply, NewState}
+ %% @end
+ %%--------------------------------------------------------------------
+ handle_sync_event(_Event, _From, StateName, State) ->
+ Reply = ok,
+ {reply, Reply, StateName, State}.
+
+ %%--------------------------------------------------------------------
+ %% @private
+ %% @doc
+ %% This function is called by a gen_fsm when it receives any
+ %% message other than a synchronous or asynchronous event
+ %% (or a system message).
+ %%
+ %% @spec handle_info(Info,StateName,State)->
+ %% {next_state, NextStateName, NextState} |
+ %% {next_state, NextStateName, NextState, Timeout} |
+ %% {stop, Reason, NewState}
+ %% @end
+ %%--------------------------------------------------------------------
+ handle_info(_Info, StateName, State) ->
+ {next_state, StateName, State}.
+
+ %%--------------------------------------------------------------------
+ %% @private
+ %% @doc
+ %% This function is called by a gen_fsm when it is about to
+ %% terminate. It should be the opposite of Module:init/1 and do any
+ %% necessary cleaning up. When it returns, the gen_fsm terminates with
+ %% Reason. The return value is ignored.
+ %%
+ %% @spec terminate(Reason, StateName, State) -> void()
+ %% @end
+ %%--------------------------------------------------------------------
+ terminate(_Reason, _StateName, _State) ->
+ ok.
+
+ %%--------------------------------------------------------------------
+ %% @private
+ %% @doc
+ %% Convert process state when code is changed
+ %%
+ %% @spec code_change(OldVsn, StateName, State, Extra) ->
+ %% {ok, StateName, NewState}
+ %% @end
+ %%--------------------------------------------------------------------
+ code_change(_OldVsn, StateName, State, _Extra) ->
+ {ok, StateName, State}.
+
+ %%%===================================================================
+ %%% Internal functions
+ %%%===================================================================
+# OTP gen_event
+snippet gen_event
+ -module(${0:`vim_snippets#Filename('', 'my')`}).
+
+ -behaviour(gen_event).
+
+ %% API
+ -export([start_link/0,
+ add_handler/2]).
+
+ %% gen_event callbacks
+ -export([init/1,
+ handle_event/2,
+ handle_call/2,
+ handle_info/2,
+ terminate/2,
+ code_change/3]).
+
+ -record(state, {}).
+
+ %%%===================================================================
+ %%% gen_event callbacks
+ %%%===================================================================
+
+ %%--------------------------------------------------------------------
+ %% @doc
+ %% Creates an event manager
+ %%
+ %% @spec start_link() -> {ok, Pid} | {error, Error}
+ %% @end
+ %%--------------------------------------------------------------------
+ start_link() ->
+ gen_event:start_link({local, ?MODULE}).
+
+ %%--------------------------------------------------------------------
+ %% @doc
+ %% Adds an event handler
+ %%
+ %% @spec add_handler(Handler, Args) -> ok | {'EXIT', Reason} | term()
+ %% @end
+ %%--------------------------------------------------------------------
+ add_handler(Handler, Args) ->
+ gen_event:add_handler(?MODULE, Handler, Args).
+
+ %%%===================================================================
+ %%% gen_event callbacks
+ %%%===================================================================
+
+ %%--------------------------------------------------------------------
+ %% @private
+ %% @doc
+ %% Whenever a new event handler is added to an event manager,
+ %% this function is called to initialize the event handler.
+ %%
+ %% @spec init(Args) -> {ok, State}
+ %% @end
+ %%--------------------------------------------------------------------
+ init([]) ->
+ {ok, #state{}}.
+
+ %%--------------------------------------------------------------------
+ %% @private
+ %% @doc
+ %% Whenever an event manager receives an event sent using
+ %% gen_event:notify/2 or gen_event:sync_notify/2, this function is
+ %% called for each installed event handler to handle the event.
+ %%
+ %% @spec handle_event(Event, State) ->
+ %% {ok, State} |
+ %% {swap_handler, Args1, State1, Mod2, Args2} |
+ %% remove_handler
+ %% @end
+ %%--------------------------------------------------------------------
+ handle_event(_Event, State) ->
+ {ok, State}.
+
+ %%--------------------------------------------------------------------
+ %% @private
+ %% @doc
+ %% Whenever an event manager receives a request sent using
+ %% gen_event:call/3,4, this function is called for the specified
+ %% event handler to handle the request.
+ %%
+ %% @spec handle_call(Request, State) ->
+ %% {ok, Reply, State} |
+ %% {swap_handler, Reply, Args1, State1, Mod2, Args2} |
+ %% {remove_handler, Reply}
+ %% @end
+ %%--------------------------------------------------------------------
+ handle_call(_Request, State) ->
+ Reply = ok,
+ {ok, Reply, State}.
+
+ %%--------------------------------------------------------------------
+ %% @private
+ %% @doc
+ %% This function is called for each installed event handler when
+ %% an event manager receives any other message than an event or a
+ %% synchronous request (or a system message).
+ %%
+ %% @spec handle_info(Info, State) ->
+ %% {ok, State} |
+ %% {swap_handler, Args1, State1, Mod2, Args2} |
+ %% remove_handler
+ %% @end
+ %%--------------------------------------------------------------------
+ handle_info(_Info, State) ->
+ {ok, State}.
+
+ %%--------------------------------------------------------------------
+ %% @private
+ %% @doc
+ %% Whenever an event handler is deleted from an event manager, this
+ %% function is called. It should be the opposite of Module:init/1 and
+ %% do any necessary cleaning up.
+ %%
+ %% @spec terminate(Reason, State) -> void()
+ %% @end
+ %%--------------------------------------------------------------------
+ terminate(_Reason, _State) ->
+ ok.
+
+ %%--------------------------------------------------------------------
+ %% @private
+ %% @doc
+ %% Convert process state when code is changed
+ %%
+ %% @spec code_change(OldVsn, State, Extra) -> {ok, NewState}
+ %% @end
+ %%--------------------------------------------------------------------
+ code_change(_OldVsn, State, _Extra) ->
+ {ok, State}.
+
%%%===================================================================
%%% Internal functions
%%%===================================================================
diff --git a/snippets/eruby.snippets b/snippets/eruby.snippets
index 95418350d..bc13fcbb0 100644
--- a/snippets/eruby.snippets
+++ b/snippets/eruby.snippets
@@ -107,6 +107,8 @@ snippet ntc
<%= number_to_currency(${1}) %>
snippet ofcfs
<%= options_from_collection_for_select ${1:collection}, ${2:value_method}, ${3:text_method}, ${0:selected_value} %>
+snippet ofs
+ <%= options_for_select ${1:collection}, ${2:value_method} %>
snippet rf
<%= render :file => "${1:file}"${0} %>
snippet rt
diff --git a/snippets/go.snippets b/snippets/go.snippets
index 03f7649d8..8623eda28 100644
--- a/snippets/go.snippets
+++ b/snippets/go.snippets
@@ -1,8 +1,17 @@
-# variables
+# shorthand variable declaration
snippet v
${1} := ${2}
+# variable initialization
snippet vr
+ var ${1:t} ${0:string}
+# variable declaration
+snippet var
var ${1} ${2} = ${3}
+# variables declaration
+snippet vars
+ var (
+ ${1} ${2} = ${3}
+ )
# append
snippet ap
append(${1:slice}, ${0:value})
@@ -213,9 +222,6 @@ snippet sp
# true
snippet t
true
-# variable declaration
-snippet v
- var ${1:t} ${0:string}
# goroutine named function
snippet g
go ${1:funcName}(${0})
@@ -224,3 +230,15 @@ snippet ga
go func(${1} ${2:type}) {
${3:/* code */}
}(${0})
+snippet test test function
+ func Test${1:name}(t *testing.T) {
+ ${2}
+ }
+ ${0}
+snippet bench benchmark function
+ func Benchmark${1:name}(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ ${2}
+ }
+ }
+ ${0}
diff --git a/snippets/haskell.snippets b/snippets/haskell.snippets
index f5f159845..ddb89d9ab 100644
--- a/snippets/haskell.snippets
+++ b/snippets/haskell.snippets
@@ -1,5 +1,7 @@
snippet lang
{-# LANGUAGE ${0:OverloadedStrings} #-}
+snippet haddock
+ {-# OPTIONS_HADDOCK ${0:hide} #-}
snippet info
-- |
-- Module : ${1:Module.Namespace}
diff --git a/snippets/html.snippets b/snippets/html.snippets
index f25e1bc73..5620caae0 100644
--- a/snippets/html.snippets
+++ b/snippets/html.snippets
@@ -147,6 +147,8 @@ snippet a:ext
${0:$1}
snippet a:mail
${0:email me}
+snippet ac
+ ${0:`@+`}
snippet abbr
${0}
snippet address
@@ -361,15 +363,15 @@ snippet footer#
${0}
snippet form
-
snippet form.
-
snippet form#
-
snippet h1
@@ -449,7 +451,8 @@ snippet html5
-
+
+
${1:`substitute(vim_snippets#Filename('', 'Page Title'), '^.', '\u&', '')`}
${2:meta}
@@ -749,15 +752,15 @@ snippet summary
snippet sup
${0}
snippet table
-
+
snippet table.
-
+
snippet table#
-
+
snippet tbody
diff --git a/snippets/html_minimal.snippets b/snippets/html_minimal.snippets
index 308f44dfe..43e5d4a4e 100644
--- a/snippets/html_minimal.snippets
+++ b/snippets/html_minimal.snippets
@@ -63,12 +63,10 @@ snippet img
snippet css_file
snippet css_block
-
-
-
+
snippet script_block
snippet script_file
-
+
diff --git a/snippets/jade.snippets b/snippets/jade.snippets
new file mode 100644
index 000000000..55f0af7bf
--- /dev/null
+++ b/snippets/jade.snippets
@@ -0,0 +1,18 @@
+# Angular HTML
+snippet rep
+ div(ng-repeat='${1} in ${2}')
+
+snippet repf
+ div(ng-repeat='${1} in ${2}' | ${3})
+
+snippet repi
+ div(ng-repeat='${1} in ${2}' track by $index)
+
+snippet hide
+ div(ng-hide='${1}')
+
+snippet show
+ div(ng-show='${1}')
+
+snippet if
+ div(ng-if='${1}')
diff --git a/snippets/java.snippets b/snippets/java.snippets
index 1595ffc1a..e0965f1b1 100644
--- a/snippets/java.snippets
+++ b/snippets/java.snippets
@@ -1,10 +1,10 @@
## Access Modifiers
snippet po
- protected
+ protected ${0}
snippet pu
- public
+ public ${0}
snippet pr
- private
+ private ${0}
##
## Annotations
snippet before
@@ -25,7 +25,7 @@ snippet oo
##
## Basic Java packages and import
snippet im
- import
+ import ${0}
snippet j.b
java.beans.
snippet j.i
@@ -39,17 +39,17 @@ snippet j.u
##
## Class
snippet cl
- class ${1:`vim_snippets#Filename("", "untitled")`} ${0}
+ class ${1:`vim_snippets#Filename("$1", "untitled")`} ${0}
snippet in
- interface ${1:`vim_snippets#Filename("", "untitled")`} ${2:extends Parent}
+ interface ${1:`vim_snippets#Filename("$1", "untitled")`} ${2:extends Parent}
snippet tc
- public class ${1:`vim_snippets#Filename()`} extends ${0:TestCase}
+ public class ${1:`vim_snippets#Filename("$1")`} extends ${0:TestCase}
##
## Class Enhancements
snippet ext
- extends
+ extends ${0}
snippet imp
- implements
+ implements ${0}
##
## Comments
snippet /*
@@ -89,15 +89,40 @@ snippet m
snippet v
${1:String} ${2:var}${3: = null}${4};
##
+## Declaration for ArrayList
+snippet d.al
+ List<${1:Object}> ${2:list} = new ArrayList<$1>();${0}
+## Declaration for HashMap
+snippet d.hm
+ Map<${1:Object}, ${2:Object}> ${3:map} = new HashMap<$1, $2>();${0}
+## Declaration for HashSet
+snippet d.hs
+ Set<${1:Object}> ${2:set} = new HashSet<$1>();${0}
+## Declaration for Stack
+snippet d.st
+ Stack<${1:Object}> ${2:stack} = new Stack<$1>();${0}
+##
+## Singleton Pattern
+snippet singlet
+ private static class Holder {
+ private static final ${1:`vim_snippets#Filename("$1")`} INSTANCE = new $1();
+ }
+
+ private $1() { }
+
+ private static $1 getInstance() {
+ return Holder.INSTANCE;
+ }
+##
## Enhancements to Methods, variables, classes, etc.
snippet ab
- abstract
+ abstract ${0}
snippet fi
- final
+ final ${0}
snippet st
- static
+ static ${0}
snippet sy
- synchronized
+ synchronized ${0}
##
## Error Methods
snippet err
@@ -113,9 +138,9 @@ snippet as
snippet ca
catch(${1:Exception} ${2:e}) ${0}
snippet thr
- throw
+ throw ${0}
snippet ths
- throws
+ throws ${0}
snippet try
try {
${0}
@@ -144,7 +169,7 @@ snippet @au
snippet @br
@brief ${0:Description}
snippet @fi
- @file ${0:`vim_snippets#Filename()`}.java
+ @file ${0:`vim_snippets#Filename("$1")`}.java
snippet @pa
@param ${0:param}
snippet @re
@@ -206,7 +231,7 @@ snippet get
##
## Terminate Methods or Loops
snippet re
- return
+ return ${0}
snippet br
break;
##
diff --git a/snippets/javascript-jquery.snippets b/snippets/javascript/javascript-jquery.snippets
similarity index 100%
rename from snippets/javascript-jquery.snippets
rename to snippets/javascript/javascript-jquery.snippets
diff --git a/snippets/javascript.d3.snippets b/snippets/javascript/javascript.d3.snippets
similarity index 100%
rename from snippets/javascript.d3.snippets
rename to snippets/javascript/javascript.d3.snippets
diff --git a/snippets/javascript.snippets b/snippets/javascript/javascript.snippets
similarity index 100%
rename from snippets/javascript.snippets
rename to snippets/javascript/javascript.snippets
diff --git a/snippets/javascript_jquery.snippets b/snippets/javascript_jquery.snippets
deleted file mode 120000
index 9b4966dbb..000000000
--- a/snippets/javascript_jquery.snippets
+++ /dev/null
@@ -1 +0,0 @@
-javascript-jquery.snippets
\ No newline at end of file
diff --git a/snippets/php.snippets b/snippets/php.snippets
index 5af980112..d7b21eb5c 100644
--- a/snippets/php.snippets
+++ b/snippets/php.snippets
@@ -260,6 +260,10 @@ snippet if
if (${1:/* condition */}) {
${0}
}
+snippet ifn
+ if (!${1:/* condition */}) {
+ ${2}
+ }
snippet ifil
${0}
@@ -412,3 +416,185 @@ snippet static_var
if (is_null($$1)){
$$1 = ${2};
}
+
+snippet CSVWriter
+ f =
+ is_string($file_or_handle)
+ ? fopen($file_or_handle, $mode)
+ : $file_or_handle;
+
+ $this->fputcsv_args = array($this->f, null, $sep, $quot);
+
+ if (!$this->f) throw new Exception('bad file descriptor');
+ }
+
+ public function write($row){
+ $this->fputcsv_args[1] =& $row;
+ call_user_func_array('fputcsv', $this->fputcsv_args);
+ }
+
+ public function close(){
+ if (!is_null($this->f))
+ fclose($this->f);
+ $this->f = null;
+ }
+
+ public function __destruct(){
+ $this->close();
+ }
+
+ }
+
+snippet CSVIterator
+
+ // http://snipplr.com/view.php?codeview&id=1986 // modified
+ class CSVIterator implements Iterator
+ {
+ private $f;
+ private $curr;
+ private $rowCounter;
+
+ /* opts keys:
+ * row_size
+ * escape
+ * enclosure
+ * delimiter
+ */
+ public function __construct( $file_or_handle, $opts = array(4096, ',') )
+ {
+ $d = function($n) use(&$opts){ return isset($opts[$n]) ? $opts[$n] : false; };
+
+ $this->combine = $d('combine');
+ $this->headers = $d('headers');
+ $this->headerCheckFunction = $d('header_check_function');
+
+ $this->f =
+ is_string($file_or_handle)
+ ? fopen( $file_or_handle, 'r' )
+ : $file_or_handle;
+ if (!$this->f) throw new Exception('bad file descriptor');
+ $this->fgetcsv_args = array(
+ $this->f,
+ isset($opts['row_size']) ? $opts['row_size'] : 4096,
+ isset($opts['delimiter']) ? $opts['delimiter'] : ',',
+ isset($opts['enclosure']) ? $opts['enclosure'] : '"',
+ isset($opts['escape']) ? $opts['escape'] : '\\',
+ );
+ $this->start();
+ }
+
+ protected function readRow(){
+ $this->curr = call_user_func_array('fgetcsv', $this->fgetcsv_args );
+ $this->rowCounter++;
+ if ($this->rowCounter == 1){
+ $this->processHeader();
+ } elseif ($this->curr) {
+ $this->processRow();
+ }
+ }
+
+ public function processHeader(){
+ if ($this->headers || $this->combine){
+ $this->header = $this->curr;
+ if ($this->headerCheckFunction){
+ $f = $this->headerCheckFunction;
+ $f($this->header);
+ }
+ $this->readRow();
+ }
+ }
+
+ public function processRow(){
+ if ($this->combine)
+ $this->curr = array_combine($this->header, $this->curr);
+ }
+
+ public function start(){
+ $this->rowCounter = 0;
+ rewind( $this->f );
+ $this->readRow();
+ }
+
+ public function rewind()
+ {
+ $this->start();
+ }
+
+ public function current()
+ {
+ $curr = $this->curr;
+ $this->readRow();
+ return $curr;
+ }
+
+ public function key()
+ {
+ return $this->rowCounter;
+ }
+
+ public function next()
+ {
+ return $this->curr;
+ }
+
+ public function valid(){
+ if( !$this->next() )
+ {
+ fclose( $this->f );
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ } // end class
+
+snippet is
+ isset($1{VISUAL})
+
+# phpunit
+snippet ase
+ $this->assertEquals(${1:expected}, ${2:actual});
+
+snippet asne
+ $this->assertNotEquals(${1:expected}, ${2:actual});
+
+snippet asf
+ $this->assertFalse(${1:Something});
+
+snippet ast
+ $this->assertTrue(${1:Something});
+
+snippet asfex
+ $this->assertFileExists(${1:path/to/file});
+
+snippet asfnex
+ $this->assertFileNotExists(${1:path/to/file});
+
+snippet ascon
+ $this->assertContains(${1:Search Value}, ${2:Array or Iterator});
+
+snippet ashk
+ $this->assertArrayHasKey(${1:key}, ${2:array});
+
+snippet asnhk
+ this->assertArrayNotHasKey(${1:value}, ${2:array});
+
+snippet ascha
+ $this->assertClassHasAttribute('${1:Attribute Name}', '${2:ClassName}');
+
+snippet asi
+ $this->assertInstanceOf(${1:expected}, ${2:actual});
+
+snippet tc
+ public function test${1:name_of_the_test}()
+ {
+ ${0:code}
+ }
+
diff --git a/snippets/puppet.snippets b/snippets/puppet.snippets
index d35608ddf..a4fdf19fc 100644
--- a/snippets/puppet.snippets
+++ b/snippets/puppet.snippets
@@ -90,7 +90,7 @@ snippet class
${0}
}
snippet node
- node "${1:`vim_snippets#Filename('', 'fqdn')`}" {
+ node '${1:`vim_snippets#Filename('', 'fqdn')`}' {
${0}
}
snippet case
@@ -122,99 +122,99 @@ snippet [
snippet >
${1} => ${0}
snippet p:
- "puppet://puppet/${1:module name}/${0:file name}"
+ 'puppet://puppet/${1:module name}/${0:file name}'
#
# Functions
snippet alert
- alert("${1:message}")
+ alert('${1:message}')
snippet crit
- crit("${1:message}")
+ crit('${1:message}')
snippet debug
- debug("${1:message}")
+ debug('${1:message}')
snippet defined
- defined(${1:Resource}["${2:name}"])
+ defined(${1:Resource}['${2:name}'])
snippet emerg
- emerg("${1:message}")
+ emerg('${1:message}')
snippet extlookup Simple extlookup
- extlookup("${1:variable}")
+ extlookup('${1:variable}')
snippet extlookup Extlookup with defaults
- extlookup("${1:variable}", "${2:default}")
+ extlookup('${1:variable}', '${2:default}')
snippet extlookup Extlookup with defaults and custom data file
- extlookup("${1:variable}", "${2:default}", "${3:data source}")
+ extlookup('${1:variable}', '${2:default}', '${3:data source}')
snippet fail
- fail("${1:message}")
+ fail('${1:message}')
snippet info
- info("${1:message}")
+ info('${1:message}')
snippet inline_template
- inline_template("<%= ${1} %>")
+ inline_template('<%= ${1} %>')
snippet notice
- notice("${1:message}")
+ notice('${1:message}')
snippet realize
realize(${1:Resource}[${2:name}])
snippet regsubst
- regsubst(${1:hay stack}, ${2:needle}, "${3:replacement}")
+ regsubst(${1:hay stack}, ${2:needle}, '${3:replacement}')
snippet inc
include ${1:classname}
snippet split
- split(${1:hay stack}, "${2:patten}")
+ split(${1:hay stack}, '${2:patten}')
snippet versioncmp
- versioncmp("${1:version}", "${2:version}")
+ versioncmp('${1:version}', '${2:version}')
snippet warning
- warning("${1:message}")
+ warning('${1:message}')
#
# Types
snippet cron
- cron{ "${1:name}":
- command => "${2}",
- user => "${3:root}",
- ${4} => ${0}
+ cron { '${1:name}':
+ command => '${2}',
+ user => '${3:root}',
+ ${4} => ${0},
}
snippet exec
- exec{ "${1:name}":
- command => "${2:$1}",
- user => "${3:root}",
- ${4} => ${0}
+ exec { '${1:name}':
+ command => '${2:$1}',
+ user => '${3:root}',
+ ${4} => ${0},
}
snippet user
- user{ "${1:user}":
- comment => "${2:$1}",
- ensure => present,
- managehome => true,
- home => "${0:/home/$1}"
+ user { '${1:user}':
+ ensure => present,
+ comment => '${2:$1}',
+ managehome => true,
+ home => '${0:/home/$1}',
}
snippet group
- group{ "${1:group}":
- ensure => ${0:present}
+ group { '${1:group}':
+ ensure => ${0:present},
}
snippet host
- host{ "${1:hostname}":
- ip => ${0:127.0.0.1}
+ host { '${1:hostname}':
+ ip => ${0:127.0.0.1},
}
snippet mailalias
- mailalias{ "${1:localpart}":
- recipient => "${0:recipient}"
+ mailalias { '${1:localpart}':
+ recipient => '${0:recipient}',
}
snippet mount
- mount{ "${1:destination path}":
+ mount { '${1:destination path}':
ensure => ${2:mounted},
- device => "${0:device name or path}"
+ device => '${0:device name or path}',
}
snippet package
- package{ "${1:package name}":
- ensure => ${0:present}
+ package { '${1:package name}':
+ ensure => ${0:present},
}
snippet yumrepo
- yumrepo{ "${1:repo name}":
- descr => "${2:$1}",
- enabled => ${0:1}
+ yumrepo { '${1:repo name}':
+ Descr => '${2:$1}',
+ enabled => ${0:1},
}
snippet define
@@ -223,14 +223,22 @@ snippet define
}
snippet service
- service{ "${1:service}":
- enable => ${2:true},
- ensure => ${0:running},
- hasstatus => true,
+ service { '${1:service}' :
+ ensure => running,
+ enable => true,
+ require => [ Package['${2:package}'], File['${3:file}'], ],
+ subscribe => [ File['${4:configfile1}'], File['${5:configfile2}'], Package['${6:package}'], ],
}
snippet file
- file{ "${1:path}":
- ${2} => ${0}
+ file { '${1:filename}' :
+ ensure => ${2:present},
+ owner => '${3:root}',
+ group => '${4:root}',
+ mode => '${5:0644}',
+ source => 'puppet:///modules/${6:module}/${7:source}',
+ content => template('/etc/puppet/templates/${8:template}'),
+ alias => '${9:alias}',
+ require => [ Package['${10:package}'], File['${11:file}'], ],
}
diff --git a/snippets/python.snippets b/snippets/python.snippets
index 638a9c4b8..c221f466e 100644
--- a/snippets/python.snippets
+++ b/snippets/python.snippets
@@ -1,5 +1,6 @@
snippet #!
#!/usr/bin/env python
+ # -*- coding: utf-8 -*-
snippet imp
import ${0:module}
snippet uni
@@ -140,6 +141,9 @@ snippet "
"""
${0:doc}
"""
+# assertions
+snippet a=
+ self.assertEqual(${0}, ${1})
# test function/method
snippet test
def test_${1:description}(${2:`indent('.') ? 'self' : ''`}):
@@ -197,3 +201,10 @@ snippet epydoc
@raise e: ${0: Description}
"""
+snippet dol
+ def ${1:__init__}(self, *args, **kwargs):
+ super(${0:ClassName}, self).$1(*args, **kwargs)
+snippet kwg
+ self.${1:var_name} = kwargs.get('$1', ${2:None})
+snippet lkwg
+ ${1:var_name} = kwargs.get('$1', ${2:None})
diff --git a/snippets/r.snippets b/snippets/r.snippets
index c7ca5acae..7bdeeec05 100644
--- a/snippets/r.snippets
+++ b/snippets/r.snippets
@@ -23,9 +23,19 @@ snippet ei
${0}
}
+# loops
+snippet wh
+ while(${1}) {
+ ${2}
+ }
+snippet for
+ for (${1:item} in ${2:list}) {
+ ${3}
+ }
+
# functions
snippet fun
- ${1:name} = function (${2:variables}) {
+ ${1:name} <- function (${2:variables}) {
${0}
}
snippet ret
@@ -39,7 +49,7 @@ snippet c
snippet li
list(${0:items})
snippet mat
- matrix(${1:data}, nrow=${2:rows}, ncol=${0:cols})
+ matrix(${1:data}, nrow = ${2:rows}, ncol = ${0:cols})
# apply functions
snippet apply
@@ -100,7 +110,7 @@ snippet pl
snippet ggp
ggplot(${1:data}, aes(${0:aesthetics}))
snippet img
- ${1:(jpeg,bmp,png,tiff)}(filename="${2:filename}", width=${3}, height=${4}, unit="${5}")
+ ${1:(jpeg,bmp,png,tiff)}(filename = '${2:filename}', width = ${3}, height = ${4}, unit = '${5}')
${0:plot}
dev.off()
diff --git a/snippets/ruby.snippets b/snippets/ruby.snippets
index cbfc85ee5..5d9c01ea3 100644
--- a/snippets/ruby.snippets
+++ b/snippets/ruby.snippets
@@ -58,6 +58,12 @@ snippet deft
def test_${1:case_name}
${0}
end
+snippet descendants
+ class Class
+ def descendants
+ ObjectSpace.each_object(::Class).select {|klass| klass < self }
+ end
+ end
snippet if
if ${1:condition}
${0}
@@ -168,7 +174,7 @@ snippet ana
accepts_nested_attributes_for :${0:association}
# ivc == instance variable cache
snippet ivc
- @${1:variable_name} ||= ${0:chached_value}
+ @${1:variable_name} ||= ${0:cached_value}
# include Enumerable
snippet Enum
include Enumerable
@@ -473,6 +479,8 @@ snippet asne
assert_not_equal ${1:unexpected}, ${2:actual}
snippet asid
assert_in_delta ${1:expected_float}, ${2:actual_float}, ${3:2 ** -20}
+snippet asi
+ assert_includes ${1:collection}, ${2:object}
snippet asio
assert_instance_of ${1:ExpectedClass}, ${2:actual_instance}
snippet asko
@@ -585,6 +593,8 @@ snippet debug
require 'ruby-debug'; debugger; true;
snippet pry
require 'pry'; binding.pry
+snippet strf
+ strftime("${1:%Y-%m-%d %H:%M:%S %z}")${0}
#############################################
# Rails snippets - for pure Ruby, see above #
#############################################
@@ -612,6 +622,8 @@ snippet asrj
assert_rjs :${1:replace}, "${0:dom id}"
snippet ass assert_select(..)
assert_select '${1:path}', :${2:text} => '${3:inner_html' ${4:do}
+snippet ba
+ before_action :${0:method}
snippet bf
before_filter :${0:method}
snippet bt
@@ -739,8 +751,49 @@ snippet mapwo
${1:map}.with_options :${2:controller} => '${3:thing}' do |$3|
${0}
end
+
+###############################
+# model callback snippets #
+###############################
+
+# before callback
+snippet mbv
+ before_validation :${0:method}
+snippet mbc
+ before_create :${0:method}
+snippet mbu
+ before_update :${0:method}
snippet mbs
before_save :${0:method}
+snippet mbd
+ before_destroy :${0:method}
+
+# after callback
+snippet mav
+ after_validation :${0:method}
+snippet maf
+ after_find :${0:method}
+snippet mat
+ after_touch :${0:method}
+snippet macr
+ after_create :${0:method}
+snippet mau
+ after_update :${0:method}
+snippet mas
+ after_save :${0:method}
+snippet mad
+ after_destroy :${0:method}
+
+# around callback
+snippet marc
+ around_create :${0:method}
+snippet maru
+ around_update :${0:method}
+snippet mars
+ around_save :${0:method}
+snippet mard
+ around_destroy :${0:method}
+
snippet mcht
change_table :${1:table_name} do |t|
${0}
@@ -977,9 +1030,9 @@ snippet aft
${0}
end
snippet let
- let(:${1:object}) ${0}
+ let(:${1:object}) { ${0} }
snippet let!
- let!(:${1:object}) ${0}
+ let!(:${1:object}) { ${0} }
snippet subj
subject { ${0} }
snippet s.
@@ -987,8 +1040,10 @@ snippet s.
snippet spec
specify { subject.${0} }
snippet exp
+ expect(${1:object}).to ${0}
+snippet expb
expect { ${1:object} }.to ${0}
-snippet raise
+snippet experr
expect { ${1:object} }.to raise_error ${2:StandardError}, /${0:message_regex}/
snippet shared
shared_examples ${0:"shared examples name"}
diff --git a/snippets/rust.snippets b/snippets/rust.snippets
new file mode 100644
index 000000000..d4b9264d9
--- /dev/null
+++ b/snippets/rust.snippets
@@ -0,0 +1,125 @@
+#################
+# Rust Snippets #
+#################
+
+# Functions
+snippet fn
+ fn ${1:function_name}(${2}) {
+ ${0}
+ }
+snippet fn-
+ fn ${1:function_name}(${2}) -> ${3} {
+ ${0}
+ }
+snippet test
+ #[test]
+ fn ${1:test_function_name}() {
+ ${0}
+ }
+snippet new
+ pub fn new(${2}) -> ${1:Name} {
+ ${0}return $1 { ${3} };
+ }
+snippet main
+ pub fn main() {
+ ${0}
+ }
+snippet let
+ let ${1:name}${3} = ${2};
+snippet pln
+ println!("${1}");
+snippet pln,
+ println!("${1}", ${2});
+snippet ec
+ extern crate ${1:sync};
+snippet ecl
+ #![feature(phase)]
+ #[phase(syntax, link)] extern crate log;
+snippet mod
+ mod ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} {
+ ${0}
+ } /* $1 */
+snippet crate
+ // Crate ID
+ #![crate_id = "${1:crate_name}#${2:0.0.1}"]
+ // Additional metadata attributes
+ #![desc = "${3:Descrption.}"]
+ #![license = "${4:BSD}"]
+ #![comment = "${5:Comment.}"]
+ // Specify the output type
+ #![crate_type = "${6:lib}"]
+snippet allow
+ #[allow(${1:unused_variable})]
+snippet feat
+ #![feature(${1:macro_rules})]
+# Common types
+snippet opt
+ Option<${1:int}>
+snippet res
+ Result<${1:~str}, ${2:()}>
+snippet if
+ if ${1:/* condition */} {
+ ${0}
+ }
+snippet mat
+ match ${1} {
+ ${2} => ${3},
+ }
+snippet while
+ while ${1:condition} {
+ ${0}
+ }
+snippet for
+ for ${1:i} in ${2:range(0u, 10)} {
+ ${0}
+ }
+snippet spawn
+ spawn(proc() {
+ ${0}
+ });
+snippet chan
+ let (${1:tx}, ${2:rx}): (Sender<${3:int}>, Receiver<${4:int}>) = channel();
+snippet duplex
+ let (${1:from_child}, ${2:to_child}) = sync::duplex();
+# TODO commenting
+snippet todo
+ // [TODO]: ${1:Description}
+# Struct
+snippet st
+ struct ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} {
+ ${0}
+ }
+
+ impl $1 {
+ pub fn new(${2}) -> $1 {
+ ${4}return $1 {
+ ${5}
+ };
+ }
+ }
+# Enum
+snippet enum
+ enum ${1:enum_name} {
+ ${0},
+ }
+# Impl
+snippet imp
+ impl ${1:Name} {
+ ${0}
+ }
+snippet drop
+ impl Drop for ${1:Name} {
+ fn drop(&mut self) {
+ ${0}
+ }
+ }
+# Traits
+snippet trait
+ trait ${1:Name} {
+ ${0}
+ }
+# Statics
+snippet ss
+ static ${1}: &'static str = "${0}";
+snippet stat
+ static ${1}: ${2:uint} = ${0};
diff --git a/snippets/scala.snippets b/snippets/scala.snippets
index 5eddb2c3c..09d69ad3a 100644
--- a/snippets/scala.snippets
+++ b/snippets/scala.snippets
@@ -194,8 +194,9 @@ snippet mhmap
snippet as
${1:name}.asInstanceOf[${2:T}]
#isInstanceOf[]
+snippet is
${1:name}.isInstanceOf[${2:T}]
-#end
+
#collections methods
#scope() with one arg
diff --git a/snippets/scheme.snippets b/snippets/scheme.snippets
new file mode 100644
index 000000000..035d53483
--- /dev/null
+++ b/snippets/scheme.snippets
@@ -0,0 +1,36 @@
+snippet +
+ (+ ${1}
+ ${0})
+
+snippet -
+ (- ${1}
+ ${0})
+
+snippet /
+ (/ ${1}
+ ${0})
+
+snippet *
+ (* ${1}
+ ${0})
+
+# Definition
+snippet def
+ (define (${1:name})
+ (${0:definition}))
+
+# Definition with lambda
+snippet defl
+ (define ${1:name}
+ (lambda (x)(${0:definition})))
+
+# Condition
+snippet cond
+ (cond ((${1:predicate}) (${2:action}))
+ ((${3:predicate}) (${0:action})))
+
+# If statement
+snippet if
+ (if (${1:predicate})
+ (${2:true-action})
+ (${0:false-action}))
diff --git a/snippets/sh.snippets b/snippets/sh.snippets
index 6bf7089cc..c9c6ebc3c 100644
--- a/snippets/sh.snippets
+++ b/snippets/sh.snippets
@@ -81,7 +81,7 @@ snippet getopt
done
shift $(($OPTIND-1))
snippet root
- if [ $(id -u) -ne 0 ]; then exec sudo $0; fi
+ if [ \$(id -u) -ne 0 ]; then exec sudo \$0; fi
snippet fun
${1:function_name}() {
${0:#function_body}
diff --git a/snippets/slim.snippets b/snippets/slim.snippets
new file mode 100644
index 000000000..8eeb4a535
--- /dev/null
+++ b/snippets/slim.snippets
@@ -0,0 +1,64 @@
+# Some useful Unicode entities
+# ============================
+# Non-Breaking Space
+snippet nbs
+
+# ←
+snippet left
+ ←
+# →
+snippet right
+ →
+# ↑
+snippet up
+ ↑
+# ↓
+snippet down
+ ↓
+# ↩
+snippet return
+ ↩
+# ⇤
+snippet backtab
+ ⇤
+# ⇥
+snippet tab
+ ⇥
+# ⇧
+snippet shift
+ ⇧
+# ⌃
+snippet ctrl
+ ⌃
+# ⌅
+snippet enter
+ ⌅
+# ⌘
+snippet cmd
+ ⌘
+# ⌥
+snippet option
+ ⌥
+# ⌦
+snippet delete
+ ⌦
+# ⌫
+snippet backspace
+ ⌫
+# ⎋
+snippet esc
+ ⎋
+
+# Forms
+# =====
+snippet fieldset
+ fieldset
+ legend ${1}
+
+# Assets
+# ======
+snippet css
+ link rel="stylesheet" href="${1:style.css}" type="text/css" media="${2:all}"
+
+snippet script
+ script src="${1:script.js}" type="text/javascript"
diff --git a/snippets/tex.snippets b/snippets/tex.snippets
index f3c090e68..37fcc91b6 100644
--- a/snippets/tex.snippets
+++ b/snippets/tex.snippets
@@ -1,215 +1,224 @@
#PREAMBLE
#newcommand
-snippet nc
+snippet nc \newcommand
\newcommand{\${1:cmd}}[${2:opt}]{${3:realcmd}} ${0}
#usepackage
-snippet up
+snippet up \usepackage
\usepackage[${1:options}]{${2:package}} ${0}
#newunicodechar
-snippet nuc
+snippet nuc \newunicodechar
\newunicodechar{${1}}{${2:\ensuremath}${3:tex-substitute}}} ${0}
#DeclareMathOperator
-snippet dmo
+snippet dmo \DeclareMathOperator
\DeclareMathOperator{${1}}{${2}} ${0}
#DOCUMENT
# \begin{}...\end{}
-snippet begin
+snippet begin \begin{} ... \end{} block
\begin{${1:env}}
${0}
\end{$1}
# Tabular
-snippet tab
+snippet tab tabular (or arbitrary) environment
\begin{${1:tabular}}{${2:c}}
- ${0}
+ ${0}
\end{$1}
-snippet thm
+snippet thm thm (or arbitrary) environment with optional argument
\begin[${1:author}]{${2:thm}}
- ${0}
+ ${0}
\end{$2}
-snippet center
+snippet center center environment
\begin{center}
${0}
\end{center}
# Align(ed)
-snippet ali
+snippet ali align(ed) environment
\begin{align${1:ed}}
+ \label{eq:${2}}
${0}
\end{align$1}
# Gather(ed)
-snippet gat
+snippet gat gather(ed) environment
\begin{gather${1:ed}}
${0}
\end{gather$1}
# Equation
-snippet eq
+snippet eq equation environment
\begin{equation}
+ \label{eq:${2}}
${0}
\end{equation}
# Equation
-snippet eq*
+snippet eq* unnumbered equation environment
\begin{equation*}
${0}
\end{equation*}
# Unnumbered Equation
-snippet \
+snippet \ unnumbered equation: \[ ... \]
\[
${0}
\]
# Equation array
-snippet eqnarray
+snippet eqnarray eqnarray environment
\begin{eqnarray}
${0}
\end{eqnarray}
+# Label
+snippet lab \label
+ \label{${1:eq:}${2:fig:}${3:tab:}${0}}
# Enumerate
-snippet enum
+snippet enum enumerate environment
\begin{enumerate}
\item ${0}
\end{enumerate}
# Itemize
-snippet itemize
+snippet itemize itemize environment
\begin{itemize}
\item ${0}
\end{itemize}
-snippet item
+snippet item \item
\item ${1}
# Description
-snippet desc
+snippet desc description environment
\begin{description}
\item[${1}] ${0}
\end{description}
# Endless new item
-snippet ]i
+snippet ]i \item (recursive)
\item ${1}
- ${0:]i}
+ ${0:]i}
# Matrix
-snippet mat
+snippet mat smart matrix environment
\begin{${1:p/b/v/V/B/small}matrix}
${0}
\end{$1matrix}
# Cases
-snippet cas
+snippet cas cases environment
\begin{cases}
${1:equation}, &\text{ if }${2:case}\\
${0}
\end{cases}
# Split
-snippet spl
+snippet spl split environment
\begin{split}
${0}
\end{split}
# Part
-snippet part
+snippet part document \part
\part{${1:part name}} % (fold)
\label{prt:${2:$1}}
${0}
% part $2 (end)
# Chapter
-snippet cha
+snippet cha \chapter
\chapter{${1:chapter name}}
\label{cha:${2:$1}}
${0}
# Section
-snippet sec
+snippet sec \section
\section{${1:section name}}
\label{sec:${2:$1}}
${0}
# Section without number
-snippet sec*
+snippet sec* \section*
\section*{${1:section name}}
\label{sec:${2:$1}}
${0}
# Sub Section
-snippet sub
+snippet sub \subsection
\subsection{${1:subsection name}}
\label{sub:${2:$1}}
${0}
# Sub Section without number
-snippet sub*
+snippet sub* \subsection*
\subsection*{${1:subsection name}}
\label{sub:${2:$1}}
${0}
# Sub Sub Section
-snippet subs
+snippet subs \subsubsection
\subsubsection{${1:subsubsection name}}
\label{ssub:${2:$1}}
${0}
# Sub Sub Section without number
-snippet subs*
+snippet subs* \subsubsection*
\subsubsection*{${1:subsubsection name}}
\label{ssub:${2:$1}}
${0}
# Paragraph
-snippet par
+snippet par \paragraph
\paragraph{${1:paragraph name}}
\label{par:${2:$1}}
${0}
# Sub Paragraph
-snippet subp
+snippet subp \subparagraph
\subparagraph{${1:subparagraph name}}
\label{subp:${2:$1}}
${0}
-snippet ni
+snippet ni \noindent
\noindent
${0}
#References
-snippet itd
+snippet itd description \item
\item[${1:description}] ${0:item}
-snippet figure
+snippet figure reference to a figure
${1:Figure}~\ref{${2:fig:}}
-snippet table
+snippet table reference to a table
${1:Table}~\ref{${2:tab:}}
-snippet listing
+snippet listing reference to a listing
${1:Listing}~\ref{${2:list}}
-snippet section
+snippet section reference to a section
${1:Section}~\ref{sec:${2}} ${0}
-snippet page
+snippet page reference to a page
${1:page}~\pageref{${2}} ${0}
-snippet index
+snippet index \index
\index{${1:index}} ${0}
#Citations
-snippet citen
- \cite{$1} ${0}
-# bibtex commands
-snippet citep
- \citep{$1} ${0}
-snippet citet
- \citet{$1} ${0}
-snippet cite
+snippet citen \citen
+ \citen{${1}} ${0}
+# natbib citations
+snippet citep \citep
+ \citep{${1}} ${0}
+snippet citet \citet
+ \citet{${1}} ${0}
+snippet cite \cite[]{}
\cite[${1}]{${2}} ${0}
-snippet fcite
+snippet citea \citeauthor
+ \citeauthor{${1}} ${0}
+snippet citey \citeyear
+ \citeyear{${1}} ${0}
+snippet fcite \footcite[]{}
\footcite[${1}]{${2}}${0}
#Formating text: italic, bold, underline, small capital, emphase ..
-snippet it
+snippet it italic text
\textit{${0:text}}
-snippet bf
+snippet bf bold face text
\textbf{${0:text}}
-snippet under
+snippet under underline text
\underline{${0:text}}
-snippet emp
+snippet emp emphasize text
\emph{${0:text}}
-snippet sc
+snippet sc small caps text
\textsc{${0:text}}
#Choosing font
-snippet sf
+snippet sf sans serife text
\textsf{${0:text}}
-snippet rm
+snippet rm roman font text
\textrm{${0:text}}
-snippet tt
+snippet tt typewriter (monospace) text
\texttt{${0:text}}
#misc
-snippet ft
+snippet ft \footnote
\footnote{${0:text}}
-snippet fig
+snippet fig figure environment (includegraphics)
\begin{figure}
\begin{center}
- \includegraphics[scale=${1}]{Figures/${2}}
+ \includegraphics[scale=${1}]{Figures/${2}}
\end{center}
\caption{${3}}
\label{fig:${4}}
\end{figure}
${0}
-snippet tikz
+snippet tikz figure environment (tikzpicture)
\begin{figure}
\begin{center}
\begin{tikzpicture}[scale=${1:1}]
@@ -221,33 +230,31 @@ snippet tikz
\end{figure}
${0}
#math
-snippet stackrel
+snippet stackrel \stackrel{}{}
\stackrel{${1:above}}{${2:below}} ${0}
-snippet frac
+snippet frac \frac{}{}
\frac{${1:num}}{${2:denom}} ${0}
-snippet sum
+snippet sum \sum^{}_{}
\sum^{${1:n}}_{${2:i=1}} ${0}
-snippet lim
+snippet lim \lim_{}
\lim_{${1:x \to +\infty}} ${0}
-snippet frame
- \begin{frame}[<+->]
- \frametitle{${1:title}}
-
+snippet frame frame environment
+ \begin{frame}[${1:t}]{${2:title}}
${0}
\end{frame}
-snippet block
+snippet block block environment
\begin{block}{${1:title}}
${0}
\end{block}
-snippet alert
+snippet alert alertblock environment
\begin{alertblock}{${1:title}}
${0}
\end{alertblock}
-snippet example
+snippet example exampleblock environment
\begin{exampleblock}{${1:title}}
${0}
\end{exampleblock}
-snippet col2
+snippet col2 two-column environment
\begin{columns}
\begin{column}{0.5\textwidth}
${1}
diff --git a/snippets/vim.snippets b/snippets/vim.snippets
index dd1e65e80..b299f5121 100644
--- a/snippets/vim.snippets
+++ b/snippets/vim.snippets
@@ -1,51 +1,52 @@
-snippet header
+snippet header standard Vim script file header
" File: ${1:`expand('%:t')`}
" Author: ${2:`g:snips_author`}
" Description: ${3}
${0:" Last Modified: `strftime("%B %d, %Y")`}
-snippet guard
+snippet guard script reload guard
if exists('${1:did_`vim_snippets#Filename()`}') || &cp${2: || version < 700}
finish
endif
let $1 = 1${0}
-snippet f
+snippet f function
fun! ${1:`expand('%') =~ 'autoload' ? substitute(matchstr(expand('%:p'),'autoload/\zs.*\ze.vim'),'[/\\]','#','g').'#' : ''`}${2:function_name}(${3})
${0}
endf
-snippet t
+snippet t try ... catch statement
try
${1}
catch ${2}
${0}
endtry
-snippet for
+snippet for for ... in loop
for ${1} in ${2}
${0}
endfor
-snippet forkv
+snippet forkv for [key, value] in loop
for [${1},${2}] in items(${3})
${0}
- unlet $1 $2
+ unlet $1 $2
endfor
-
-snippet wh
+snippet wh while loop
while ${1}
${0}
endw
-snippet if
+snippet if if statement
if ${1}
${0}
endif
-snippet ife
+snippet ife if ... else statement
if ${1}
${2}
else
${0}
endif
-snippet au
+snippet au augroup ... autocmd block
augroup ${1:AU_NAME}
" this one is which you're most likely to use?
autocmd ${2:BufRead,BufNewFile} ${3:*.ext,*.ext3|} ${0}
augroup end
-snippet bun
- Bundle '${0}'
+snippet bun Vundle.vim Plugin definition
+ Plugin '${0}'
+snippet plug Vundle.vim Plugin definition
+ Plugin '${0}'