1
0
Fork 0
mirror of synced 2024-11-23 09:15:35 -05:00
ultimate-vim/sources_non_forked/vim-snippets/UltiSnips/coffee.snippets

99 lines
2.1 KiB
Text
Raw Normal View History

2012-08-16 23:41:25 -04:00
# From the TextMate bundle
2013-07-17 19:06:05 -04:00
# with some modification
2012-08-16 23:41:25 -04:00
snippet fun "Function" b
2013-07-17 19:06:05 -04:00
${1:name} = `!p snip.rv = "(" if t[2] else ""`${2:args}`!p snip.rv = ") " if t[2] else ""`->
2012-08-16 23:41:25 -04:00
${0:# body...}
endsnippet
2013-07-17 19:06:05 -04:00
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}
2012-08-16 23:41:25 -04:00
endsnippet
2013-07-17 19:06:05 -04:00
snippet if "If"
2012-08-16 23:41:25 -04:00
if ${1:condition}
${0:# body...}
endsnippet
2013-07-17 19:06:05 -04:00
snippet ife "If .. Else"
2012-08-16 23:41:25 -04:00
if ${1:condition}
${2:# body...}
else
${3:# body...}
endsnippet
2013-07-17 19:06:05 -04:00
snippet eif "Else if" b
2012-08-16 23:41:25 -04:00
else if ${1:condition}
${0:# body...}
endsnippet
2013-07-17 19:06:05 -04:00
snippet ifte "Ternary if"
2012-08-16 23:41:25 -04:00
if ${1:condition} then ${2:value} else ${3:other}
endsnippet
2013-07-17 19:06:05 -04:00
snippet unl "Unless"
2012-08-16 23:41:25 -04:00
${1:action} unless ${2:condition}
endsnippet
2013-07-17 19:06:05 -04:00
snippet fora "Array Comprehension"
2012-08-16 23:41:25 -04:00
for ${1:name} in ${2:array}
${0:# body...}
endsnippet
2013-07-17 19:06:05 -04:00
snippet foro "Object Comprehension"
2012-08-16 23:41:25 -04:00
for ${1:key}, ${2:value} of ${3:Object}
${0:# body...}
endsnippet
2013-07-17 19:06:05 -04:00
snippet forr "Range Comprehension (inclusive)"
for ${1:name} in [${2:start}..${3:finish}]`!p snip.rv = " by " if t[4] else ""`${4:step}
2012-08-16 23:41:25 -04:00
${0:# body...}
endsnippet
2013-07-17 19:06:05 -04:00
snippet forrex "Range Comprehension (exclusive)"
for ${1:name} in [${2:start}...${3:finish}]`!p snip.rv = " by " if t[4] else ""`${4:step}
2012-08-16 23:41:25 -04:00
${0:# body...}
endsnippet
2013-07-17 19:06:05 -04:00
snippet swi "Switch"
2012-08-16 23:41:25 -04:00
switch ${1:object}
when ${2:value}
2013-07-17 19:06:05 -04:00
${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}
2012-08-16 23:41:25 -04:00
endsnippet
snippet cla "Class" b
2013-07-17 19:06:05 -04:00
class ${1:ClassName}`!p snip.rv = " extends " if t[2] else ""`${2:Ancestor}
2012-08-16 23:41:25 -04:00
2013-07-17 19:06:05 -04:00
${3:constructor:`!p snip.rv = " (" if t[4] else ""`${4:args}`!p snip.rv = ")" if t[4] else ""` ->
${5:# body...}}
$0
2012-08-16 23:41:25 -04:00
endsnippet
2013-07-17 19:06:05 -04:00
snippet try "Try .. Catch"
2012-08-16 23:41:25 -04:00
try
$1
catch ${2:error}
$3
endsnippet
snippet req "Require" b
${1/^'?(\w+)'?$/\L$1\E/} = require(${1:'${2:sys}'})
endsnippet
2013-07-17 19:06:05 -04:00
snippet # "Interpolated Code" i
2012-08-16 23:41:25 -04:00
#{$1}$0
endsnippet
snippet log "Log" b
console.log ${1:"${2:msg}"}
endsnippet