1
0
mirror of https://github.com/amix/vimrc synced 2025-06-16 01:25:00 +08:00

Updated plugins

This commit is contained in:
amix
2013-07-17 19:06:05 -04:00
parent 879a7b6bd4
commit a448b32309
85 changed files with 2174 additions and 941 deletions

View File

@ -1,75 +1,83 @@
# From the TextMate bundle
# with some modification
snippet fun "Function" b
${1:name} = (${2: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)" b
${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] and not t[2].startswith("\n") else ""`${2:expr}
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
${3:# body...}
endsnippet
snippet elif "Else if" b
snippet eif "Else if" b
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
for ${1:name} in [${2:start}..${3:finish}]${4: by ${5:step}}
snippet forr "Range Comprehension (inclusive)"
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)" b
for ${1:name} in [${2:start}...${3:finish}]${4: by ${5:step}}
snippet forrex "Range Comprehension (exclusive)"
for ${1:name} in [${2:start}...${3:finish}]`!p snip.rv = " by " if t[4] else ""`${4:step}
${0:# body...}
endsnippet
snippet swi "Switch" b
snippet swi "Switch"
switch ${1:object}
when ${2:value}
${0:# body...}
${3:# body...}
else
$0
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] and not t[4].startswith("\n") 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" b
snippet try "Try .. Catch"
try
$1
catch ${2:error}
@ -80,7 +88,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

View File

@ -126,7 +126,7 @@ else
}
endsnippet
snippet elif "else if (elif)" b
snippet eif "else if (elif)" b
else if(${1:/*condition*/})
{
${VISUAL}${0:/*code*/}
@ -576,7 +576,7 @@ snippet module "New module (module)" b
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
module ${2}.`!v Filename('$1', 'name')`;
module ${2}.`!v vim_snippets#Filename('$1', 'name')`;
${3}

View File

@ -76,7 +76,7 @@ snippet if
{% endif %}
endsnippet
snippet else
snippet el
{% else %}
${1}
endsnippet

View File

@ -263,7 +263,7 @@ snippet st "submit_tag"
`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`submit_tag "${1:Save changes}"${2:, :id => "${3:submit}"}${4:, :name => "${5:$3}"}${6:, :class => "${7:form_$3}"}${8:, :disabled => ${9:false}}${10:, :disable_with => "${11:Please wait...}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`
endsnippet
snippet else "else (ERB)"
snippet el "else (ERB)"
<% else %>
endsnippet

View File

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

View File

@ -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
<label for="${2:$1}">${1}</label>
<input type="${3:text}" name="${4:$2}"${5: id="${6:$2}"} value="${7}" />${8}
endsnippet
snippet input
<input type="${1:text}" value="${2}" name="${3}"${4: id="${5:$3}}/>${7}
endsnippet
snippet submit
<input type="submit" value="${2}" ${3}/>${7}
endsnippet
snippet textarea
<textarea name="$2"${3: id="$4"}>$5</textarea>
endsnippet
snippet img
<img src="$1"${2: alt="$3"}/>
endsnippet

View File

@ -59,7 +59,7 @@ default:
$0
endsnippet
snippet elif "else if" b
snippet eif "else if" b
else if ($1)`!p nl(snip)`{
$0
}

View File

@ -50,12 +50,19 @@ function ${1:function_name} (${2:argument}) {
}
endsnippet
# for one line if .. else you usually use a ? b : c
snippet ife "if ___ else"
if (${1:true}) {$0} else{};
if (${1}) {
{$2}
} else {
{$3}
};
endsnippet
snippet if "if"
if (${1:true}) {$0};
if (${1}) {
{$2}
};
endsnippet
snippet timeout "setTimeout function"

View File

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

View File

@ -11,8 +11,8 @@ endsnippet
snippet do "do"
do {
${2:// code... }
} while (${1:/* condition */});"
${2}
} while (${1});"
endsnippet
snippet doc_f "doc_f"
@ -37,21 +37,21 @@ interface ${1:someClass}
} // END interface $1"
endsnippet
snippet else "else"
snippet el "else"
else {
${1:// code...}
${1}
}
endsnippet
snippet for "for"
for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {
${4:// code...}
${4}
}
endsnippet
snippet foreachk "foreachk"
foreach ($${1:variable} as $${2:key} => $${3:value}){
${4:// code...}
${4}
}
endsnippet
@ -60,8 +60,8 @@ $_GET['${1}']${2}
endsnippet
snippet if "if"
if (${1:/* condition */}) {
${2:// code...}
if (${1}) {
${2}
}
endsnippet
@ -210,9 +210,9 @@ endsnippet
snippet ife "if else"
if (${1:/* condition */}) {
${2:// code...}
${2}
} else {
${3:// code...}
${3}
}
$0
endsnippet
@ -227,7 +227,7 @@ class $1
{
public function ${3:__construct}(${4:$options})
{
${4:// code}
${4}
}
}
$0

View File

@ -1,61 +1,314 @@
# -*- coding: utf-8 -*-
###########################################################################
# General Stuff #
###########################################################################
global !p
import vim
from os import path as ospath
from string import Template
import re
from collections import Counter
#http://docutils.sourceforge.net/docs/ref/rst/roles.html
TEXT_ROLES = ['emphasis','literal','code','math',
'pep-reference','rfc-reference',
'strong','subscript','superscript',
'title-reference','raw']
TEXT_ROLES_REGEX = r'\.\.\srole::?\s(w+)'
#http://docutils.sourceforge.net/docs/ref/rst/directives.html#specific-admonitions
SPECIFIC_ADMONITIONS = ["attention", "caution", "danger",
"error", "hint", "important", "note",
"tip", "warning"]
#http://docutils.sourceforge.net/docs/ref/rst/directives.html
DIRECTIVES = ['topic','sidebar','math','epigraph',
'parsed-literal','code','highlights',
'pull-quote','compound','container',
'list-table','class','sectnum',
'role','default-role','unicode',
'raw']
NONE_CONTENT_DIRECTIVES = ['rubric', 'contents', 'header',
'footer', 'date', 'include', 'title']
INCLUDABLE_DIRECTIVES = ['image', 'figure', 'include']
# CJK chars
# http://stackoverflow.com/questions/2718196/find-all-chinese-text-in-a-string-using-python-and-regex
CJK_RE = re.compile(u'[⺀-⺙⺛-⻳⼀-⿕々〇〡-〩〸-〺〻㐀-䶵一-鿃豈-鶴侮-頻並-龎]', re.UNICODE)
def has_cjk(char):
"""
Detect char contains CJK character
:param char: characters needs to be detect
"""
try:
CJK_RE.finditer(char).next()
except StopIteration:
return False
else:
return True
def real_filename(filename):
"""peal extension name off if possible
# i.e. "foo.bar.png will return "foo.bar"
"""
return ospath.splitext(filename)[0]
def check_file_exist(rst_path, relative_path):
"""
For RST file, it can just include files as relative path.
:param rst_path: absolute path to rst file
:param relative_path: path related to rst file
:return: relative file's absolute path if file exist
"""
abs_path = ospath.join(ospath.dirname(rst_path), relative_path)
if ospath.isfile(abs_path):
return abs_path
def rst_char_len(char):
"""
return len of string which fit in rst
For instance:chinese "我" decode as only one character,
However, the rst interpreter needs 2 "=" instead of 1.
:param: char needs to be count
"""
return len(re.findall(r'[^\u4e00-\u9fff\s]', char))+len(char)
def make_items(times, leading='+'):
"""
make lines with leading char multitimes
:param: times, how many times you need
:param: leading, leading character
"""
times = int(times)
if leading == 1:
msg = ""
for x in xrange(1, times+1):
msg += "%s. Item\n" % x
return msg
else:
return ("%s Item\n" % leading) * times
def look_up_directives(regex, fpath):
"""
find all directive args in given file
:param: regex, the regex that needs to match
:param: path, to path to rst file
:return: list, empty list if nothing match
"""
try:
with open(fpath) as source:
match = re.findall(regex, source.read())
except IOError:
match = []
return match
def get_popular_code_type():
"""
find most popular code type in the given rst
:param path: file to detect
:return: string, most popular code type in file
"""
buf = "".join(vim.current.buffer)
types = re.findall(r'[:|\.\.\s]code::?\s(\w+)', buf)
try:
popular_type = Counter(types).most_common()[0][0]
except IndexError:
popular_type = "lua" # Don't break default
return popular_type
def complete(t, opts):
"""
get options that start with t
:param t: query string
:param opts: list that needs to be completed
:return: a string that start with t
"""
msg = "({0})"
if t:
opts = [ m[len(t):] for m in opts if m.startswith(t) ]
if len(opts) == 1:
return opts[0]
if not len(opts):
msg = "{0}"
return msg.format("|".join(opts))
endglobal
snippet part "Part" b
`!p snip.rv = len(t[1])*'#'`
`!p snip.rv = rst_char_len(t[1])*'#'`
${1:Part name}
`!p snip.rv = len(t[1])*'#'`
`!p snip.rv = rst_char_len(t[1])*'#'`
$0
endsnippet
snippet sec "Section" b
${1:Section name}
`!p snip.rv = len(t[1])*'='`
`!p snip.rv = rst_char_len(t[1])*'='`
$0
endsnippet
snippet ssec "Subsection" b
${1:Section name}
`!p snip.rv = len(t[1])*'-'`
`!p snip.rv = rst_char_len(t[1])*'-'`
$0
endsnippet
snippet sssec "Subsubsection" b
${1:Section name}
`!p snip.rv = len(t[1])*'^'`
`!p snip.rv = rst_char_len(t[1])*'^'`
$0
endsnippet
snippet chap "Chapter" b
`!p snip.rv = len(t[1])*'*'`
`!p snip.rv = rst_char_len(t[1])*'*'`
${1:Chapter name}
`!p snip.rv = len(t[1])*'*'`
`!p snip.rv = rst_char_len(t[1])*'*'`
$0
endsnippet
snippet para "Paragraph" b
${1:Paragraph name}
`!p snip.rv = len(t[1])*'"'`
`!p snip.rv = rst_char_len(t[1])*'"'`
$0
endsnippet
snippet em "Emphasize string" i
`!p
# dirty but works with CJK charactor detection
if has_cjk(vim.current.line):
snip.rv ="\ "`*${1:${VISUAL:Em}}*`!p
if has_cjk(vim.current.line):
snip.rv ="\ "
else:
snip.rv = " "
`$0
endsnippet
snippet st "Strong string" i
`!p
if has_cjk(vim.current.line):
snip.rv ="\ "`**${1:${VISUAL:Strong}}**`!p
if has_cjk(vim.current.line):
snip.rv ="\ "
else:
snip.rv = " "
`$0
endsnippet
snippet "li(st)? (?P<num>\d+)" "List" br
$0
`!p
# usage: li 4<tab>
# which will extand into a unordered list contains 4 items
snip.rv = make_items(match.groupdict()['num'])
`
endsnippet
snippet "ol(st)? (?P<num>\d+)" "Order List" br
$0
`!p
# usage: ol 4<tab>
# which will extand into a ordered list contains 4 items
snip.rv = make_items(match.groupdict()['num'], 1)
`
endsnippet
###########################################################################
# More Specialized Stuff. #
###########################################################################
snippet cb "Code Block" b
.. code-block:: ${1:lua}
.. code-block:: ${1:`!p snip.rv = get_popular_code_type()`}
${2:code}
$0
endsnippet
# match snippets :
# img, inc, fig
snippet id "Includable Directives" b
`!p
real_name=real_filename(ospath.basename(t[2]))
di=t[1][:2]
link=""
content=""
if di == 'im':
link = "|{0}|".format(real_name)
if di == 'fi':
content="""
:alt: {0}
{0}""".format(real_name)
`
..`!p snip.rv = " %s" % link if link else ""` $1`!p snip.rv=complete(t[1], INCLUDABLE_DIRECTIVES)`:: ${2:file}`!p if content:
snip.rv +=" "+content`
`!p
# Tip of whether file is exist in comment type
if not check_file_exist(path, t[2]):
snip.rv='.. FILE {0} does not exist'.format(t[2])
else:
snip.rv=""
`$0
endsnippet
snippet di "Directives" b
.. $1`!p snip.rv=complete(t[1], DIRECTIVES)`:: $2
${3:Content}
$0
endsnippet
snippet nd "None Content Directives" b
.. $1`!p snip.rv=complete(t[1], NONE_CONTENT_DIRECTIVES)`:: $2
$0
endsnippet
snippet sa "Specific Admonitions" b
.. $1`!p snip.rv =complete(t[1], SPECIFIC_ADMONITIONS)`::
${2:Content}
$0
endsnippet
#it will be trigger at start of line or after a word
snippet ro "Text Roles" w
\ :$1`!p snip.rv=complete(t[1],
TEXT_ROLES+look_up_directives(TEXT_ROLES_REGEX,
path))`:\`$2\`\
endsnippet
############
# Sphinx #
############
snippet sid "SideBar" b
.. sidebar:: ${1:SideBar Title}
${2:SideBar Content}
endsnippet
# vim:ft=snippets:

View File

@ -25,7 +25,7 @@ endsnippet
snippet if "if <condition> ... end"
if ${1:condition}
${2:# TODO}
${2}
end
endsnippet
@ -33,9 +33,9 @@ endsnippet
snippet ife "if <condition> ... else ... end"
if ${1:condition}
${2:# TODO}
${2}
else
${3:# TODO}
${3}
end
endsnippet
@ -43,11 +43,11 @@ endsnippet
snippet ifee "if <condition> ... elseif <condition> ... 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 <condition> ... end"
unless ${1:condition}
${0:# TODO}
${0}
end
endsnippet
@ -63,9 +63,9 @@ endsnippet
snippet unlesse "unless <condition> ... else ... end"
unless ${1:condition}
${2:# TODO}
${2}
else
${0:# TODO}
${0}
end
endsnippet
@ -73,11 +73,11 @@ endsnippet
snippet unlesee "unless <condition> ... elseif <condition> ... 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 <name>..." 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 <name> ... rescue ..."
def ${1:function_name}${2: ${3:*args}}
${4:# TODO}
${4}
rescue
${0:# TODO}
${0}
end
endsnippet
snippet For "(<from>..<to>).each { |<i>| <block> }"
(${1:from}..${2:to}).each { |${3:i}| ${4:# TODO} }
(${1:from}..${2:to}).each { |${3:i}| ${4} }
endsnippet
snippet for "(<from>..<to>).each do |<i>| <block> 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 { |<key>,<value>| <block> }" 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 |<key>,<value>| <block> 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 { |<key>,<value>| <block> }" 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 <key>,<value>| <block> end" r
`!p snip.rv=match.group(1)`.keep_if do |${1:key},${2:value}|
${0:# TODO}
${0}
end
endsnippet
snippet "(\S+)\.Reject" ".reject { |<key>,<value>| <block> }" 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 <key>,<value>| <block> 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 { |<a>,<b>| <block> }" 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 |<a>,<b>| <block> 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 { |<key>| <block> }" 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| <block> 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 { |<value>| <block> }" 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 |<value>| <block> end" r
`!p snip.rv=match.group(1)`.each_value do |${1:value}|
${0:# TODO}
${0}
end
endsnippet
snippet Each "<elements>.each { |<element>| <block> }"
${1:elements}.each { |${2:${1/s$//}}| ${3:# TODO} }
${1:elements}.each { |${2:${1/s$//}}| ${3} }
endsnippet
snippet each "<elements>.each do |<element>| <block> end"
${1:elements}.each do |${2:${1/s$//}}|
${0:# TODO}
${0}
end
endsnippet
@ -251,14 +251,14 @@ endsnippet
snippet each_?s(lice)? "<array>.each_slice(n) do |slice| <block> end"
each_slice(${1:2}) do |${2:slice}|
${0:# TODO}
${0}
end
endsnippet
snippet Each_?s(lice)? "<array>.each_slice(n) { |slice| <block> }"
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 { |<key>,<value>| <block> }" 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 |<key>,<value>| <block> 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 |<key>| ... 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 |<key>| ... end" i
do |${0:v}|
$1
end
endsnippet
snippet until "until <expression> ... end"
until ${1:expression}
${0:# TODO}
${0}
end
endsnippet
@ -451,7 +449,7 @@ endsnippet
snippet Until "begin ... end until <expression>"
begin
${0:# TODO}
${0}
end until ${1:expression}
endsnippet
@ -459,7 +457,7 @@ endsnippet
snippet while "while <expression> ... end"
while ${1:expression}
${0:# TODO}
${0}
end
endsnippet
@ -467,7 +465,7 @@ endsnippet
snippet While "begin ... end while <expression>"
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

View File

@ -16,14 +16,14 @@ foreach ${1:var} ${2:\$list} {
endsnippet
snippet if "if... (if)" b
if {${1:condition}} {
if {${1}} {
${2}
}
endsnippet
snippet proc "proc... (proc)" b
proc ${1:name} {${2:args}} \
proc ${1} {${2}} \
{
${3}
}
@ -41,7 +41,7 @@ switch ${1:-exact} -- ${2:\$var} {
endsnippet
snippet while "while... (while)" b
while {${1:condition}} {
while {${1}} {
${2}
}

View File

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