From b2a91d1ea38d46be57a89e52a02cb7940e59eea4 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Wed, 12 Mar 2014 13:04:54 +0800 Subject: [PATCH 01/40] add options_for_select add method `options_for_select` from Rails. --- snippets/eruby.snippets | 2 ++ 1 file changed, 2 insertions(+) diff --git a/snippets/eruby.snippets b/snippets/eruby.snippets index 9541835..bc13fcb 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 From 9371c648e18c765abdd811725fa57d73e937de00 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Wed, 12 Mar 2014 13:35:17 +0800 Subject: [PATCH 02/40] add rails callbak methods --- snippets/ruby.snippets | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/snippets/ruby.snippets b/snippets/ruby.snippets index 1798e08..e4be782 100644 --- a/snippets/ruby.snippets +++ b/snippets/ruby.snippets @@ -749,8 +749,45 @@ snippet mapwo ${1:map}.with_options :${2:controller} => '${3:thing}' do |$3| ${0} end + +# 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 mac + after_create :${0:method} +snippet mau + after_update :${0:method} +snippet mas + after_save :${0:method} +snippet mad + after_destroy :${0:method} +snippet mrc + +# around callback + around_create :${0:method} +snippet mru + around_update :${0:method} +snippet mrs + around_save :${0:method} +snippet mrd + around_destroy :${0:method} + snippet mcht change_table :${1:table_name} do |t| ${0} From 7924eee16b4bff6e3ca8745605bfc392e2915af1 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Fri, 14 Mar 2014 23:00:50 +0800 Subject: [PATCH 03/40] change abbreviation to c for controller --- snippets/ruby.snippets | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/snippets/ruby.snippets b/snippets/ruby.snippets index e4be782..4c07578 100644 --- a/snippets/ruby.snippets +++ b/snippets/ruby.snippets @@ -750,42 +750,46 @@ snippet mapwo ${0} end +########################### +# controller snippets # +########################### + # before callback -snippet mbv +snippet cbv before_validation :${0:method} -snippet mbc +snippet cbc before_create :${0:method} -snippet mbu +snippet cbu before_update :${0:method} -snippet mbs +snippet cbs before_save :${0:method} -snippet mbd +snippet cbd before_destroy :${0:method} # after callback -snippet mav +snippet cav after_validation :${0:method} -snippet maf +snippet caf after_find :${0:method} -snippet mat +snippet cat after_touch :${0:method} -snippet mac +snippet cac after_create :${0:method} -snippet mau +snippet cau after_update :${0:method} -snippet mas +snippet cas after_save :${0:method} -snippet mad +snippet cad after_destroy :${0:method} -snippet mrc # around callback +snippet crc around_create :${0:method} -snippet mru +snippet cru around_update :${0:method} -snippet mrs +snippet crs around_save :${0:method} -snippet mrd +snippet crd around_destroy :${0:method} snippet mcht @@ -933,6 +937,8 @@ snippet mct create_table :${1:table_name} do |t| ${0} end +snippet mdt + drop_table :${1:table_name} snippet migration class .. < ActiveRecord::Migration .. def up .. def down .. end class ${1:class_name} < ActiveRecord::Migration def up From dfc456ea492ef757ed1e593de23fc8339402796e Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Sat, 15 Mar 2014 00:32:23 +0800 Subject: [PATCH 04/40] respect the convention --- snippets/ruby.snippets | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/snippets/ruby.snippets b/snippets/ruby.snippets index 4c07578..0083cca 100644 --- a/snippets/ruby.snippets +++ b/snippets/ruby.snippets @@ -756,41 +756,41 @@ snippet mapwo # before callback snippet cbv - before_validation :${0:method} + before_validation :${0:method} snippet cbc - before_create :${0:method} + before_create :${0:method} snippet cbu - before_update :${0:method} + before_update :${0:method} snippet cbs before_save :${0:method} snippet cbd - before_destroy :${0:method} + before_destroy :${0:method} # after callback snippet cav - after_validation :${0:method} + after_validation :${0:method} snippet caf - after_find :${0:method} + after_find :${0:method} snippet cat - after_touch :${0:method} + after_touch :${0:method} snippet cac - after_create :${0:method} + after_create :${0:method} snippet cau - after_update :${0:method} + after_update :${0:method} snippet cas - after_save :${0:method} + after_save :${0:method} snippet cad - after_destroy :${0:method} + after_destroy :${0:method} # around callback snippet crc - around_create :${0:method} + around_create :${0:method} snippet cru - around_update :${0:method} + around_update :${0:method} snippet crs - around_save :${0:method} + around_save :${0:method} snippet crd - around_destroy :${0:method} + around_destroy :${0:method} snippet mcht change_table :${1:table_name} do |t| From 391d4fea4725df2067bf6bbd0af65c3fc004bf7b Mon Sep 17 00:00:00 2001 From: Ryan Pineo Date: Sat, 22 Mar 2014 15:03:16 -0400 Subject: [PATCH 05/40] Add python google style docstrings. --- UltiSnips/python.snippets | 54 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/UltiSnips/python.snippets b/UltiSnips/python.snippets index 357d01d..dea562d 100644 --- a/UltiSnips/python.snippets +++ b/UltiSnips/python.snippets @@ -34,13 +34,30 @@ 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 @@ -61,6 +78,7 @@ def get_style(snip): if style == "doxygen": return DOXYGEN elif style == "sphinx": return SPHINX + elif style == "google": return GOOGLE else: return NORMAL @@ -71,6 +89,8 @@ def format_arg(arg, style): return ":param %s: @todo" % arg elif style == NORMAL: return ":%s: @todo" % arg + elif style == GOOGLE: + return "%s (@todo): @todo" % arg def format_return(style): @@ -78,6 +98,8 @@ def format_return(style): return "@return: @todo" elif style in (NORMAL, SPHINX): return ":returns: @todo" + elif style == GOOGLE: + return "Returns: @todo" def write_docstring_args(args, snip): @@ -89,8 +111,32 @@ def write_docstring_args(args, 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): From 16630a5c8e99de906d6cb623332441db66ea0adb Mon Sep 17 00:00:00 2001 From: gfixler Date: Sat, 22 Mar 2014 22:33:17 -0700 Subject: [PATCH 06/40] Fix spelling throughout UltiSnips/python.snippets --- UltiSnips/python.snippets | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/UltiSnips/python.snippets b/UltiSnips/python.snippets index dea562d..64b5cfd 100644 --- a/UltiSnips/python.snippets +++ b/UltiSnips/python.snippets @@ -68,7 +68,7 @@ def get_quoting_style(snip): return SINGLE_QUOTES return DOUBLE_QUOTES -def tripple_quotes(snip): +def triple_quotes(snip): if get_quoting_style(snip) == SINGLE_QUOTES: return "'''" return '"""' @@ -104,7 +104,7 @@ def format_return(style): def write_docstring_args(args, snip): if not args: - snip.rv += ' {0}'.format(tripple_quotes(snip)) + snip.rv += ' {0}'.format(triple_quotes(snip)) return snip.rv += '\n' + snip.mkline('', indent='') @@ -166,10 +166,10 @@ endglobal snippet class "class with docstrings" b class ${1:MyClass}(${2:object}): - `!p snip.rv = tripple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = tripple_quotes(snip)` + `!p snip.rv = triple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = triple_quotes(snip)` def __init__(self$4): - `!p snip.rv = tripple_quotes(snip)`${5:@todo: to be defined1.}`!p + `!p snip.rv = triple_quotes(snip)`${5:@todo: to be defined1.}`!p snip.rv = "" snip >> 2 @@ -178,7 +178,7 @@ args = get_args(t[4]) write_docstring_args(args, snip) if args: snip.rv += '\n' + snip.mkline('', indent='') - snip += '{0}'.format(tripple_quotes(snip)) + snip += '{0}'.format(triple_quotes(snip)) write_init_body(args, t[2], snip) ` @@ -189,7 +189,7 @@ endsnippet snippet slotclass "class with slots and docstrings" b class ${1:MyClass}(${2:object}): - `!p snip.rv = tripple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = tripple_quotes(snip)` + `!p snip.rv = triple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = triple_quotes(snip)` `!p snip >> 1 args = get_args(t[4]) @@ -197,7 +197,7 @@ write_slots_args(args, snip) ` def __init__(self$4): - `!p snip.rv = tripple_quotes(snip)`${5:@todo: to be defined.}`!p + `!p snip.rv = triple_quotes(snip)`${5:@todo: to be defined.}`!p snip.rv = "" snip >> 2 @@ -206,7 +206,7 @@ args = get_args(t[4]) write_docstring_args(args, snip) if args: snip.rv += '\n' + snip.mkline('', indent='') - snip += tripple_quotes(snip) + snip += triple_quotes(snip) write_init_body(args, t[2], snip) ` @@ -399,7 +399,7 @@ snippet def "function with docstrings" b def ${1:function}(`!p if snip.indent: snip.rv = 'self' + (", " if len(t[2]) else "")`${2:arg1}): - `!p snip.rv = tripple_quotes(snip)`${4:@todo: Docstring for $1.}`!p + `!p snip.rv = triple_quotes(snip)`${4:@todo: Docstring for $1.}`!p snip.rv = "" snip >> 1 @@ -410,7 +410,7 @@ if args: style = get_style(snip) snip += format_return(style) snip.rv += '\n' + snip.mkline('', indent='') -snip += tripple_quotes(snip) ` +snip += triple_quotes(snip) ` ${0:pass} endsnippet @@ -436,7 +436,7 @@ endsnippet snippet rwprop "Read write property" b def ${1:name}(): - `!p snip.rv = tripple_quotes(snip) if t[2] else '' + `!p snip.rv = triple_quotes(snip) if t[2] else '' `${2:@todo: Docstring for $1.}`!p if t[2]: snip >> 1 @@ -445,7 +445,7 @@ if t[2]: snip.rv += '\n' + snip.mkline('', indent='') snip += format_return(style) snip.rv += '\n' + snip.mkline('', indent='') - snip += tripple_quotes(snip) + snip += triple_quotes(snip) else: snip.rv = ""` def fget(self): @@ -564,7 +564,7 @@ endsnippet snippet testcase "pyunit testcase" b class Test${1:Class}(${2:unittest.TestCase}): - `!p snip.rv = tripple_quotes(snip)`${3:Test case docstring.}`!p snip.rv = tripple_quotes(snip)` + `!p snip.rv = triple_quotes(snip)`${3:Test case docstring.}`!p snip.rv = triple_quotes(snip)` def setUp(self): ${4:pass} From 1ffdf752b647afd921bc8b094e221de9be0d8ea9 Mon Sep 17 00:00:00 2001 From: Piotr Yordanov Date: Mon, 24 Mar 2014 03:29:41 +0000 Subject: [PATCH 07/40] Added Jade templates --- snippets/jade.snippets | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 snippets/jade.snippets diff --git a/snippets/jade.snippets b/snippets/jade.snippets new file mode 100644 index 0000000..55f0af7 --- /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}') From 88cd206a193a3488b01a77137254eb18b0d34017 Mon Sep 17 00:00:00 2001 From: Danny Navarro Date: Mon, 24 Mar 2014 09:46:51 +0100 Subject: [PATCH 08/40] Add `OPTIONS_HADDOCK` snippet --- snippets/haskell.snippets | 2 ++ 1 file changed, 2 insertions(+) diff --git a/snippets/haskell.snippets b/snippets/haskell.snippets index f5f1598..ddb89d9 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} From fc65844236629e26428dd2f2b4b8aece3e1c3c62 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Mon, 24 Mar 2014 17:51:34 +0800 Subject: [PATCH 09/40] use m as prefix and fix conflicts with other snippets --- snippets/ruby.snippets | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/snippets/ruby.snippets b/snippets/ruby.snippets index 0083cca..95eca9d 100644 --- a/snippets/ruby.snippets +++ b/snippets/ruby.snippets @@ -750,46 +750,46 @@ snippet mapwo ${0} end -########################### -# controller snippets # -########################### +############################### +# model callback snippets # +############################### # before callback -snippet cbv +snippet mbv before_validation :${0:method} -snippet cbc +snippet mbc before_create :${0:method} -snippet cbu +snippet mbu before_update :${0:method} -snippet cbs +snippet mbs before_save :${0:method} -snippet cbd +snippet mbd before_destroy :${0:method} # after callback -snippet cav +snippet mav after_validation :${0:method} -snippet caf +snippet maf after_find :${0:method} -snippet cat +snippet mat after_touch :${0:method} -snippet cac +snippet macr after_create :${0:method} -snippet cau +snippet mau after_update :${0:method} -snippet cas +snippet mas after_save :${0:method} -snippet cad +snippet mad after_destroy :${0:method} # around callback -snippet crc +snippet marc around_create :${0:method} -snippet cru +snippet maru around_update :${0:method} -snippet crs +snippet mars around_save :${0:method} -snippet crd +snippet mard around_destroy :${0:method} snippet mcht @@ -937,8 +937,6 @@ snippet mct create_table :${1:table_name} do |t| ${0} end -snippet mdt - drop_table :${1:table_name} snippet migration class .. < ActiveRecord::Migration .. def up .. def down .. end class ${1:class_name} < ActiveRecord::Migration def up From 1d41c715e23a62174cb4ad92ca9a7956e9966c82 Mon Sep 17 00:00:00 2001 From: Ryan Pineo Date: Wed, 26 Mar 2014 15:39:47 -0400 Subject: [PATCH 10/40] Allow java else/elif to be expanded mid line. --- UltiSnips/java.snippets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UltiSnips/java.snippets b/UltiSnips/java.snippets index 96cc7a9..de15572 100644 --- a/UltiSnips/java.snippets +++ b/UltiSnips/java.snippets @@ -173,13 +173,13 @@ default: $0 endsnippet -snippet elif "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 } From 0b673c3e59d7e61589d8ddca9875ab3c232815a5 Mon Sep 17 00:00:00 2001 From: Ches Martin Date: Thu, 27 Mar 2014 05:37:14 +0700 Subject: [PATCH 11/40] Scala snippets fix --- snippets/scala.snippets | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/snippets/scala.snippets b/snippets/scala.snippets index 5eddb2c..09d69ad 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 From ba94750df1627790ac8fbc7577f1f765cc02da75 Mon Sep 17 00:00:00 2001 From: Muhammad Hallaj Subery Date: Thu, 27 Mar 2014 12:08:39 +0800 Subject: [PATCH 12/40] Update python.snippets adding code encoding. --- snippets/python.snippets | 1 + 1 file changed, 1 insertion(+) diff --git a/snippets/python.snippets b/snippets/python.snippets index d38df5b..a7bb708 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 From ad8883ddcaf27414e96dfc521aba9260cfc48e8c Mon Sep 17 00:00:00 2001 From: Ryan Pineo Date: Fri, 28 Mar 2014 12:10:19 -0400 Subject: [PATCH 13/40] Fix java setter method param case, remove return. The paramater was keeping the case of the setter name. It should have been lowercased. The other uses of the paramter were already lowercased correctly. There should also not be a return statement in a void method. --- UltiSnips/java.snippets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UltiSnips/java.snippets b/UltiSnips/java.snippets index de15572..18746b4 100644 --- a/UltiSnips/java.snippets +++ b/UltiSnips/java.snippets @@ -343,8 +343,8 @@ public ${1:String} get${2:Name}() { endsnippet snippet /set(ter)?/ "setter" br -public void set${1:Name}(${2:String} $1) { - return this.`!p snip.rv = t[1].lower()` = `!p snip.rv = t[1].lower()`; +public void set${1:Name}(${2:String} `!p snip.rv = t[1].lower()`) { + this.`!p snip.rv = t[1].lower()` = `!p snip.rv = t[1].lower()`; } endsnippet From e5f3d6bdf55ebd2dc6e129cb58bf4c8faac289f0 Mon Sep 17 00:00:00 2001 From: Ryan Pineo Date: Fri, 28 Mar 2014 15:32:39 -0400 Subject: [PATCH 14/40] Change java set/get snippets to use mixedCase. The java setter and getter snippets were incorrectly formatting the set/get name as all lowercase. It should be mixed case, as per java's coding standard. A new function was made (mixedCase) to handle that. --- UltiSnips/java.snippets | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/UltiSnips/java.snippets b/UltiSnips/java.snippets index 18746b4..a9aa55f 100644 --- a/UltiSnips/java.snippets +++ b/UltiSnips/java.snippets @@ -27,6 +27,9 @@ def getArgs(group): def camel(word): return word[0].upper() + word[1:] +def mixedCase(word): + return word[0].lower() + word[1:] + endglobal snippet sleep "try sleep catch" b @@ -338,23 +341,23 @@ endsnippet snippet /get(ter)?/ "getter" br public ${1:String} get${2:Name}() { - return `!p snip.rv = t[2].lower()`; + return `!p snip.rv = mixedCase(t[2])`; } endsnippet snippet /set(ter)?/ "setter" br -public void set${1:Name}(${2:String} `!p snip.rv = t[1].lower()`) { - this.`!p snip.rv = t[1].lower()` = `!p snip.rv = t[1].lower()`; +public 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 = t[1].lower()`) { - this.`!p snip.rv = t[1].lower()` = `!p snip.rv = t[1].lower()`; +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 = t[1].lower()`; + return `!p snip.rv = mixedCase(t[1])`; } endsnippet From 6541994397033efe43e53b66984806667680fbfb Mon Sep 17 00:00:00 2001 From: Brandon Hilkert Date: Fri, 28 Mar 2014 19:45:20 -0400 Subject: [PATCH 15/40] Add asi => assert_includes --- snippets/ruby.snippets | 2 ++ 1 file changed, 2 insertions(+) diff --git a/snippets/ruby.snippets b/snippets/ruby.snippets index 95eca9d..6ee11d4 100644 --- a/snippets/ruby.snippets +++ b/snippets/ruby.snippets @@ -479,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 From 77bc9bdf8012281d580f12c0d727dc85e7dabee8 Mon Sep 17 00:00:00 2001 From: Josh Davis Date: Sat, 29 Mar 2014 16:28:00 -0500 Subject: [PATCH 16/40] Add support for rnoweb filetype Rnoweb is a filetype that combines LaTeX and R. It's used by systems like Sweave and Knitr. --- UltiSnips/rnoweb.snippets | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 UltiSnips/rnoweb.snippets diff --git a/UltiSnips/rnoweb.snippets b/UltiSnips/rnoweb.snippets new file mode 100644 index 0000000..37eece6 --- /dev/null +++ b/UltiSnips/rnoweb.snippets @@ -0,0 +1,3 @@ +priority -50 + +extends tex From 53f8dd5a7ad3acc4f3e7a6c87e9936a1905a3890 Mon Sep 17 00:00:00 2001 From: Josh Davis Date: Sat, 29 Mar 2014 16:46:23 -0500 Subject: [PATCH 17/40] Add in r.snippets file I converted these over from the snipMate r.snippets in the snippets/ directory and removed some ones. --- UltiSnips/r.snippets | 136 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 UltiSnips/r.snippets diff --git a/UltiSnips/r.snippets b/UltiSnips/r.snippets new file mode 100644 index 0000000..bbfbaaa --- /dev/null +++ b/UltiSnips/r.snippets @@ -0,0 +1,136 @@ +snippet #! "Hashbang for Rscript" +#!/usr/bin/env Rscript +endsnippet + +# includes +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 + +# conditionals +snippet if "If statement" +if (${1:condition}) { + ${0} +} +endsnippet + +snippet el "Else statement" +else { + ${0} +} +endsnippet + +snippet ei "Else-If statement" +else if (${1:condition}) { + ${0} +} +endsnippet + +# functions +snippet fun "Function definition" +${1:name} = function (${2:variables}) { + ${0} +} +endsnippet + +snippet ret "Return call" +return(${0}) +endsnippet + +# dataframes, lists, etc +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 + +# apply functions +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" +lapply(${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 + +# plot functions +snippet pl "Plot function" +plot(${1:x}, ${0:y}) +endsnippet + +snippet ggp "ggplot2 plot" +ggplot(${1:data}, aes(${0:aesthetics})) +endsnippet + +snippet img "Output an image" +${1:(jpeg,bmp,png,tiff)}(filename="${2:filename}", width=${3}, height=${4}, unit="${5}") +${0:plot} +dev.off() +endsnippet + +# statistical test functions +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 From 55887f0db48c5f44afdcd76841aaf246b169a75e Mon Sep 17 00:00:00 2001 From: Josh Davis Date: Sat, 29 Mar 2014 16:52:21 -0500 Subject: [PATCH 18/40] Add R snippets to Rnoweb --- UltiSnips/rnoweb.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UltiSnips/rnoweb.snippets b/UltiSnips/rnoweb.snippets index 37eece6..773b9aa 100644 --- a/UltiSnips/rnoweb.snippets +++ b/UltiSnips/rnoweb.snippets @@ -1,3 +1,3 @@ priority -50 -extends tex +extends tex, r From 87ea532f410551cb3609d0d62262696702363dea Mon Sep 17 00:00:00 2001 From: Ryan Pineo Date: Sat, 29 Mar 2014 20:39:14 -0400 Subject: [PATCH 19/40] Bug fix for java case coercion helpers. If an empty tab stop was used with either of the java case coercion helper functions then they would blow up. Fixed by returning an empty string if the word passed to them is falsey. --- UltiSnips/java.snippets | 2 ++ 1 file changed, 2 insertions(+) diff --git a/UltiSnips/java.snippets b/UltiSnips/java.snippets index a9aa55f..21be6be 100644 --- a/UltiSnips/java.snippets +++ b/UltiSnips/java.snippets @@ -25,9 +25,11 @@ def getArgs(group): 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 From bd8ef3d11053562632dde8804f7b4d0ac65929db Mon Sep 17 00:00:00 2001 From: Josh Davis Date: Sun, 30 Mar 2014 01:04:00 -0500 Subject: [PATCH 20/40] Tidy up some parts of r.snippets --- UltiSnips/r.snippets | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/UltiSnips/r.snippets b/UltiSnips/r.snippets index bbfbaaa..5fafb3c 100644 --- a/UltiSnips/r.snippets +++ b/UltiSnips/r.snippets @@ -36,7 +36,7 @@ endsnippet # functions snippet fun "Function definition" -${1:name} = function (${2:variables}) { +${1:name} <- function (${2:variables}) { ${0} } endsnippet @@ -59,7 +59,7 @@ list(${0:items}) endsnippet snippet mat "Matrix function" -matrix(${1:data}, nrow=${2:rows}, ncol=${0:cols}) +matrix(${1:data}, nrow = ${2:rows}, ncol = ${0:cols}) endsnippet # apply functions @@ -88,8 +88,8 @@ tapply(${1:vector}, ${2:index}, ${0:function}) endsnippet snippet rapply "rapply function" -rapply(${1:list}, ${0:function}) endsnippet +rapply(${1:list}, ${0:function}) # plot functions snippet pl "Plot function" @@ -101,7 +101,7 @@ ggplot(${1:data}, aes(${0:aesthetics})) endsnippet snippet img "Output an image" -${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() endsnippet From d1f23164d514b095f1a090b742c48efc9405091d Mon Sep 17 00:00:00 2001 From: Josh Davis Date: Sun, 30 Mar 2014 11:39:03 -0500 Subject: [PATCH 21/40] Add a few more snippets, fix errors as per #332 Hopefully this looks better, @SirVer! --- UltiSnips/r.snippets | 92 +++++++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 39 deletions(-) diff --git a/UltiSnips/r.snippets b/UltiSnips/r.snippets index 5fafb3c..625ed64 100644 --- a/UltiSnips/r.snippets +++ b/UltiSnips/r.snippets @@ -1,69 +1,91 @@ -snippet #! "Hashbang for Rscript" +priority -50 + +snippet #! "Hashbang for Rscript (#!)" b #!/usr/bin/env Rscript endsnippet -# includes -snippet lib "Import a library" +snippet lib "Import a library (lib)" library(${0:package}) endsnippet -snippet req "Require a file" +snippet req "Require a file (req)" require(${0:package}) endsnippet -snippet source "Source a file" +snippet source "Source a file (source)" source('${0:file}') endsnippet -# conditionals -snippet if "If statement" -if (${1:condition}) { +snippet if "If statement (if)" +if (${1}) { ${0} } endsnippet -snippet el "Else statement" +snippet eif "Else-If statement (eif)" +else if (${1}) { + ${0} +} + +snippet el "Else statement (el)" else { ${0} } endsnippet -snippet ei "Else-If statement" -else if (${1:condition}) { +snippet eif "Else-If statement (eif)" +else if (${1}) { ${0} } endsnippet -# functions -snippet fun "Function definition" -${1:name} <- function (${2:variables}) { +snippet ife "if .. else (ife)" +if (${1}) { + ${2} +} else { + ${3} +} +endsnippet + +snippet wh "while loop (wh)" +while(${1}) { + ${2} +} +endsnippet + +snippet for "for loop (for)" +for ({${1:item} in ${2:list}) { + ${3} +} +endsnippet + +snippet fun "Function definition (fun)" +${1:name} <- function (${2}) { ${0} } endsnippet -snippet ret "Return call" +snippet ret "Return call (ret)" return(${0}) endsnippet -# dataframes, lists, etc -snippet df "Data frame" +snippet df "Data frame (df)" ${1:name}[${2:rows}, ${0:cols}] endsnippet -snippet c "C function" +snippet c "c function (c)" c(${0:items}) endsnippet -snippet li "List function" +snippet li "list function (li)" list(${0:items}) endsnippet -snippet mat "Matrix function" +snippet mat "matrix function (mat)" matrix(${1:data}, nrow = ${2:rows}, ncol = ${0:cols}) endsnippet -# apply functions -snippet apply "Apply function" +snippet apply "apply function" apply(${1:array}, ${2:margin}, ${0:function}) endsnippet @@ -91,46 +113,38 @@ snippet rapply "rapply function" endsnippet rapply(${1:list}, ${0:function}) -# plot functions -snippet pl "Plot function" +snippet pl "Plot function (pl)" plot(${1:x}, ${0:y}) endsnippet -snippet ggp "ggplot2 plot" +snippet ggp "ggplot2 plot (ggp)" ggplot(${1:data}, aes(${0:aesthetics})) endsnippet -snippet img "Output an image" -${1:(jpeg,bmp,png,tiff)}(filename = "${2:filename}", width = ${3}, height = ${4}, unit = "${5}") -${0:plot} -dev.off() -endsnippet - -# statistical test functions -snippet fis "Fisher test" +snippet fis "Fisher test (fis)" fisher.test(${1:x}, ${0:y}) endsnippet -snippet chi "Chi Squared test" +snippet chi "Chi Squared test (chi)" chisq.test(${1:x}, ${0:y}) endsnippet -snippet tt "t-test" +snippet tt "t-test (tt)" t.test(${1:x}, ${0:y}) endsnippet -snippet wil "Wilcox test" +snippet wil "Wilcox test (wil)" wilcox.test(${1:x}, ${0:y}) endsnippet -snippet cor "Correlation test" +snippet cor "Correlation test (cor)" cor.test(${1:x}, ${0:y}) endsnippet -snippet fte "FTE test" +snippet fte "FTE test (fte)" var.test(${1:x}, ${0:y}) endsnippet -snippet kvt "KV test" +snippet kvt "KV test (kvt)" kv.test(${1:x}, ${0:y}) endsnippet From 6b5d7d3377bd464676387ae28c59d80cfee6e7f0 Mon Sep 17 00:00:00 2001 From: Josh Davis Date: Sun, 30 Mar 2014 15:32:13 -0500 Subject: [PATCH 22/40] Remove duplicate snippet --- UltiSnips/r.snippets | 6 ------ 1 file changed, 6 deletions(-) diff --git a/UltiSnips/r.snippets b/UltiSnips/r.snippets index 625ed64..ec8ee91 100644 --- a/UltiSnips/r.snippets +++ b/UltiSnips/r.snippets @@ -33,12 +33,6 @@ else { } endsnippet -snippet eif "Else-If statement (eif)" -else if (${1}) { - ${0} -} -endsnippet - snippet ife "if .. else (ife)" if (${1}) { ${2} From 8c7bb5d4aa5c4c4f5e7ca9c2d7e3ba07a9837bec Mon Sep 17 00:00:00 2001 From: Josh Davis Date: Mon, 31 Mar 2014 21:11:47 -0500 Subject: [PATCH 23/40] Remove trigger from the end of the description --- UltiSnips/r.snippets | 48 ++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/UltiSnips/r.snippets b/UltiSnips/r.snippets index ec8ee91..771450f 100644 --- a/UltiSnips/r.snippets +++ b/UltiSnips/r.snippets @@ -4,36 +4,36 @@ snippet #! "Hashbang for Rscript (#!)" b #!/usr/bin/env Rscript endsnippet -snippet lib "Import a library (lib)" +snippet lib "Import a library" library(${0:package}) endsnippet -snippet req "Require a file (req)" +snippet req "Require a file" require(${0:package}) endsnippet -snippet source "Source a file (source)" +snippet source "Source a file" source('${0:file}') endsnippet -snippet if "If statement (if)" +snippet if "If statement" if (${1}) { ${0} } endsnippet -snippet eif "Else-If statement (eif)" +snippet eif "Else-If statement" else if (${1}) { ${0} } -snippet el "Else statement (el)" +snippet el "Else statement" else { ${0} } endsnippet -snippet ife "if .. else (ife)" +snippet ife "if .. else" if (${1}) { ${2} } else { @@ -41,41 +41,41 @@ if (${1}) { } endsnippet -snippet wh "while loop (wh)" +snippet wh "while loop" while(${1}) { ${2} } endsnippet -snippet for "for loop (for)" +snippet for "for loop" for ({${1:item} in ${2:list}) { ${3} } endsnippet -snippet fun "Function definition (fun)" +snippet fun "Function definition" ${1:name} <- function (${2}) { ${0} } endsnippet -snippet ret "Return call (ret)" +snippet ret "Return call" return(${0}) endsnippet -snippet df "Data frame (df)" +snippet df "Data frame" ${1:name}[${2:rows}, ${0:cols}] endsnippet -snippet c "c function (c)" +snippet c "c function" c(${0:items}) endsnippet -snippet li "list function (li)" +snippet li "list function" list(${0:items}) endsnippet -snippet mat "matrix function (mat)" +snippet mat "matrix function" matrix(${1:data}, nrow = ${2:rows}, ncol = ${0:cols}) endsnippet @@ -107,38 +107,38 @@ snippet rapply "rapply function" endsnippet rapply(${1:list}, ${0:function}) -snippet pl "Plot function (pl)" +snippet pl "Plot function" plot(${1:x}, ${0:y}) endsnippet -snippet ggp "ggplot2 plot (ggp)" +snippet ggp "ggplot2 plot" ggplot(${1:data}, aes(${0:aesthetics})) endsnippet -snippet fis "Fisher test (fis)" +snippet fis "Fisher test" fisher.test(${1:x}, ${0:y}) endsnippet -snippet chi "Chi Squared test (chi)" +snippet chi "Chi Squared test" chisq.test(${1:x}, ${0:y}) endsnippet -snippet tt "t-test (tt)" +snippet tt "t-test" t.test(${1:x}, ${0:y}) endsnippet -snippet wil "Wilcox test (wil)" +snippet wil "Wilcox test" wilcox.test(${1:x}, ${0:y}) endsnippet -snippet cor "Correlation test (cor)" +snippet cor "Correlation test" cor.test(${1:x}, ${0:y}) endsnippet -snippet fte "FTE test (fte)" +snippet fte "FTE test" var.test(${1:x}, ${0:y}) endsnippet -snippet kvt "KV test (kvt)" +snippet kvt "KV test" kv.test(${1:x}, ${0:y}) endsnippet From 653a814deac45c522b51ed27519fcb1eab186615 Mon Sep 17 00:00:00 2001 From: Josh Davis Date: Mon, 31 Mar 2014 23:59:21 -0500 Subject: [PATCH 24/40] Fix snippets syntax error --- UltiSnips/r.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UltiSnips/r.snippets b/UltiSnips/r.snippets index 771450f..d78a1d7 100644 --- a/UltiSnips/r.snippets +++ b/UltiSnips/r.snippets @@ -104,8 +104,8 @@ tapply(${1:vector}, ${2:index}, ${0:function}) endsnippet snippet rapply "rapply function" -endsnippet rapply(${1:list}, ${0:function}) +endsnippet snippet pl "Plot function" plot(${1:x}, ${0:y}) From fcce90db9baf9327c1c076a09821eee264b30b1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Szymczyszyn?= Date: Tue, 1 Apr 2014 14:33:47 +0200 Subject: [PATCH 25/40] Reindent gen_server export list --- snippets/erlang.snippets | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/snippets/erlang.snippets b/snippets/erlang.snippets index 8845870..3a8cf90 100644 --- a/snippets/erlang.snippets +++ b/snippets/erlang.snippets @@ -120,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). From 8f9a7e3dc916a5020af7638a590901dd0f877193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Szymczyszyn?= Date: Tue, 1 Apr 2014 14:35:02 +0200 Subject: [PATCH 26/40] Add gen_fsm and gen_event imported from vimerl --- snippets/erlang.snippets | 314 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 314 insertions(+) diff --git a/snippets/erlang.snippets b/snippets/erlang.snippets index 3a8cf90..2a0d1a4 100644 --- a/snippets/erlang.snippets +++ b/snippets/erlang.snippets @@ -161,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 %%%=================================================================== From 40f1db97d9b6a3e4f25e6e34e1a07914dc555367 Mon Sep 17 00:00:00 2001 From: Maximiliano Robaina Date: Mon, 7 Apr 2014 13:41:38 -0300 Subject: [PATCH 27/40] Added new django fields types --- snippets/django.snippets | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/snippets/django.snippets b/snippets/django.snippets index cad80eb..0e9164d 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 From 0c4960aa84987713aded5daf999d8831eaa3ca29 Mon Sep 17 00:00:00 2001 From: Maximiliano Robaina Date: Tue, 8 Apr 2014 09:35:15 -0300 Subject: [PATCH 28/40] Fixed #335 - django snippet fix model save method --- snippets/django.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/django.snippets b/snippets/django.snippets index 0e9164d..e2a8d6d 100644 --- a/snippets/django.snippets +++ b/snippets/django.snippets @@ -84,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 From 513fad93b103d0c3c633e4c071c5e8c7647ec588 Mon Sep 17 00:00:00 2001 From: "David C. Bishop" Date: Wed, 9 Apr 2014 00:18:29 +1000 Subject: [PATCH 29/40] Add rust.snippets --- UltiSnips/rust.snippets | 215 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 UltiSnips/rust.snippets diff --git a/UltiSnips/rust.snippets b/UltiSnips/rust.snippets new file mode 100644 index 0000000..98a371f --- /dev/null +++ b/UltiSnips/rust.snippets @@ -0,0 +1,215 @@ +####################################################################### +# Rust Snippets # +####################################################################### + +############### +# Functions # +############### +snippet fn "A function, optionally with arguments and return type." +fn ${1:function_name}(${2})${3/..*/ -> /}${3} { + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} +} +endsnippet + +snippet test "Test function" +#[test] +fn ${1:test_function_name}() { + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} +} +endsnippet + +snippet new "A new function" +pub fn new(${2}) -> ${1:Name} { + ${VISUAL}${0}return $1 { ${3} }; +} +endsnippet + +snippet main "The main function" +pub fn main() { + ${VISUAL}${0} +} +endsnippet + + + +snippet let "A let statement" +let ${1:name}${3} = ${VISUAL}${2}; +endsnippet + +snippet pln "println!(..)" b +println!("${1}"${2/..*/, /}${2}); +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 mod." b +mod ${1:`!p snip.rv = snip.basename.lower() or "name"`} { + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} +} /* $1 */ +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 + + +################## +# Common types # +################## +snippet opt "Option<..>" +Option<${1:int}> +endsnippet + +snippet res "Result<.., ..>" +Result<${1:~str}, ${2:()}> +endsnippet + + + + +snippet if "if .. (if)" b +if ${1:/* condition */} { + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} +} +endsnippet + +snippet mat "match" +match ${1} { + ${2} => ${3}, +} +endsnippet + +snippet while "while .. {}" b +while ${1:condition} { + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} +} +endsnippet + +snippet for "for .. in .." b +for ${1:i} in ${2:range(0u, 10)} { + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} +} +endsnippet + +snippet spawn "spawn(proc() { .. });" b +spawn(proc() { + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} +}); +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 + +##################### +# TODO commenting # +##################### +snippet todo "A Todo comment" +// [TODO]: ${1:Description} - `!v strftime("%Y-%m-%d %I:%M%P")` +endsnippet + + +############ +# Struct # +############ +snippet st "Struct" b +struct ${1:`!p snip.rv = snip.basename.title() or "name"`} { + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} +} +endsnippet + +snippet stn "Struct with new constructor." b +pub struct ${1:`!p snip.rv = snip.basename.title() or "name"`} { + ${3:/* code */} +} + +impl $1 { + pub fn new(${2}) -> $1 { + ${4}return $1 { + ${5} + }; + } +} +endsnippet + + +########## +# Enum # +########## +snippet enum "An enum" b +enum ${1:enum_name} { + ${VISUAL}${0}, +} +endsnippet + + +########## +# Impl # +########## +snippet imp "An impl" b +impl ${1:Name} { + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} +} +endsnippet + +snippet drop "Drop implementation" b +impl Drop for ${1:Name} { + fn drop(&mut self) { + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} + } +} +endsnippet + + +############ +# Traits # +############ +snippet trait "Trait block" b +trait ${1:Name} { + ${VISUAL}${0:${VISUAL/(.*)/(?1::\/* code *\/)/}} +} +endsnippet + + +############# +# Statics # +############# +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: From fa6d71e49e3ab109b5a56f5bcb99805a6f30b221 Mon Sep 17 00:00:00 2001 From: Steeve Date: Wed, 9 Apr 2014 12:27:32 +0200 Subject: [PATCH 30/40] add def overloading methode (dol) I add it because I use it many times a day -not only for the `__init__` method- this snippet is very useful to me, no need to call super and handle all args and kwargs, and no more typo errors :D --- snippets/python.snippets | 3 +++ 1 file changed, 3 insertions(+) diff --git a/snippets/python.snippets b/snippets/python.snippets index a7bb708..ac9573b 100644 --- a/snippets/python.snippets +++ b/snippets/python.snippets @@ -201,3 +201,6 @@ snippet epydoc @raise e: ${0: Description} """ +snippet dol + def ${1:__init__}(self, *args, **kwargs): + super(${0:ClassName}, self).$1(*args, **kwargs) From 039a1c0801ff94c4cd1ed02bb2885ad2a44f963a Mon Sep 17 00:00:00 2001 From: Gilad Peleg Date: Thu, 10 Apr 2014 12:13:17 +0300 Subject: [PATCH 31/40] update meta charset in html --- UltiSnips/html.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UltiSnips/html.snippets b/UltiSnips/html.snippets index 31f7cc3..5746feb 100644 --- a/UltiSnips/html.snippets +++ b/UltiSnips/html.snippets @@ -194,7 +194,7 @@ endsnippet snippet head "XHTML " - + ${1:`!p snip.rv = snip.basename or "Page Title"`} $0 From fea2ddc0044a136f55a024ef5a4c10dee88f1993 Mon Sep 17 00:00:00 2001 From: Steeve Date: Thu, 10 Apr 2014 11:17:29 +0200 Subject: [PATCH 32/40] key word argument get (kwg) a common usage -especially when overloading class- is to use `*args` array and `**kwargs` dictionary to handle method's arguments this snippet is usefull to quickly get the argument value from the keyword arguments dictionary -kwargs- or setting a default value --- snippets/python.snippets | 2 ++ 1 file changed, 2 insertions(+) diff --git a/snippets/python.snippets b/snippets/python.snippets index ac9573b..799e061 100644 --- a/snippets/python.snippets +++ b/snippets/python.snippets @@ -204,3 +204,5 @@ snippet epydoc 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})${0:} From 76a4d7eae9c60b091a59aa85c7a2fc3a4fcfbe59 Mon Sep 17 00:00:00 2001 From: David Barnett Date: Fri, 11 Apr 2014 21:49:14 -0700 Subject: [PATCH 33/40] Add message and field snippets for proto filetype --- UltiSnips/proto.snippets | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 UltiSnips/proto.snippets diff --git a/UltiSnips/proto.snippets b/UltiSnips/proto.snippets new file mode 100644 index 0000000..079fbb4 --- /dev/null +++ b/UltiSnips/proto.snippets @@ -0,0 +1,30 @@ +priority -50 + +snippet mess "Proto message" b +// ${2:TODO(`whoami`): Describe this message.} +message ${1:Name} { + + // Next available id: 1 +} +endsnippet + +snippet reqf "Required field" b +// ${4:TODO(`whoami`): Describe this field.} +optional ${1:type} ${2:name} = ${3:1}; // Required +endsnippet + +snippet optf "Optional field" b +// ${4:TODO(`whoami`): Describe this field.} +optional ${1:type} ${2:name} = ${3:1}; +endsnippet + +snippet repf "Repeated field" b +// ${4:TODO(`whoami`): Describe this field.} +repeated ${1:type} ${2:name} = ${3:1}; +endsnippet + +snippet enum "Enumeration" b +// ${2:TODO(`whoami`): Describe this enum.} +enum ${1:Name} { +} +endsnippet From 4b9f18c53139a2dfe616850146d95f49c343c7bf Mon Sep 17 00:00:00 2001 From: Holger Rapp Date: Sun, 13 Apr 2014 10:24:56 +0200 Subject: [PATCH 34/40] Add a common pythonx directory containing helper methods for snippets. --- UltiSnips/rst.snippets | 23 ++--------------------- plugin/vimsnippets.vim | 37 +++++++++++++++++++++++++++++++++++++ pythonx/vimsnippets.py | 20 ++++++++++++++++++++ 3 files changed, 59 insertions(+), 21 deletions(-) create mode 100644 plugin/vimsnippets.vim create mode 100644 pythonx/vimsnippets.py diff --git a/UltiSnips/rst.snippets b/UltiSnips/rst.snippets index e8aef2b..3763a95 100644 --- a/UltiSnips/rst.snippets +++ b/UltiSnips/rst.snippets @@ -12,6 +12,8 @@ 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', @@ -130,27 +132,6 @@ def get_popular_code_type(): 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)) - endglobal snippet part "Part" b diff --git a/plugin/vimsnippets.vim b/plugin/vimsnippets.vim new file mode 100644 index 0000000..3c3ecf9 --- /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 0000000..b00edb1 --- /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)) From e3c6399f8c4406105ce2d70641b111f99c16e5a1 Mon Sep 17 00:00:00 2001 From: David Barnett Date: Sun, 13 Apr 2014 09:11:58 -0700 Subject: [PATCH 35/40] Add type completions --- UltiSnips/proto.snippets | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/UltiSnips/proto.snippets b/UltiSnips/proto.snippets index 079fbb4..973e911 100644 --- a/UltiSnips/proto.snippets +++ b/UltiSnips/proto.snippets @@ -1,5 +1,28 @@ 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} { @@ -10,17 +33,17 @@ endsnippet snippet reqf "Required field" b // ${4:TODO(`whoami`): Describe this field.} -optional ${1:type} ${2:name} = ${3:1}; // Required +optional ${1:type}`!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:type} ${2:name} = ${3:1}; +optional ${1:type}`!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:type} ${2:name} = ${3:1}; +repeated ${1:type}`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1}; endsnippet snippet enum "Enumeration" b From 3f3b2d561c87fc7db388270b3831853d43922998 Mon Sep 17 00:00:00 2001 From: David Barnett Date: Sun, 13 Apr 2014 09:17:57 -0700 Subject: [PATCH 36/40] Add tabstop for message body --- UltiSnips/proto.snippets | 1 + 1 file changed, 1 insertion(+) diff --git a/UltiSnips/proto.snippets b/UltiSnips/proto.snippets index 973e911..b09c4e6 100644 --- a/UltiSnips/proto.snippets +++ b/UltiSnips/proto.snippets @@ -26,6 +26,7 @@ endglobal snippet mess "Proto message" b // ${2:TODO(`whoami`): Describe this message.} message ${1:Name} { + $0 // Next available id: 1 } From cf39d41acc6bb2fae78d03d8cdc502256a2ca6ae Mon Sep 17 00:00:00 2001 From: David Barnett Date: Sun, 13 Apr 2014 22:58:20 -0700 Subject: [PATCH 37/40] rm unnecessary empty lines --- UltiSnips/proto.snippets | 2 -- 1 file changed, 2 deletions(-) diff --git a/UltiSnips/proto.snippets b/UltiSnips/proto.snippets index b09c4e6..adc5310 100644 --- a/UltiSnips/proto.snippets +++ b/UltiSnips/proto.snippets @@ -1,7 +1,6 @@ priority -50 global !p - from vimsnippets import complete FIELD_TYPES = [ @@ -20,7 +19,6 @@ FIELD_TYPES = [ 'bool', 'string', 'bytes'] - endglobal snippet mess "Proto message" b From 7f65658f47f18b2cf4669a898244c0bbef805d01 Mon Sep 17 00:00:00 2001 From: Steeve Date: Mon, 14 Apr 2014 12:28:03 +0200 Subject: [PATCH 38/40] remove useless $0 --- snippets/python.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/python.snippets b/snippets/python.snippets index 799e061..1ac0dd4 100644 --- a/snippets/python.snippets +++ b/snippets/python.snippets @@ -205,4 +205,4 @@ 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})${0:} + self.${1:var_name} = kwargs.get('$1', ${2:None}) From 593a3b79dff5ae60b2a18dd2930bd0669c92bd9e Mon Sep 17 00:00:00 2001 From: Steeve Date: Mon, 14 Apr 2014 12:30:29 +0200 Subject: [PATCH 39/40] lkwg LocalKeyWordargumentGet --- snippets/python.snippets | 2 ++ 1 file changed, 2 insertions(+) diff --git a/snippets/python.snippets b/snippets/python.snippets index 1ac0dd4..c221f46 100644 --- a/snippets/python.snippets +++ b/snippets/python.snippets @@ -206,3 +206,5 @@ snippet dol 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}) From 00231357c890fbe4808f3c69ce213877993ffe1d Mon Sep 17 00:00:00 2001 From: Holger Rapp Date: Wed, 16 Apr 2014 08:19:50 +0200 Subject: [PATCH 40/40] Remove placeholder text in proto snippets. --- UltiSnips/proto.snippets | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/UltiSnips/proto.snippets b/UltiSnips/proto.snippets index adc5310..923be57 100644 --- a/UltiSnips/proto.snippets +++ b/UltiSnips/proto.snippets @@ -32,17 +32,17 @@ endsnippet snippet reqf "Required field" b // ${4:TODO(`whoami`): Describe this field.} -optional ${1:type}`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1}; // Required +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:type}`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1}; +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:type}`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1}; +repeated ${1}`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1}; endsnippet snippet enum "Enumeration" b