From 3a93e890ebd660fa65fc53373b73cff6ad67f3f9 Mon Sep 17 00:00:00 2001 From: Enric Lluelles Date: Sun, 26 May 2013 23:33:29 +0200 Subject: [PATCH 01/16] Adding span# and span. snippets --- snippets/html.snippets | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/snippets/html.snippets b/snippets/html.snippets index cfc44ad..9693fe0 100644 --- a/snippets/html.snippets +++ b/snippets/html.snippets @@ -730,6 +730,10 @@ snippet source snippet span ${1} +snippet span# + ${2} +snippet span. + ${2} snippet strong ${1} snippet style From 234ddb7e702f3e4fdb127ed8fb8a916503da3fce Mon Sep 17 00:00:00 2001 From: babybeasimple Date: Fri, 31 May 2013 23:42:10 +0400 Subject: [PATCH 02/16] refactor ruby on rails validations with new style --- snippets/ruby.snippets | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/snippets/ruby.snippets b/snippets/ruby.snippets index 13522e3..ac97f33 100644 --- a/snippets/ruby.snippets +++ b/snippets/ruby.snippets @@ -849,24 +849,24 @@ snippet tctss ${1} snippet va validates_associated :${1:attribute} -snippet vao - validates_acceptance_of :${1:terms} +snippet va + validates :${1:terms}, :acceptance => true snippet vc - validates_confirmation_of :${1:attribute} + validates :${1:attribute}, :confirmation => true snippet ve - validates_exclusion_of :${1:attribute}, :in => ${2:%w( mov avi )} + validates :${1:attribute}, :exclusion => { :in => ${2:%w( mov avi )} } snippet vf - validates_format_of :${1:attribute}, :with => /${2:regex}/ + validates :${1:attribute}, :format => { :with => /${2:regex}/ } snippet vi - validates_inclusion_of :${1:attribute}, :in => %w(${2: mov avi }) + validates :${1:attribute}, :inclusion => { :in => %w(${2: mov avi }) } snippet vl - validates_length_of :${1:attribute}, :within => ${2:3}..${3:20} + validates :${1:attribute}, :length => { :in => ${2:3}..${3:20} } snippet vn - validates_numericality_of :${1:attribute} -snippet vpo - validates_presence_of :${1:attribute} + validates :${1:attribute}, :numericality => true +snippet vp + validates :${1:attribute}, :presence => true snippet vu - validates_uniqueness_of :${1:attribute} + validates :${1:attribute}, :uniqueness => true snippet wants wants.${1:js|xml|html} { ${2} } snippet wc From 2f72d327ecc6e8bc47adc946be6a961cb7c66e44 Mon Sep 17 00:00:00 2001 From: Eduardo Gurgel Date: Sat, 1 Jun 2013 04:13:23 -0300 Subject: [PATCH 03/16] Add syntax highlighting to README.md --- README.md | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 1c94978..cb9074b 100644 --- a/README.md +++ b/README.md @@ -86,19 +86,23 @@ add snippets/ruby-1.9.snippets (1.9 only) then configure github.com/garbas/vim-snipmate this way: - let g:snipMate = {} - let g:snipMate.scope_aliases = {} - let g:snipMate.scope_aliases['ruby'] = 'ruby,ruby-rails,ruby-1.9' + +```vim +let g:snipMate = {} +let g:snipMate.scope_aliases = {} +let g:snipMate.scope_aliases['ruby'] = 'ruby,ruby-rails,ruby-1.9' +``` or github.com/MarcWeber/UltiSnips this way: - let g:UltiSnips = {} - - let g:UltiSnips.snipmate_ft_filter = { - \ 'default' : {'filetypes': ["FILETYPE"] }, - \ 'ruby' : {'filetypes': ["ruby", "ruby-rails", "ruby-1.9"] }, +```vim +let g:UltiSnips = {} +let g:UltiSnips.snipmate_ft_filter = { + \ 'default' : {'filetypes': ["FILETYPE"] }, + \ 'ruby' : {'filetypes': ["ruby", "ruby-rails", "ruby-1.9"] }, +``` If it happens that you work on a project requiring ruby-1.8 snippets instead, consider using vim-addon-local-vimrc and override the filetypes. From b1bca66a11f21027d3f041943446ee280775dbad Mon Sep 17 00:00:00 2001 From: Iuri Fernandes Date: Sat, 1 Jun 2013 10:39:30 -0300 Subject: [PATCH 04/16] Add elixir snippets. --- snippets/elixir.snippets | 93 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 snippets/elixir.snippets diff --git a/snippets/elixir.snippets b/snippets/elixir.snippets new file mode 100644 index 0000000..449071c --- /dev/null +++ b/snippets/elixir.snippets @@ -0,0 +1,93 @@ +snippet if if .. do .. end + if ${1} do + ${2} + end + +snippet if if .. do: .. + if ${1:condition}, do: ${2} + +snippet ife if .. do .. else .. end + if ${1:condition} do + ${2} + else + ${3} + end + +snippet ife if .. do: .. else: + if ${1:condition}, do: ${2}, else: ${3} + +snippet case + case ${1} do + match: ${2} + ${3} + end + +snippet def + def ${1:name} do + ${2} + end + +snippet defim + defimpl ${1:protocol_name}, for: ${2:data_type} do + ${3} + end + +snippet defma + defmacro ${1:name} do + ${2} + end + +snippet defmo + defmodule ${1:module_name} do + ${2} + end + +snippet defp + defp ${1:name} do + ${2} + end + +snippet defpr + defprotocol ${1:name}, [${2:function}] + +snippet defr + defrecord ${1:record_name}, ${2:functions} + +snippet doc + @doc """ + ${1} + """ + +snippet fn + fn(${1:args}) -> ${2} end + +snippet loop + loop ${1:values}, ${2:initial} do + match: ${3} + ${4} + end + +snippet mdoc + @moduledoc """ + ${1} + """ + +snippet rec + receive do + match: ${1} + ${2} + end + +snippet req + require ${1:module_name}, as: ${2:alias} + +snippet test + test "${1:test_name}" do + ${2} + end + +snippet try + try do + catch: ${1} + ${2} + end From 4b42fc04b625338819f8fbc26ef7f2267aed5f30 Mon Sep 17 00:00:00 2001 From: Eduardo Gurgel Date: Sat, 1 Jun 2013 22:43:20 -0300 Subject: [PATCH 05/16] Update elixir snippets to stable Elixir lang --- snippets/elixir.snippets | 51 ++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/snippets/elixir.snippets b/snippets/elixir.snippets index 449071c..9c562ad 100644 --- a/snippets/elixir.snippets +++ b/snippets/elixir.snippets @@ -16,9 +16,33 @@ snippet ife if .. do .. else .. end snippet ife if .. do: .. else: if ${1:condition}, do: ${2}, else: ${3} +snippet unless unless .. do .. end + unless ${1} do + ${2} + end + +snippet unless unless .. do: .. + unless ${1:condition}, do: ${2} + +snippet unlesse unless .. do .. else .. end + unless ${1:condition} do + ${2} + else + ${3} + end + +snippet unlesse unless .. do: .. else: + unless ${1:condition}, do: ${2}, else: ${3} + +snippet cond + cond do + ${1} -> + ${2} + end + snippet case case ${1} do - match: ${2} + ${2} -> ${3} end @@ -51,7 +75,7 @@ snippet defpr defprotocol ${1:name}, [${2:function}] snippet defr - defrecord ${1:record_name}, ${2:functions} + defrecord ${1:record_name}, ${2:fields} snippet doc @doc """ @@ -61,12 +85,6 @@ snippet doc snippet fn fn(${1:args}) -> ${2} end -snippet loop - loop ${1:values}, ${2:initial} do - match: ${3} - ${4} - end - snippet mdoc @moduledoc """ ${1} @@ -74,20 +92,27 @@ snippet mdoc snippet rec receive do - match: ${1} + ${1} -> ${2} end snippet req - require ${1:module_name}, as: ${2:alias} + require ${1:module_name} + +snippet imp + import ${1:module_name} + +snippet ali + alias ${1:module_name} snippet test test "${1:test_name}" do ${2} end -snippet try +snippet try try .. rescue .. end try do - catch: ${1} - ${2} + ${1} + rescue + ${2} -> ${3} end From bc17b3d0231316962144fbdc3619a98f15c9e6d6 Mon Sep 17 00:00:00 2001 From: Iuri Fernandes Date: Tue, 4 Jun 2013 10:30:10 -0300 Subject: [PATCH 06/16] Fix ruby snippets with the same name --- snippets/ruby.snippets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/ruby.snippets b/snippets/ruby.snippets index ac97f33..027edf4 100644 --- a/snippets/ruby.snippets +++ b/snippets/ruby.snippets @@ -847,9 +847,9 @@ snippet tcts snippet tctss t.timestamps ${1} -snippet va +snippet va validates_associated validates_associated :${1:attribute} -snippet va +snippet va validates .., :acceptance => true validates :${1:terms}, :acceptance => true snippet vc validates :${1:attribute}, :confirmation => true From fb20738cf4082212d5021c031f1d621352308a7c Mon Sep 17 00:00:00 2001 From: babybeasimple Date: Thu, 6 Jun 2013 01:20:03 +0400 Subject: [PATCH 07/16] fix haml render snipets --- snippets/haml.snippets | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/snippets/haml.snippets b/snippets/haml.snippets index 61e9cf2..4491c2b 100644 --- a/snippets/haml.snippets +++ b/snippets/haml.snippets @@ -11,10 +11,12 @@ snippet ul %li ${1:item} %li -snippet =rp - = render :partial => '${1:partial}' -snippet =rpl - = render :partial => '${1:partial}', :locals => {} -snippet =rpc - = render :partial => '${1:partial}', :collection => @$1 +snippet rp + = render :partial => "${1:item}" +snippet rpc + = render :partial => "${1:item}", :collection => ${2:@$1s} +snippet rpl + = render :partial => "${1:item}", :locals => { :${2:$1} => ${3:@$1} +snippet rpo + = render :partial => "${1:item}", :object => ${2:@$1} From c8783fd02f0688612abc9cbd85edacaea2f3f319 Mon Sep 17 00:00:00 2001 From: Marc Weber Date: Thu, 6 Jun 2013 13:44:17 +0200 Subject: [PATCH 08/16] adding alternative html-minimal snippets illustrating a somewhat minimal setup which is useful to me --- UltiSnips/html_minimal.snippets | 31 ++++++++++++++ snippets/html_minimal.snippets | 74 +++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 UltiSnips/html_minimal.snippets create mode 100644 snippets/html_minimal.snippets diff --git a/UltiSnips/html_minimal.snippets b/UltiSnips/html_minimal.snippets new file mode 100644 index 0000000..1f77ad7 --- /dev/null +++ b/UltiSnips/html_minimal.snippets @@ -0,0 +1,31 @@ +# more can be found in snippets/html_minimal.snippets +# these UltiSnips override snippets because nested placeholders are being used + +snippet id +id="${1}"${2} +endsnippet + +snippet idn +id="${1}" name="${2:$1}" +endsnippet + +snippet label_and_input + +${8} +endsnippet + +snippet input +${7} +endsnippet + +snippet textarea + +endsnippet + +snippet img + $3 +endsnippet diff --git a/snippets/html_minimal.snippets b/snippets/html_minimal.snippets new file mode 100644 index 0000000..ce971ef --- /dev/null +++ b/snippets/html_minimal.snippets @@ -0,0 +1,74 @@ +# file containing most useful mappings only +# when editing this file please be aware that there is ZenCoding and sparkup + +# html 5 is recommended from now on +snippet html5 + + + + $2 + + $3 + + + $4 + + + +# ==== TAGS +# you always need these: +snippet . + class="${1}"${2} +snippet n + name="${1}"${2} +snippet r + rel="${1}"${2} +snippet t + title="${1}"${2} + +# not using # because id is faster to type +snippet id + id="${1}"${2} +snippet idn + id="${1}" name="${2:$1}" + +snippet label_and_input + + ${7} + + +# FORMS +# use idn . or n to add id +snippet input + ${7} +snippet submit + ${7} +snippet textarea + + +# if you need id or class use snippets above +snippet form +
+ $3 +
+ +# other tags +snippet br +
+snippet a + $3 +snippet img + $2 +# JS/CSS +snippet css_file + ${3} +snippet css_block + + + +snippet script_block + +snippet script_file + From 1871372934ce78f2fa7d047d0647ff7633398032 Mon Sep 17 00:00:00 2001 From: Steven Oliver Date: Fri, 7 Jun 2013 14:43:24 -0300 Subject: [PATCH 09/16] Add myself as maintainer of the Falcon snippets --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index cb9074b..99bd980 100644 --- a/README.md +++ b/README.md @@ -133,6 +133,7 @@ vim-snippets is not like the "linux kernel". * Ruby - [taq](http://github.com/taq) * PHP - [chrisyue](http://github.com/chrisyue) * Scala - [gorodinskiy](https://github.com/gorodinskiy) +* Falcon - [steveno](https://github.com/steveno) Contributing notes ------------------ From e92b1e83f9e5d02713b80efdc1dd047467f531dc Mon Sep 17 00:00:00 2001 From: Donny Yang Date: Sat, 8 Jun 2013 08:14:52 +0900 Subject: [PATCH 10/16] binding function should be usable in middle of a line --- UltiSnips/coffee.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UltiSnips/coffee.snippets b/UltiSnips/coffee.snippets index 8f347f1..371859f 100644 --- a/UltiSnips/coffee.snippets +++ b/UltiSnips/coffee.snippets @@ -5,7 +5,7 @@ ${1:name} = (${2:args}) -> ${0:# body...} endsnippet -snippet bfun "Function (bound)" b +snippet bfun "Function (bound)" ${1:(${2:args}) }=> ${0:# body...} endsnippet From f216cebf5479e91db3a007d30d12e1f7430f2783 Mon Sep 17 00:00:00 2001 From: Donny Yang Date: Sat, 8 Jun 2013 08:25:02 +0900 Subject: [PATCH 11/16] Interpolated Code should be usable as in-word snippet --- UltiSnips/coffee.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UltiSnips/coffee.snippets b/UltiSnips/coffee.snippets index 371859f..a61dc5c 100644 --- a/UltiSnips/coffee.snippets +++ b/UltiSnips/coffee.snippets @@ -80,7 +80,7 @@ snippet req "Require" b ${1/^'?(\w+)'?$/\L$1\E/} = require(${1:'${2:sys}'}) endsnippet -snippet # "Interpolated Code" +snippet # "Interpolated Code" i #{$1}$0 endsnippet From f16295f3c135b151192d0020c36b6ba2cc07a559 Mon Sep 17 00:00:00 2001 From: Donny Yang Date: Sat, 8 Jun 2013 08:29:31 +0900 Subject: [PATCH 12/16] It is better to have an else clause in a switch --- UltiSnips/coffee.snippets | 2 ++ 1 file changed, 2 insertions(+) diff --git a/UltiSnips/coffee.snippets b/UltiSnips/coffee.snippets index a61dc5c..db7e985 100644 --- a/UltiSnips/coffee.snippets +++ b/UltiSnips/coffee.snippets @@ -58,6 +58,8 @@ endsnippet snippet swi "Switch" b switch ${1:object} when ${2:value} + ${3:# body...} + else ${0:# body...} endsnippet From 81f85934428472c8965bb5c6ca8810f52475c4f9 Mon Sep 17 00:00:00 2001 From: Donny Yang Date: Sat, 8 Jun 2013 23:45:35 +0900 Subject: [PATCH 13/16] inline snippets, arg-less function, new swit snippet --- UltiSnips/coffee.snippets | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/UltiSnips/coffee.snippets b/UltiSnips/coffee.snippets index db7e985..3e923dc 100644 --- a/UltiSnips/coffee.snippets +++ b/UltiSnips/coffee.snippets @@ -1,7 +1,8 @@ # From the TextMate bundle +# with some modification snippet fun "Function" b -${1:name} = (${2:args}) -> +${1:name} = ${2:(${3:args}) }-> ${0:# body...} endsnippet @@ -10,12 +11,12 @@ ${1:(${2:args}) }=> ${0:# body...} endsnippet -snippet if "If" b +snippet if "If" if ${1:condition} ${0:# body...} endsnippet -snippet ife "If .. Else" b +snippet ife "If .. Else" if ${1:condition} ${2:# body...} else @@ -27,40 +28,46 @@ else if ${1:condition} ${0:# body...} endsnippet -snippet ifte "Ternary if" b +snippet ifte "Ternary if" if ${1:condition} then ${2:value} else ${3:other} endsnippet -snippet unl "Unless" b +snippet unl "Unless" ${1:action} unless ${2:condition} endsnippet -snippet fora "Array Comprehension" b +snippet fora "Array Comprehension" for ${1:name} in ${2:array} ${0:# body...} endsnippet -snippet foro "Object Comprehension" b +snippet foro "Object Comprehension" for ${1:key}, ${2:value} of ${3:Object} ${0:# body...} endsnippet -snippet forr "Range Comprehension (inclusive)" b +snippet forr "Range Comprehension (inclusive)" for ${1:name} in [${2:start}..${3:finish}]${4: by ${5:step}} ${0:# body...} endsnippet -snippet forrex "Range Comprehension (exclusive)" b +snippet forrex "Range Comprehension (exclusive)" for ${1:name} in [${2:start}...${3:finish}]${4: by ${5:step}} ${0:# body...} endsnippet -snippet swi "Switch" b +snippet swi "Switch" switch ${1:object} when ${2:value} ${3:# body...} else - ${0:# body...} + $0 +endsnippet + +snippet swit "Switch when .. then" +switch ${1:object} + when ${2:${3:condition} then ${4:value}} + else ${0:value} endsnippet snippet cla "Class" b @@ -71,7 +78,7 @@ class ${1:ClassName}${2: extends ${3:Ancestor}} $7 endsnippet -snippet try "Try .. Catch" b +snippet try "Try .. Catch" try $1 catch ${2:error} From beedbaa29b5c9a5ab6df20c5b182f118c9b29aa7 Mon Sep 17 00:00:00 2001 From: Donny Yang Date: Mon, 10 Jun 2013 00:46:27 +0900 Subject: [PATCH 14/16] apply some python magic to reduce the tabstops needed --- UltiSnips/coffee.snippets | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/UltiSnips/coffee.snippets b/UltiSnips/coffee.snippets index 3e923dc..dab4608 100644 --- a/UltiSnips/coffee.snippets +++ b/UltiSnips/coffee.snippets @@ -2,13 +2,12 @@ # with some modification snippet fun "Function" b -${1:name} = ${2:(${3:args}) }-> +${1:name} = `!p snip.rv = "(" if t[2] else ""`${2:args}`!p snip.rv = ") " if t[2] else ""`-> ${0:# body...} endsnippet -snippet bfun "Function (bound)" -${1:(${2:args}) }=> - ${0:# body...} +snippet bfun "Function (bound)" i +`!p snip.rv = "(" if t[1] else ""`${1:args}`!p snip.rv = ") " if t[1] else ""`=>`!p snip.rv = " " if t[2] else ""`${2:expr} endsnippet snippet if "If" @@ -47,12 +46,12 @@ for ${1:key}, ${2:value} of ${3:Object} endsnippet snippet forr "Range Comprehension (inclusive)" -for ${1:name} in [${2:start}..${3:finish}]${4: by ${5:step}} +for ${1:name} in [${2:start}..${3:finish}]`!p snip.rv = " by " if t[4] else ""`${4:step} ${0:# body...} endsnippet snippet forrex "Range Comprehension (exclusive)" -for ${1:name} in [${2:start}...${3:finish}]${4: by ${5:step}} +for ${1:name} in [${2:start}...${3:finish}]`!p snip.rv = " by " if t[4] else ""`${4:step} ${0:# body...} endsnippet @@ -66,16 +65,16 @@ endsnippet snippet swit "Switch when .. then" switch ${1:object} - when ${2:${3:condition} then ${4:value}} - else ${0:value} + when ${2:condition}`!p snip.rv = " then " if t[3] else ""`${3:value} + else`!p snip.rv = " " if t[4] else ""`${4:value} endsnippet snippet cla "Class" b -class ${1:ClassName}${2: extends ${3:Ancestor}} +class ${1:ClassName}`!p snip.rv = " extends " if t[2] else ""`${2:Ancestor} - ${4:constructor: (${5:args}) -> - ${6:# body...}} - $7 + ${3:constructor:`!p snip.rv = " (" if t[4] else ""`${4:args}`!p snip.rv = ")" if t[4] else ""` -> + ${5:# body...}} + $0 endsnippet snippet try "Try .. Catch" From ee2a486dacfa5210ce4554e3c27ff034b9fb21fe Mon Sep 17 00:00:00 2001 From: Donny Yang Date: Mon, 10 Jun 2013 02:08:39 +0900 Subject: [PATCH 15/16] add newline checks to avoid leaving trailing whitespace --- UltiSnips/coffee.snippets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UltiSnips/coffee.snippets b/UltiSnips/coffee.snippets index dab4608..bb451aa 100644 --- a/UltiSnips/coffee.snippets +++ b/UltiSnips/coffee.snippets @@ -7,7 +7,7 @@ ${1:name} = `!p snip.rv = "(" if t[2] else ""`${2:args}`!p snip.rv = ") " if t[2 endsnippet snippet bfun "Function (bound)" i -`!p snip.rv = "(" if t[1] else ""`${1:args}`!p snip.rv = ") " if t[1] else ""`=>`!p snip.rv = " " if t[2] else ""`${2:expr} +`!p snip.rv = "(" if t[1] else ""`${1:args}`!p snip.rv = ") " if t[1] else ""`=>`!p snip.rv = " " if t[2] and not t[2].startswith("\n") else ""`${2:expr} endsnippet snippet if "If" @@ -66,7 +66,7 @@ endsnippet snippet swit "Switch when .. then" switch ${1:object} when ${2:condition}`!p snip.rv = " then " if t[3] else ""`${3:value} - else`!p snip.rv = " " if t[4] else ""`${4:value} + else`!p snip.rv = " " if t[4] and not t[4].startswith("\n") else ""`${4:value} endsnippet snippet cla "Class" b From 057a066f9c549e445fcbd519e7785db0bf16a380 Mon Sep 17 00:00:00 2001 From: George Lee Date: Mon, 10 Jun 2013 21:37:09 +0800 Subject: [PATCH 16/16] add if/ife snippets to eruby --- snippets/eruby.snippets | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/snippets/eruby.snippets b/snippets/eruby.snippets index 592e490..721116c 100644 --- a/snippets/eruby.snippets +++ b/snippets/eruby.snippets @@ -111,3 +111,13 @@ snippet slt <%= stylesheet_link_tag ${1::all}, :cache => ${2:true} %> snippet sslt <%= stylesheet_link_tag "${1}" %> +snippet if + <% if ${1} %> + ${2} + <% end %> +snippet ife + <% if ${1} %> + ${2} + <% else %> + ${3} + <% end %>