Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Meng Zhuo 2013-06-18 16:26:41 +08:00
commit 7e084b9c02
9 changed files with 300 additions and 48 deletions

View File

@ -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.
@ -129,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
------------------

View File

@ -1,21 +1,21 @@
# 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
@ -27,49 +27,57 @@ 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

@ -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

118
snippets/elixir.snippets Normal file
View File

@ -0,0 +1,118 @@
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 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
${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:fields}
snippet doc
@doc """
${1}
"""
snippet fn
fn(${1:args}) -> ${2} end
snippet mdoc
@moduledoc """
${1}
"""
snippet rec
receive do
${1} ->
${2}
end
snippet req
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 try .. rescue .. end
try do
${1}
rescue
${2} -> ${3}
end

View File

@ -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 %>

View File

@ -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}

View File

@ -730,6 +730,10 @@ snippet source
<source src="${1}" type="${2}" media="${3}" />
snippet span
<span>${1}</span>
snippet span#
<span id="${1}">${2}</span>
snippet span.
<span class="${1}">${2}</span>
snippet strong
<strong>${1}</strong>
snippet style

View File

@ -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
<!doctype html>
<html>
<head>
<title>$2</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
$3
</head>
<body>
$4
</body>
</html>
# ==== 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
<label for="${2:$1}">${1}</label>
<input type="${3:text}" name="${4:$2}" id="${5:$2}" value="${6}" />${7}
# FORMS
# use idn . or n to add id
snippet input
<input type="${1:text}" value="${2}" ${3}/>${7}
snippet submit
<input type="submit" value="${2}" ${3}/>${7}
snippet textarea
<textarea $1>$2</textarea>
# if you need id or class use snippets above
snippet form
<form method="${1:post/get}" action="$2">
$3
</form>
# other tags
snippet br
<br/>
snippet a
<a href="#" $2>$3</a>
snippet img
<img src="$1" alt="$2"/>
# JS/CSS
snippet css_file
<link rel="stylesheet" href="${1:style.css}" type="text/css" media="${2:all}" />${3}
snippet css_block
<link rel="stylesheet" href="${1:style.css}" type="text/css" media="${2:all}">
</link>
snippet script_block
<script type="text/javascript" charset="utf-8">
</script>
snippet script_file
<script type="text/javascript" charset="utf-8">
</script>

View File

@ -847,26 +847,26 @@ snippet tcts
snippet tctss
t.timestamps
${1}
snippet va
snippet va validates_associated
validates_associated :${1:attribute}
snippet vao
validates_acceptance_of :${1:terms}
snippet va validates .., :acceptance => true
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