From 533fe487a1f7af9cbbf13db27dc75f501a13ce79 Mon Sep 17 00:00:00 2001 From: Marc Weber Date: Mon, 8 Jul 2013 23:44:03 +0200 Subject: [PATCH] ruby snippets: use do dov for both engines drop #TODO comments changing defaults is bad, but I expect ruby folks to expect do to type do .. doo has the advantage to get a completion popup .. but its too long to type The UtiSnips do snippet didn't make sense: the nested placeholder still didn't remove the space after the "do" when deleting it - so it was written badly. Could be fixed, by why bother? Thus learn do and dov and be happy forever. Would Do be a better choice (upper case chars?) Don't know. This was used by UltiSnips. Comment on this commit if you don't like this choice. --- UltiSnips/ruby.snippets | 120 ++++++++++++++++++++-------------------- snippets/ruby.snippets | 10 +++- 2 files changed, 66 insertions(+), 64 deletions(-) diff --git a/UltiSnips/ruby.snippets b/UltiSnips/ruby.snippets index 6336589..306c7e1 100644 --- a/UltiSnips/ruby.snippets +++ b/UltiSnips/ruby.snippets @@ -25,7 +25,7 @@ endsnippet snippet if "if ... end" if ${1:condition} - ${2:# TODO} + ${2} end endsnippet @@ -33,9 +33,9 @@ endsnippet snippet ife "if ... else ... end" if ${1:condition} - ${2:# TODO} + ${2} else - ${3:# TODO} + ${3} end endsnippet @@ -43,11 +43,11 @@ endsnippet snippet ifee "if ... elseif ... else ... end" if ${1:condition} - ${2:# TODO} + ${2} elsif ${3:condition} - ${4:# TODO} + ${4} else - ${0:# TODO} + ${0} end endsnippet @@ -55,7 +55,7 @@ endsnippet snippet unless "unless ... end" unless ${1:condition} - ${0:# TODO} + ${0} end endsnippet @@ -63,9 +63,9 @@ endsnippet snippet unlesse "unless ... else ... end" unless ${1:condition} - ${2:# TODO} + ${2} else - ${0:# TODO} + ${0} end endsnippet @@ -73,11 +73,11 @@ endsnippet snippet unlesee "unless ... elseif ... else ... end" unless ${1:condition} - ${2:# TODO} + ${2} elsif ${3:condition} - ${4:# TODO} + ${4} else - ${0:# TODO} + ${0} end endsnippet @@ -85,7 +85,7 @@ endsnippet snippet "\b(de)?f" "def ..." r def ${1:function_name}${2: ${3:*args}} - ${0:# TODO} + ${0} end endsnippet @@ -93,7 +93,7 @@ endsnippet snippet defi "def initialize ..." def initialize${1: ${2:*args}} - ${0:# TODO} + ${0} end endsnippet @@ -101,23 +101,23 @@ endsnippet snippet defr "def ... rescue ..." def ${1:function_name}${2: ${3:*args}} - ${4:# TODO} + ${4} rescue - ${0:# TODO} + ${0} end endsnippet snippet For "(..).each { || }" -(${1:from}..${2:to}).each { |${3:i}| ${4:# TODO} } +(${1:from}..${2:to}).each { |${3:i}| ${4} } endsnippet snippet for "(..).each do || end" (${1:from}..${2:to}).each do |${3:i}| - ${0:# TODO} + ${0} end endsnippet @@ -138,42 +138,42 @@ endsnippet snippet "(\S+)\.Del(ete)?_?if" ".delete_if { |,| }" r -`!p snip.rv=match.group(1)`.delete_if { |${1:key},${2:value}| ${3:# TODO} } +`!p snip.rv=match.group(1)`.delete_if { |${1:key},${2:value}| ${3} } 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:# TODO} + ${0} end endsnippet snippet "(\S+)\.Keep_?if" ".keep_if { |,| }" r -`!p snip.rv=match.group(1)`.keep_if { |${1:key},${2:value}| ${3:# TODO} } +`!p snip.rv=match.group(1)`.keep_if { |${1:key},${2:value}| ${3} } endsnippet snippet "(\S+)\.keep_?if" ".keep_if do ,| end" r `!p snip.rv=match.group(1)`.keep_if do |${1:key},${2:value}| - ${0:# TODO} + ${0} end endsnippet snippet "(\S+)\.Reject" ".reject { |,| }" r -`!p snip.rv=match.group(1)`.reject { |${1:key},${2:value}| ${3:# TODO} } +`!p snip.rv=match.group(1)`.reject { |${1:key},${2:value}| ${3} } endsnippet snippet "(\S+)\.reject" ".reject do ,| end" r `!p snip.rv=match.group(1)`.reject do |${1:key},${2:value}| - ${0:# TODO} + ${0} end endsnippet @@ -194,56 +194,56 @@ endsnippet snippet "(\S+)\.Sort" ".sort { |,| }" r -`!p snip.rv=match.group(1)`.sort { |${1:a},${2:b}| ${3:# TODO} } +`!p snip.rv=match.group(1)`.sort { |${1:a},${2:b}| ${3} } endsnippet snippet "(\S+)\.sort" ".sort do |,| end" r `!p snip.rv=match.group(1)`.sort do |${1:a},${2:b}| - ${0:# TODO} + ${0} end endsnippet snippet "(\S+)\.Each_?k(ey)?" ".each_key { || }" r -`!p snip.rv=match.group(1)`.each_key { |${1:key}| ${2:# TODO} } +`!p snip.rv=match.group(1)`.each_key { |${1:key}| ${2} } endsnippet snippet "(\S+)\.each_?k(ey)?" ".each_key do |key| end" r `!p snip.rv=match.group(1)`.each_key do |${1:key}| - ${0:# TODO} + ${0} end endsnippet snippet "(\S+)\.Each_?val(ue)?" ".each_value { || }" r -`!p snip.rv=match.group(1)`.each_value { |${1:value}| ${2:# TODO} } +`!p snip.rv=match.group(1)`.each_value { |${1:value}| ${2} } endsnippet snippet "(\S+)\.each_?val(ue)?" ".each_value do || end" r `!p snip.rv=match.group(1)`.each_value do |${1:value}| - ${0:# TODO} + ${0} end endsnippet snippet Each ".each { || }" -${1:elements}.each { |${2:${1/s$//}}| ${3:# TODO} } +${1:elements}.each { |${2:${1/s$//}}| ${3} } endsnippet snippet each ".each do || end" ${1:elements}.each do |${2:${1/s$//}}| - ${0:# TODO} + ${0} end endsnippet @@ -251,14 +251,14 @@ endsnippet snippet each_?s(lice)? ".each_slice(n) do |slice| end" each_slice(${1:2}) do |${2:slice}| - ${0:# TODO} + ${0} end endsnippet snippet Each_?s(lice)? ".each_slice(n) { |slice| }" -each_slice(${1:2}) { |${2:slice}| ${3:# TODO} } +each_slice(${1:2}) { |${2:slice}| ${3} } endsnippet @@ -273,7 +273,7 @@ try: snip.rv = wmatch.group(1).lower() except: snip.rv = 'element' -`}| ${2:# TODO} } +`}| ${2} } endsnippet @@ -288,7 +288,7 @@ try: except: snip.rv = 'element' `}| - ${0:# TODO} + ${0} end endsnippet @@ -303,7 +303,7 @@ try: snip.rv = wmatch.group(1).lower() except: snip.rv = 'element' -`}| ${2:# TODO} } +`}| ${2} } endsnippet @@ -318,7 +318,7 @@ try: except: snip.rv = 'element' `}| - ${0:# TODO} + ${0} end endsnippet @@ -333,7 +333,7 @@ try: snip.rv = wmatch.group(1).lower() except: snip.rv = 'element' -`}| ${2:# TODO} } +`}| ${2} } endsnippet @@ -348,7 +348,7 @@ try: except: snip.rv = 'element' `}| - ${0:# TODO} + ${0} end endsnippet @@ -364,7 +364,7 @@ try: snip.rv = wmatch.group(1).lower() except: snip.rv = 'element' -`},${2:i}| ${3:# TODO} }$0 +`},${2:i}| ${3} }$0 endsnippet @@ -379,7 +379,7 @@ try: except: snip.rv = 'element' `},${2:i}| - ${0:# TODO} + ${0} end endsnippet @@ -387,14 +387,14 @@ endsnippet snippet "(\S+)\.Each_?p(air)?" ".each_pair { |,| }" r -`!p snip.rv=match.group(1)`.each_pair { |${1:key},${2:value}| ${3:# TODO} } +`!p snip.rv=match.group(1)`.each_pair { |${1:key},${2:value}| ${3} } 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:# TODO} + ${0} end endsnippet @@ -424,26 +424,24 @@ snippet "(\S+)\.Index" ".index do |item| ... end" r end endsnippet - - -snippet do "do || ... end" i -do ${1:|${2:key}|} - $0 -end -endsnippet - - - -snippet Do "do ... end" i +# comments about do and dov see snippets/ruby.snippets +snippet do "do ... end" i do $0 end endsnippet +snippet dov "do || ... end" i +do |${0:v}| + $1 +end +endsnippet + + snippet until "until ... end" until ${1:expression} - ${0:# TODO} + ${0} end endsnippet @@ -451,7 +449,7 @@ endsnippet snippet Until "begin ... end until " begin - ${0:# TODO} + ${0} end until ${1:expression} endsnippet @@ -459,7 +457,7 @@ endsnippet snippet while "while ... end" while ${1:expression} - ${0:# TODO} + ${0} end endsnippet @@ -467,7 +465,7 @@ endsnippet snippet While "begin ... end while " begin - ${0:# TODO} + ${0} end while ${1:expression} endsnippet @@ -493,9 +491,9 @@ endsnippet snippet begin "begin ... rescue ... end" begin - ${1:# TODO} + ${1} rescue - ${0:# TODO} + ${0} end endsnippet diff --git a/snippets/ruby.snippets b/snippets/ruby.snippets index 9c99479..73db366 100644 --- a/snippets/ruby.snippets +++ b/snippets/ruby.snippets @@ -413,13 +413,17 @@ snippet seld end snippet lam lambda { |${1:args}| ${2} } -snippet doo +# I'm pretty sure that ruby users expect do to expand to do .. end +snippet do do ${1} end +# this is for one or more variables. typing a ", " is that cheap that it may +# not be worth adding another snippet. should 0/1 placeholders change order? +# its a good idea to think about the var name, so use it first snippet dov - do |${1:variable}| - ${2} + do |${0:v}| + ${1} end snippet : :${1:key} => ${2:"value"}${3}