diff --git a/README.md b/README.md index 1c94978..99bd980 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. @@ -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 ------------------ diff --git a/UltiSnips/coffee.snippets b/UltiSnips/coffee.snippets index 8f347f1..bb451aa 100644 --- a/UltiSnips/coffee.snippets +++ b/UltiSnips/coffee.snippets @@ -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 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/elixir.snippets b/snippets/elixir.snippets new file mode 100644 index 0000000..9c562ad --- /dev/null +++ b/snippets/elixir.snippets @@ -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 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 %> 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} 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 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 + diff --git a/snippets/ruby.snippets b/snippets/ruby.snippets index 13522e3..027edf4 100644 --- a/snippets/ruby.snippets +++ b/snippets/ruby.snippets @@ -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