diff options
Diffstat (limited to 'vim/bundle/vim-snippets/UltiSnips')
68 files changed, 10786 insertions, 0 deletions
diff --git a/vim/bundle/vim-snippets/UltiSnips/README b/vim/bundle/vim-snippets/UltiSnips/README new file mode 100644 index 0000000..41d8592 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/README @@ -0,0 +1,17 @@ +This directory contains the snippets for UltiSnips. +https://github.com/sirver/ultisnips + +Standing On The Shoulders of Giants +=================================== + +The snippets have been collected from various other project which I want to +express my gratitude for. My main source for inspiration where the following +two projects: + + TextMate: http://svn.textmate.org/trunk/Bundles/ + SnipMate: http://code.google.com/p/snipmate/ + +UltiSnips has seen contributions by many individuals. Those contributions have +been merged into this collection seamlessly and without further comments. + +-- vim:ft=rst:nospell: diff --git a/vim/bundle/vim-snippets/UltiSnips/ada.snippets b/vim/bundle/vim-snippets/UltiSnips/ada.snippets new file mode 100644 index 0000000..cc35c2c --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/ada.snippets @@ -0,0 +1,280 @@ +priority -50 + +global !p + +def ada_case(word): + out = word[0].upper() + for i in range(1, len(word)): + if word[i - 1] == '_': + out = out + word[i].upper() + else: + out = out + word[i] + return out + +endglobal + +snippet wi "with" +with $1;$0 +endsnippet + +snippet pac "package" +package ${1:`!p snip.rv = ada_case(snip.basename)`} is + $0 +end $1; +endsnippet + +snippet pacb "package body" +package body ${1:`!p snip.rv = ada_case(snip.basename)`} is + $0 +end $1; +endsnippet + +snippet ent "entry ... when" +entry $1($2) when $3 is +begin + $0 +end $1; +endsnippet + +snippet task "task" +task $1 is + entry $0 +end $1; +endsnippet + +snippet taskb "task body" +task body $1 is + $2 +begin + $0 +end $1; +endsnippet + +snippet acc "accept" +accept $1($2) do + $0 +end $1; +endsnippet + +snippet prot "protected type" +protected type $1($2) is + $0 +end $1; +endsnippet + +snippet prob "protected body" +protected body $1 is + $2 +begin + $0 +end $1; +endsnippet + +snippet gen "generic type" +generic + type $1 is $2;$0 +endsnippet + +snippet ty "type" +type $1 is $2;$0 +endsnippet + +snippet tyd "type with default value" +type $1 is $2 + with Default_Value => $3;$0 +endsnippet + +snippet subty "subtype" +subtype $1 is $2;$0 +endsnippet + +snippet dec "declare block" +declare + $1 +begin + $0 +end; +endsnippet + +snippet decn "declare named block" +$1: +declare + $2 +begin + $0 +end $1; +endsnippet + +snippet ifex "if expression" +if $1 then $2 else $0 +endsnippet + +snippet casex "case expression" +case $1 is + when $2 => $3,$0 +endsnippet + +snippet fora "for all" +for all $1 ${2:in} $3 => $0 +endsnippet + +snippet fors "for some" +for some $1 ${2:in} $3 => $0 +endsnippet + +snippet if "if" +if $1 then + $0 +end if; +endsnippet + +snippet ife "if ... else" +if $1 then + $2 +else + $0 +end if; +endsnippet + +snippet el "else" +else + $0 +endsnippet + +snippet eif "elsif" +elsif $1 then + $0 +endsnippet + +snippet wh "while" +while $1 loop + $0 +end loop; +endsnippet + +snippet nwh "named while" +$1: +while $2 loop + $0 +end loop $1; +endsnippet + +snippet for "for" +for ${1:I} in $2 loop + $0 +end loop; +endsnippet + +snippet fore "for each" +for $1 of $2 loop + $0 +end loop; +endsnippet + +snippet nfor "named for" +$1: +for ${2:I} in $3 loop + $0 +end loop $1; +endsnippet + +snippet nfore "named for each" +$1: +for $2 of $3 loop + $0 +end loop $1; +endsnippet + +snippet proc "procedure" +procedure $1($2) is + $3 +begin + $0 +end $1; +endsnippet + +snippet procd "procedure declaration" +procedure $1;$0 +endsnippet + +snippet fun "function" +function $1($2) return $3 is + $4 +begin + $0 +end $1; +endsnippet + +snippet fune "expression function" +function $1 return $2 is + ($3);$0 +endsnippet + +snippet fund "function declaration" +function $1 return $2;$0 +endsnippet + +snippet ret "extended return" +return $1 do + $0 +end return; +endsnippet + +snippet rec "record" +record + $0 +end record; +endsnippet + +snippet case "case" +case $1 is + when $2 => $3;$0 +end case; +endsnippet + +snippet whe "when" +when $1 => $2;$0 +endsnippet + +snippet wheo "when others" +when others => $1;$0 +endsnippet + +snippet lo "loop" +loop + $0 +end loop; +endsnippet + +snippet nlo "named loop" +$1: +loop + $0 +end loop $1; +endsnippet + +snippet ex "exit when" +exit when $1;$0 +endsnippet + +snippet put "Ada.Text_IO.Put" +Ada.Text_IO.Put($1);$0 +endsnippet + +snippet putl "Ada.Text_IO.Put_Line" +Ada.Text_IO.Put_Line($1);$0 +endsnippet + +snippet get "Ada.Text_IO.Get" +Ada.Text_IO.Get($1);$0 +endsnippet + +snippet getl "Ada.Text_IO.Get_Line" +Ada.Text_IO.Get_Line($1);$0 +endsnippet + +snippet newline "Ada.Text_IO.New_Line" +Ada.Text_IO.New_Line(${1:1});$0 +endsnippet + +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/all.snippets b/vim/bundle/vim-snippets/UltiSnips/all.snippets new file mode 100644 index 0000000..0e286e5 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/all.snippets @@ -0,0 +1,76 @@ +# This file contains snippets that are always defined. I personally +# have snippets for signatures and often needed texts + +# sligthly lower priority than everything else since specialized versions +# should overwrite. The user needs to adjust her priority in her snippets to +# ~-55 so that other filetypes will still overwrite. +priority -60 + +############## +# NICE BOXES # +############## +global !p +from vimsnippets import foldmarker, make_box, get_comment_format +endglobal + +snippet box "A nice box with the current comment symbol" b +`!p +box = make_box(len(t[1])) +snip.rv = box[0] +snip += box[1] +`${1:content}`!p +box = make_box(len(t[1])) +snip.rv = box[2] +snip += box[3]` +$0 +endsnippet + +snippet bbox "A nice box over the full width" b +`!p +if not snip.c: + width = int(vim.eval("&textwidth - (virtcol('.') == 1 ? 0 : virtcol('.'))")) or 71 +box = make_box(len(t[1]), width) +snip.rv = box[0] +snip += box[1] +`${1:content}`!p +box = make_box(len(t[1]), width) +snip.rv = box[2] +snip += box[3]` +$0 +endsnippet + +snippet fold "Insert a vim fold marker" b +`!p snip.rv = get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]`${2:1} `!p snip.rv = get_comment_format()[2]` +endsnippet + +snippet foldc "Insert a vim fold close marker" b +`!p snip.rv = get_comment_format()[0]` ${2:1}`!p snip.rv = foldmarker()[1]` `!p snip.rv = get_comment_format()[2]` +endsnippet + +snippet foldp "Insert a vim fold marker pair" b +`!p snip.rv = get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]` `!p snip.rv = get_comment_format()[2]` +${2:${VISUAL:Content}} +`!p snip.rv = get_comment_format()[0]` `!p snip.rv = foldmarker()[1]` $1 `!p snip.rv = get_comment_format()[2]` +endsnippet + +########################## +# LOREM IPSUM GENERATORS # +########################## +snippet lorem "Lorem Ipsum - 50 Words" b +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod +tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At +vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, +no sea takimata sanctus est Lorem ipsum dolor sit amet. +endsnippet + +########################## +# VIM MODELINE GENERATOR # +########################## +# See advice on `:help 'tabstop'` for why these values are set. Uses second +# modeline form ('set') to work in languages with comment terminators +# (/* like C */). +snippet modeline "Vim modeline" +vim`!v ':set '. (&expandtab ? printf('et sw=%i ts=%i', &sw, &ts) : printf('noet sts=%i sw=%i ts=%i', &sts, &sw, &ts)) . (&tw ? ' tw='. &tw : '') . ':'` +endsnippet + +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/bib.snippets b/vim/bundle/vim-snippets/UltiSnips/bib.snippets new file mode 100644 index 0000000..c9b8df5 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/bib.snippets @@ -0,0 +1,52 @@ +priority -50 + +snippet online "Online resource" b +@online{${1:name}, + author={${2:author}}, + title={${3:title}}, + date={${4:date}}, + url={${5:url}} +} +$0 +endsnippet + +snippet article "Article reference" b +@article{${1:name}, + author={${2:author}}, + title={${3:title}}, + journaltitle={${4:journal}}, + volume={${5:NN}}, + number={${6:NN}}, + year={${7:YYYY}}, + pages={${8:NN}--${9:NN}} +} +$0 +endsnippet + +snippet book "Book reference" b +@book{${1:name}, + author={${2:author}}, + title={${3:title}}, + subtitle={${4:subtitle}}, + year={${5:YYYY}}, + location={${6:somewhere}}, + publisher={${7:publisher}}, + pages={${8:NN}--${9:NN}} +} +$0 +endsnippet + +snippet inb "In Book reference" b +@inbook{${1:name}, + author={${2:author}}, + title={${3:title}}, + subtitle={${4:subtitle}}, + booktitle={${5:book}}, + editor={${6:editor}}, + year={${7:YYYY}}, + location={${8:somewhere}}, + publisher={${9:publisher}}, + pages={${10:NN}--${11:NN}} +} +$0 +endsnippet diff --git a/vim/bundle/vim-snippets/UltiSnips/bindzone.snippets b/vim/bundle/vim-snippets/UltiSnips/bindzone.snippets new file mode 100644 index 0000000..b8ab0df --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/bindzone.snippets @@ -0,0 +1,29 @@ +priority -50 + +global !p +def newsoa(): + import datetime + now = datetime.datetime.now() + # return standard SOA formatted serial for today + return now.strftime("%Y%m%d00") +endglobal + +snippet zone "Bootstrap a new Bind zonefile" b +$TTL 86400 +@ IN SOA ${1:example.net}. ${2:hostmaster.$1}.( + `!p snip.rv = newsoa()`; serial + 21600; refresh every 6 hours + 3600; retry after one hour + 604800; expire after a week + 86400 ); minimum TTL of 1 day + + IN NS ns01.$1. + IN MX 10 mail.$1. + +ns01.$1 IN A +mail.$1 IN A +endsnippet + +snippet A "Insert A Record" b +${1:hostname} IN A ${2:ip} +endsnippet diff --git a/vim/bundle/vim-snippets/UltiSnips/c.snippets b/vim/bundle/vim-snippets/UltiSnips/c.snippets new file mode 100644 index 0000000..c989464 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/c.snippets @@ -0,0 +1,99 @@ +########################################################################### +# TextMate Snippets # +########################################################################### + +priority -50 + +snippet def "#define ..." +#define ${1} +endsnippet + +snippet #ifndef "#ifndef ... #define ... #endif" +#ifndef ${1/([A-Za-z0-9_]+).*/$1/} +#define ${1:SYMBOL} ${2:value} +#endif /* ifndef $1 */ +endsnippet + +snippet #if "#if #endif" b +#if ${1:0} +${VISUAL}${0} +#endif +endsnippet + +snippet mark "#pragma mark (mark)" +#if 0 +${1:#pragma mark - +}#pragma mark $2 +#endif + +$0 +endsnippet + +snippet main "main() (main)" +int main(int argc, char *argv[]) +{ + ${VISUAL}${0} + return 0; +} +endsnippet + +snippet for "for loop (for)" +for (${2:i} = 0; $2 < ${1:count}; ${3:++$2}) { + ${VISUAL}${0} +} +endsnippet + +snippet fori "for int loop (fori)" +for (${4:int} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}) { + ${VISUAL}${0} +} +endsnippet + +snippet once "Include header once only guard" +#ifndef ${1:`!p +if not snip.c: + import random, string + name = re.sub(r'[^A-Za-z0-9]+','_', snip.fn).upper() + rand = ''.join(random.sample(string.ascii_letters+string.digits, 8)) + snip.rv = ('%s_%s' % (name,rand)).upper() +else: + snip.rv = snip.c`} +#define $1 + +${VISUAL}${0} + +#endif /* end of include guard: $1 */ +endsnippet + +snippet fprintf "fprintf ..." +fprintf(${1:stderr}, "${2:%s}\n"${2/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$3${2/([^%]|%%)*(%.)?.*/(?2:\);)/} +endsnippet + +snippet eli "else if .. (eli)" +else if (${1:/* condition */}) { + ${VISUAL}${0} +} +endsnippet + +snippet printf "printf .. (printf)" +printf("${1:%s}\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\);)/} +endsnippet + +snippet st "struct" +struct ${1:`!p snip.rv = (snip.basename or "name") + "_t"`} { + ${0:/* data */} +}; +endsnippet + +snippet fun "function" b +${1:void} ${2:function_name}(${3}) +{ + ${VISUAL}${0} +} +endsnippet + +snippet fund "function declaration" b +${1:void} ${2:function_name}(${3}); +endsnippet + +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/coffee-jasmine.snippets b/vim/bundle/vim-snippets/UltiSnips/coffee-jasmine.snippets new file mode 100644 index 0000000..0dd35cd --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/coffee-jasmine.snippets @@ -0,0 +1,166 @@ +# +# CoffeeScript versions -- adapted from the JS TextMate bundle + additions +# for some jasmine-jquery matchers +# +priority -50 + +extends coffee + +priority -49 + +snippet des "Describe (coffee)" b +describe '${1:description}', -> + $0 +endsnippet + +snippet it "it (coffee)" b +it '${1:description}', -> + $0 +endsnippet + +snippet bef "before each (coffee)" b +beforeEach -> + $0 +endsnippet + +snippet aft "after each (coffee)" b +afterEach -> + $0 +endsnippet + +snippet any "any (coffee)" b +jasmine.any($1) +endsnippet + +snippet ru "runs (coffee)" b +runs -> + $0 +endsnippet + +snippet wa "waits (coffee)" b +waits($1) +endsnippet + +snippet ex "expect (coffee)" b +expect(${1:target})$0 +endsnippet + +snippet ee "expect to equal (coffee)" b +expect(${1:target}).toEqual(${2:value}) +endsnippet + +snippet em "expect to match (coffee)" b +expect(${1:target}).toMatch(${2:pattern}) +endsnippet + +snippet eha "expect to have attribute (coffee)" b +expect(${1:target}).toHaveAttr('${2:attr}'${3:, '${4:value}'}) +endsnippet + +snippet et "expect to be truthy (coffee)" b +expect(${1:target}).toBeTruthy() +endsnippet + +snippet ef "expect to be falsy (coffee)" b +expect(${1:target}).toBeFalsy() +endsnippet + +snippet ed "expect to be defined (coffee)" b +expect(${1:target}).toBeDefined() +endsnippet + +snippet en "expect to be null (coffee)" b +expect(${1:target}).toBeNull() +endsnippet + +snippet ec "expect to contain (coffee)" b +expect(${1:target}).toContain(${2:value}) +endsnippet + +snippet ev "expect to be visible (coffee)" b +expect(${1:target}).toBeVisible() +endsnippet + +snippet eh "expect to be hidden (coffee)" b +expect(${1:target}).toBeHidden() +endsnippet + +snippet notx "expect not (coffee)" b +expect(${1:target}).not$0 +endsnippet + +snippet note "expect not to equal (coffee)" b +expect(${1:target}).not.toEqual(${2:value}) +endsnippet + +snippet notm "expect not to match (coffee)" b +expect(${1:target}).not.toMatch(${2:pattern}) +endsnippet + +snippet notha "expect to not have attribute (coffee)" b +expect(${1:target}).not.toHaveAttr('${2:attr}'${3:, '${4:value}'}) +endsnippet + +snippet nott "expect not to be truthy (coffee)" b +expect(${1:target}).not.toBeTruthy() +endsnippet + +snippet notf "expect not to be falsy (coffee)" b +expect(${1:target}).not.toBeFalsy() +endsnippet + +snippet notd "expect not to be defined (coffee)" b +expect(${1:target}).not.toBeDefined() +endsnippet + +snippet notn "expect not to be null (coffee)" b +expect(${1:target}).not.toBeNull() +endsnippet + +snippet notc "expect not to contain (coffee)" b +expect(${1:target}).not.toContain(${2:value}) +endsnippet + +snippet notv "expect not to be visible (coffee)" b +expect(${1:target}).not.toBeVisible() +endsnippet + +snippet noth "expect not to be hidden (coffee)" b +expect(${1:target}).not.toBeHidden() +endsnippet + +snippet s "spy on (coffee)" b +spyOn(${1:object}, "${2:method}")$0 +endsnippet + +snippet sr "spy on and return (coffee)" b +spyOn(${1:object}, "${2:method}").andReturn(${3:arguments}) +endsnippet + +snippet st "spy on and throw (coffee)" b +spyOn(${1:object}, "${2:method}").andThrow(${3:exception}) +endsnippet + +snippet sct "spy on and call through (coffee)" b +spyOn(${1:object}, "${2:method}").andCallThrough() +endsnippet + +snippet scf "spy on and call fake (coffee)" b +spyOn(${1:object}, "${2:method}").andCallFake(${3:function}) +endsnippet + +snippet esc "expect was called (coffee)" b +expect(${1:target}).wasCalled() +endsnippet + +snippet escw "expect was called with (coffee)" b +expect(${1:target}).wasCalledWith(${2:arguments}) +endsnippet + +snippet notsc "expect was not called (coffee)" b +expect(${1:target}).wasNotCalled() +endsnippet + +snippet noscw "expect was not called with (coffee)" b +expect(${1:target}).wasNotCalledWith(${2:arguments}) +endsnippet diff --git a/vim/bundle/vim-snippets/UltiSnips/coffee-react.snippets b/vim/bundle/vim-snippets/UltiSnips/coffee-react.snippets new file mode 100644 index 0000000..4cdb40f --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/coffee-react.snippets @@ -0,0 +1,80 @@ +# +# CoffeeScript versions -- adapted from coffee-jasmine +# for some ReactJS matchers. +# +priority -50 + +extends coffee + +priority -49 + +snippet createClass "React define Class" b +${1:classname}Class = React.createClass + displayName: "$1" + render: -> + ${2} +$1 = React.createFactory($1) +endsnippet + +snippet PropTypes "React define propTypes" b +propTypes: -> + ${1:myVar}: React.PropTypes.${2:type}${3:.isRequired} +endsnippet + +snippet propType "React propType (key/value)" b +${1:myVar}: React.PropTypes.${2:type}${3:.isRequired} +${4} +endsnippet + +snippet setState "React setState" b +@setState + ${1:myvar}: ${2:myvalue} + ${3} +endsnippet + +snippet getInitialState "React define getInitialState" b +getInitialState: -> + ${1:myvar}: ${2:myvalue} + ${3} +endsnippet + +snippet getDefaultProps "React define getDefaultProps" b +getDefaultProps: -> + ${1:myvar}: ${2:myvalue} + ${3} +endsnippet + +snippet componentWillMount "React define componentWillMount" b +componentWillMount: -> + ${1} +endsnippet + +snippet componentDidMount "React define componentDidMount" b +componentDidMount: -> + ${1} +endsnippet + +snippet componentWillReceiveProps "React define componentWillReceiveProps" b +componentWillReceiveProps: (nextProps) -> + ${1} +endsnippet + +snippet shouldComponentUpdate "React define shouldComponentUpdate" b +shouldComponentUpdate: (nextProps, nextState) -> + ${1} +endsnippet + +snippet componentWillUpdate "React define componentWillUpdate" b +componentWillUpdate: (nextProps, nextState) -> + ${1} +endsnippet + +snippet componentDidUpdate "React define componentDidUpdate" b +componentDidUpdate: (prevProps, prevState) -> + ${1} +endsnippet + +snippet componentWillUnmount "React define componentWillUnmount" b +componentWillUnmount: -> + ${1} +endsnippet diff --git a/vim/bundle/vim-snippets/UltiSnips/coffee.snippets b/vim/bundle/vim-snippets/UltiSnips/coffee.snippets new file mode 100644 index 0000000..75e7d06 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/coffee.snippets @@ -0,0 +1,100 @@ +priority -50 + +snippet fun "Function" b +${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)" 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 +if ${1:condition} + ${0:# body...} +endsnippet + +snippet ife "If .. Else" b +if ${1:condition} + ${2:# body...} +else + ${3:# body...} +endsnippet + +snippet elif "Else if" b +else if ${1:condition} + ${0:# body...} +endsnippet + +snippet ifte "Ternary if" b +if ${1:condition} then ${2:value} else ${3:other} +endsnippet + +snippet unl "Unless" b +${1:action} unless ${2:condition} +endsnippet + +snippet fora "Array Comprehension" b +for ${1:name} in ${2:array} + ${0:# body...} +endsnippet + +snippet foro "Object Comprehension" b +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}]`!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}]`!p snip.rv = " by " if t[4] else ""`${4:step} + ${0:# body...} +endsnippet + +snippet swi "Switch" b +switch ${1:object} + when ${2:value} + ${3:# body...} + else + $0 +endsnippet + +snippet swit "Switch when .. then" b +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}`!p snip.rv = " extends " if t[2] else ""`${2:Ancestor} + + ${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 +try + $1 +catch ${2:error} + $3 +endsnippet + +snippet req "Require" b +${1/^'?(\w+)'?$/\L$1\E/} = require(${1:'${2:sys}'}) +endsnippet + +snippet # "Interpolated Code" i +#{$1}$0 +endsnippet + +snippet log "Log" b +console.log ${1:"${2:msg}"} +endsnippet + +snippet kv "Key:value for object" b +${1:key}:${2:value} +endsnippet diff --git a/vim/bundle/vim-snippets/UltiSnips/cpp.snippets b/vim/bundle/vim-snippets/UltiSnips/cpp.snippets new file mode 100644 index 0000000..f7c2bd8 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/cpp.snippets @@ -0,0 +1,73 @@ +priority -50 + +extends c + +# We want to overwrite everything in parent ft. +priority -49 + +########################################################################### +# TextMate Snippets # +########################################################################### +snippet beginend "$1.begin(), $1.end() (beginend)" +${1:v}${1/^.*?(-)?(>)?$/(?2::(?1:>:.))/}begin(), $1${1/^.*?(-)?(>)?$/(?2::(?1:>:.))/}end() +endsnippet + +snippet cl "class .. (class)" +class ${1:`!p snip.rv = snip.basename or "name"`} +{ +public: + ${1/(\w+).*/$1/} (${2:arguments}); + virtual ~${1/(\w+).*/$1/} (); + +private: + ${0:/* data */} +}; +endsnippet + +snippet ns "namespace .. (namespace)" +namespace${1/.+/ /m}${1:`!p snip.rv = snip.basename or "name"`} +{ + ${VISUAL}${0} +}${1/.+/ \/* /m}$1${1/.+/ *\/ /m} +endsnippet + +snippet readfile "read file (readF)" +std::vector<char> v; +if (FILE *fp = fopen(${1:"filename"}, "r")) +{ + char buf[1024]; + while(size_t len = fread(buf, 1, sizeof(buf), fp)) + v.insert(v.end(), buf, buf + len); + fclose(fp); +} +endsnippet + +snippet map "std::map (map)" +std::map<${1:key}, ${2:value}> map$0; +endsnippet + +snippet vector "std::vector (v)" +std::vector<${1:char}> v$0; +endsnippet + +snippet tp "template <typename ..> (template)" +template <typename ${1:_InputIter}> +endsnippet + +snippet cla "An entire .h generator" b +#ifndef ${2:`!v substitute(vim_snippets#Filename('$1_H','ClassName'),'.*','\U&\E','')`} +#define $2 + +class ${1:`!v substitute(substitute(vim_snippets#Filename('$1','ClassName'),'^.','\u&',''), '_\(\w\)', '\u\1', 'g')`} +{ +private: + ${3} + +public: + $1(); + virtual ~$1(); +}; + +#endif /* $2 */ +endsnippet +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/cs.snippets b/vim/bundle/vim-snippets/UltiSnips/cs.snippets new file mode 100644 index 0000000..aca245e --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/cs.snippets @@ -0,0 +1,328 @@ +#######################################################################
+# C# Snippets for UltiSnips #
+#######################################################################
+
+priority -50
+
+#########################
+# classes and structs #
+#########################
+
+snippet namespace "namespace" b
+namespace ${1:MyNamespace}
+{
+ ${VISUAL}$0
+}
+endsnippet
+
+snippet class "class" w
+class ${1:MyClass}
+{
+ $0
+}
+endsnippet
+
+snippet struct "struct" w
+struct ${1:MyStruct}
+{
+ $0
+}
+endsnippet
+
+snippet interface "interface" w
+interface I${1:Interface}
+{
+ $0
+}
+endsnippet
+
+snippet enum "enumeration" b
+enum ${1:MyEnum} { ${2:Item} };
+endsnippet
+
+
+############
+# Main() #
+############
+
+snippet sim "static int main" b
+static int Main(string[] args)
+{
+ $0
+}
+endsnippet
+
+snippet svm "static void main" b
+static void Main(string[] args)
+{
+ $0
+}
+endsnippet
+
+
+################
+# properties #
+################
+
+snippet prop "Simple property declaration" b
+public ${1:int} ${2:MyProperty} { get; set; }
+endsnippet
+
+snippet propfull "Full property declaration" b
+private ${1:int} ${2:_myProperty};
+
+public $1 ${3:MyProperty}
+{
+ get { return $2; }
+ set { $2 = value; }
+}
+endsnippet
+
+snippet propg "Property with a private setter" b
+public ${1:int} ${2:MyProperty} { get; private set; }
+endsnippet
+
+
+############
+# blocks #
+############
+
+snippet #if "#if #endif" b
+#if ${1:DEBUG}
+${VISUAL}$0
+#endif
+endsnippet
+
+snippet #region "#region #endregion" b
+#region ${1:Region}
+${VISUAL}$0
+#endregion
+endsnippet
+
+
+###########
+# loops #
+###########
+
+snippet for "for loop" b
+for (int ${1:i} = 0; $1 < ${2:10}; $1++)
+{
+ ${VISUAL}$0
+}
+endsnippet
+
+snippet forr "for loop (reverse)" b
+for (int ${1:i} = ${2:10}; $1 >= 0; $1--)
+{
+ ${VISUAL}$0
+}
+endsnippet
+
+snippet foreach "foreach loop" b
+foreach (${3:var} ${2:item} in ${1:items})
+{
+ ${VISUAL}$0
+}
+endsnippet
+
+snippet while "while loop" b
+while (${1:true})
+{
+ ${VISUAL}$0
+}
+endsnippet
+
+snippet do "do loop" b
+do
+{
+ ${VISUAL}$0
+} while (${1:true});
+endsnippet
+
+
+###############
+# branching #
+###############
+
+snippet if "if statement" b
+if ($1)
+{
+ ${VISUAL}$0
+}
+endsnippet
+
+snippet ife "if else statement" b
+if ($1)
+{
+ ${VISUAL}$0
+}
+else
+{
+}
+endsnippet
+
+snippet elif "else if" b
+else if ($1)
+{
+ $0
+}
+endsnippet
+
+snippet elseif "else if" b
+else if ($1)
+{
+ $0
+}
+endsnippet
+
+snippet ifnn "if not null" b
+if ($1 != null)
+{
+ ${VISUAL}$0
+}
+endsnippet
+
+snippet switch "switch statement" b
+switch (${1:statement})
+{
+ case ${2:value}:
+ break;
+
+ default:
+ $0break;
+}
+endsnippet
+
+snippet case "case" b
+case ${1:value}:
+ $2
+ break;
+endsnippet
+
+
+##############
+# wrappers #
+##############
+
+snippet using "using statement" b
+using (${1:resource})
+{
+ ${VISUAL}$0
+}
+endsnippet
+
+snippet unchecked "unchecked block" b
+unchecked
+{
+ ${VISUAL}$0
+}
+endsnippet
+
+snippet checked "checked block" b
+checked
+{
+ ${VISUAL}$0
+}
+endsnippet
+
+snippet unsafe "unsafe" b
+unsafe
+{
+ ${VISUAL}$0
+}
+endsnippet
+
+
+########################
+# exception handling #
+########################
+
+snippet try "try catch block" b
+try
+{
+ ${VISUAL}$0
+}
+catch (${1:Exception} ${2:e})
+{
+ throw;
+}
+endsnippet
+
+snippet tryf "try finally block" b
+try
+{
+ ${VISUAL}$0
+}
+finally
+{
+}
+endsnippet
+
+snippet throw "throw"
+throw new ${1}Exception("${2}");
+endsnippet
+
+
+##########
+# LINQ #
+##########
+
+snippet from "LINQ syntax" b
+var ${1:seq} =
+ from ${2:item1} in ${3:items1}
+ join ${4:item2} in ${5:items2} on $2.${6:prop1} equals $4.${7:prop2}
+ select ${8:$2.prop3}
+ where ${9:clause}
+endsnippet
+
+
+############################
+# feedback and debugging #
+############################
+
+snippet da "Debug.Assert" b
+Debug.Assert(${1:true});
+endsnippet
+
+snippet cw "Console.WriteLine" b
+Console.WriteLine("$1");
+endsnippet
+
+# as you first type comma-separated parameters on the right, {n} values appear in the format string
+snippet cwp "Console.WriteLine with parameters" b
+Console.WriteLine("${2:`!p
+snip.rv = ' '.join(['{' + str(i) + '}' for i in range(t[1].count(','))])
+`}"${1:, something});
+endsnippet
+
+snippet mbox "Message box" b
+MessageBox.Show("${1:message}");
+endsnippet
+
+
+##################
+# full methods #
+##################
+
+snippet equals "Equals method" b
+public override bool Equals(object obj)
+{
+ if (obj == null || GetType() != obj.GetType())
+ {
+ return false;
+ }
+ $0
+ return base.Equals(obj);
+}
+endsnippet
+
+
+##############
+# comments #
+##############
+
+snippet /// "XML comment" b
+/// <summary>
+/// $1
+/// </summary>
+endsnippet
diff --git a/vim/bundle/vim-snippets/UltiSnips/css.snippets b/vim/bundle/vim-snippets/UltiSnips/css.snippets new file mode 100644 index 0000000..ff26509 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/css.snippets @@ -0,0 +1,499 @@ +priority -50 + +snippet . "selector { }" +$1 { + $0 +} +endsnippet + +snippet p "padding" +padding: ${1:0};$0 +endsnippet + +snippet m "margin" +margin: ${1:0};$0 +endsnippet + +snippet bd "border" +border: ${1:0};$0 +endsnippet + +snippet d "display" +display: ${1:none};$0 +endsnippet + +snippet bg "background" +background: ${1:none};$0 +endsnippet + +snippet ff "font-family" +font-family: ${1:"Helvetica Neue", Helvetica, Arial, sans-serif};$0 +endsnippet + +snippet h "height" +height: ${1:auto};$0 +endsnippet + +snippet w "width" +width: ${1:auto};$0 +endsnippet + +snippet pos "position" +position: ${1:relative};$0 +endsnippet + +snippet tt "text-transform" +text-transform: ${1:none};$0 +endsnippet + +snippet ! "!important CSS (!)" +!important +endsnippet + +snippet tsh "text-shadow: color-hex x y blur (text)" +text-shadow: ${1:${2:color} ${3:offset-x} ${4:offset-y} ${5:blur}};$0 +endsnippet + +snippet bxsh "box-shadow: color-hex x y blur (text)" +box-shadow: ${1:${2:offset-x} ${3:offset-y} ${4:blur} ${5:spread} ${6:color}};$0 +endsnippet + +# +# Colors +# + +snippet rgb "color rgb" +rgb(${1:255}, ${2:255}, ${3:255})$0 +endsnippet + +snippet rgba "color rgba" +rgba(${1:255}, ${2:255}, ${3:255}, ${4:0.5})$0 +endsnippet + +snippet hsl "color hsl" +hsl(${1:360}, ${2:100}%, ${3:100}%)$0 +endsnippet + +snippet hsla "color hsla" +hsla(${1:360}, ${2:100}%, ${3:100}%, ${4:0.5})$0 +endsnippet + +# +# Selectors +# + +snippet :fc +:first-child +endsnippet + +snippet :lc +:last-child +endsnippet + +snippet :nc +:nth-child($0) +endsnippet + +snippet :nlc +:nth-last-child($0) +endsnippet + +snippet :oc +:only-child +endsnippet + +# +# Pseudo-elements +# + +snippet :a +:after +endsnippet + +snippet :b +:before +endsnippet + +snippet ::a +::after +endsnippet + +snippet ::b +::before +endsnippet + +########################################################################### +# Most of these came from TextMate # +########################################################################### + +snippet background "background-attachment: scroll:fixed (background)" +background-attachment: ${1:scroll/fixed};$0 +endsnippet + +snippet background "background-color: color-hex (background)" +background-color: #${1:DDD};$0 +endsnippet + +snippet background "background-color: color-name (background)" +background-color: ${1:red};$0 +endsnippet + +snippet background "background-color: color-rgb (background)" +background-color: rgb(${1:255},${2:255},${3:255});$0 +endsnippet + +snippet background "background-color: transparent (background)" +background-color: transparent;$0 +endsnippet + +snippet background "background-image: none (background)" +background-image: none;$0 +endsnippet + +snippet background "background-image: url (background)" +background-image: url($1);$0 +endsnippet + +snippet background "background-position: position (background)" +background-position: ${1:top left/top center/top right/center left/center center/center right/bottom left/bottom center/bottom right/x-% y-%/x-pos y-pos};$0 +endsnippet + +snippet background "background-repeat: r:r-x:r-y:n-r (background)" +background-repeat: ${1:repeat/repeat-x/repeat-y/no-repeat};$0 +endsnippet + +snippet background "background: color image repeat attachment position (background)" +background:${6: #${1:DDD}} url($2) ${3:repeat/repeat-x/repeat-y/no-repeat} ${4:scroll/fixed} ${5:top left/top center/top right/center left/center center/center right/bottom left/bottom center/bottom right/x-% y-%/x-pos y-pos};$0 +endsnippet + +snippet border "border-bottom-color: size style color (border)" +border-bottom-color: #${1:999};$0 +endsnippet + +snippet border "border-bottom-style: size style color (border)" +border-bottom-style: ${1:none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset};$0 +endsnippet + +snippet border "border-bottom-width: size style color (border)" +border-bottom-width: ${1:1}px ${2:solid} #${3:999};$0 +endsnippet + +snippet border "border-bottom: size style color (border)" +border-bottom: ${1:1}px ${2:solid} #${3:999};$0 +endsnippet + +snippet border "border-color: color (border)" +border-color: ${1:999};$0 +endsnippet + +snippet border "border-left-color: color (border)" +border-right-color: #${1:999};$0 +endsnippet + +snippet border "border-left-style: style (border)" +border-left-style: ${1:none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset};$0 +endsnippet + +snippet border "border-left-width: size (border)" +border-left-width: ${1:1}px +endsnippet + +snippet border "border-left: size style color (border)" +border-left: ${1:1}px ${2:solid} #${3:999};$0 +endsnippet + +snippet border "border-right-color: color (border)" +border-right-color: #${1:999};$0 +endsnippet + +snippet border "border-right-style: style (border)" +border-right-style: ${1:none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset};$0 +endsnippet + +snippet border "border-right-width: size (border)" +border-right-width: ${1:1}px +endsnippet + +snippet border "border-right: size style color (border)" +border-right: ${1:1}px ${2:solid} #${3:999};$0 +endsnippet + +snippet border "border-style: style (border)" +border-style: ${1:none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset};$0 +endsnippet + +snippet border "border-top-color: color (border)" +border-top-color: #${1:999};$0 +endsnippet + +snippet border "border-top-style: style (border)" +border-top-style: ${1:none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset};$0 +endsnippet + +snippet border "border-top-width: size (border)" +border-top-width: ${1:1}px +endsnippet + +snippet border "border-top: size style color (border)" +border-top: ${1:1}px ${2:solid} #${3:999};$0 +endsnippet + +snippet border "border-width: width (border)" +border-width: ${1:1px};$0 +endsnippet + +snippet border "border: size style color (border)" +border: ${1:1px} ${2:solid} #${3:999};$0 +endsnippet + +snippet clear "clear: value (clear)" +clear: ${1:left/right/both/none};$0 +endsnippet + +snippet color "color: color-hex (color)" +color: #${1:DDD};$0 +endsnippet + +snippet color "color: color-name (color)" +color: ${1:red};$0 +endsnippet + +snippet color "color: color-rgb (color)" +color: rgb(${1:255},${2:255},${3:255});$0 +endsnippet + +snippet cursor "cursor: type (cursor)" +cursor: ${1:default/auto/crosshair/pointer/move/*-resize/text/wait/help};$0 +endsnippet + +snippet cursor "cursor: url (cursor)" +cursor: url($1);$0 +endsnippet + +snippet direction "direction: ltr|rtl (direction)" +direction: ${1:ltr|rtl};$0 +endsnippet + +snippet display "display: block (display)" +display: block;$0 +endsnippet + +snippet display "display: common-types (display)" +display: ${1:none/inline/block/list-item/run-in/compact/marker};$0 +endsnippet + +snippet display "display: inline (display)" +display: inline;$0 +endsnippet + +snippet display "display: table-types (display)" +display: ${1:table/inline-table/table-row-group/table-header-group/table-footer-group/table-row/table-column-group/table-column/table-cell/table-caption};$0 +endsnippet + +snippet float "float: left:right:none (float)" +float: ${1:left/right/none};$0 +endsnippet + +snippet font "font-family: family (font)" +font-family: ${1:Arial, "MS Trebuchet"}, ${2:sans-}serif;$0 +endsnippet + +snippet font "font-size: size (font)" +font-size: ${1:100%};$0 +endsnippet + +snippet font "font-style: normal:italic:oblique (font)" +font-style: ${1:normal/italic/oblique};$0 +endsnippet + +snippet font "font-variant: normal:small-caps (font)" +font-variant: ${1:normal/small-caps};$0 +endsnippet + +snippet font "font-weight: weight (font)" +font-weight: ${1:normal/bold};$0 +endsnippet + +snippet font "font: style variant weight size:line-height font -family (font)" +font: ${1:normal/italic/oblique} ${2:normal/small-caps} ${3:normal/bold} ${4:1em/1.5em} ${5:Arial}, ${6:sans-}serif;$0 +endsnippet + +snippet font "font: size font (font)" +font: ${1:75%} ${2:"Lucida Grande", "Trebuchet MS", Verdana,} ${3:sans-}serif;$0 +endsnippet + +snippet letter "letter-spacing: length-em (letter)" +letter-spacing: $1em;$0 +endsnippet + +snippet letter "letter-spacing: length-px (letter)" +letter-spacing: $1px;$0 +endsnippet + +snippet list "list-style-image: url (list)" +list-style-image: url($1);$0 +endsnippet + +snippet list "list-style-position: pos (list)" +list-style-position: ${1:inside/outside};$0 +endsnippet + +snippet list "list-style-type: asian (list)" +list-style-type: ${1:cjk-ideographic/hiragana/katakana/hiragana-iroha/katakana-iroha};$0 +endsnippet + +snippet list "list-style-type: marker(list)" +list-style-type: ${1:none/disc/circle/square};$0 +endsnippet + +snippet list "list-style-type: numeric (list)" +list-style-type: ${1:decimal/decimal-leading-zero/zero};$0 +endsnippet + +snippet list "list-style-type: other (list)" +list-style-type: ${1:hebrew/armenian/georgian};$0 +endsnippet + +snippet list "list-style-type: roman-alpha-greek (list)" +list-style-type: ${1:lower-roman/upper-roman/lower-alpha/upper-alpha/lower-greek/lower-latin/upper-latin};$0 +endsnippet + +snippet list "list-style: type position image (list)" +list-style: ${1:none/disc/circle/square/decimal/zero} ${2:inside/outside} url($3);$0 +endsnippet + +snippet margin "margin-bottom: length (margin)" +margin-bottom: ${1:20px};$0 +endsnippet + +snippet margin "margin-left: length (margin)" +margin-left: ${1:20px};$0 +endsnippet + +snippet margin "margin-right: length (margin)" +margin-right: ${1:20px};$0 +endsnippet + +snippet margin "margin-top: length (margin)" +margin-top: ${1:20px};$0 +endsnippet + +snippet margin "margin: all (margin)" +margin: ${1:20px};$0 +endsnippet + +snippet margin "margin: T R B L (margin)" +margin: ${1:20px} ${2:0px} ${3:40px} ${4:0px};$0 +endsnippet + +snippet margin "margin: V H (margin)" +margin: ${1:20px} ${2:0px};$0 +endsnippet + +snippet marker "marker-offset: auto (marker)" +marker-offset: auto;$0 +endsnippet + +snippet marker "marker-offset: length (marker)" +marker-offset: ${1:10px};$0 +endsnippet + +snippet overflow "overflow: type (overflow)" +overflow: ${1:visible/hidden/scroll/auto};$0 +endsnippet + +snippet padding "padding-bottom: length (margin)" +padding-bottom: ${1:20px};$0 +endsnippet + +snippet padding "padding-left: length (margin)" +padding-left: ${1:20px};$0 +endsnippet + +snippet padding "padding-right: length (margin)" +padding-right: ${1:20px};$0 +endsnippet + +snippet padding "padding-top: length (margin)" +padding-top: ${1:20px};$0 +endsnippet + +snippet padding "padding: T R B L (padding)" +padding: ${1:20px} ${2:0px} ${3:40px} ${4:0px};$0 +endsnippet + +snippet padding "padding: V H (padding)" +padding: ${1:20px} ${2:0px};$0 +endsnippet + +snippet padding "padding: all (padding)" +padding: ${1:20px};$0 +endsnippet + +snippet position "position: type (position)" +position: ${1:static/relative/absolute/fixed};$0 +endsnippet + +snippet { "properties { } ( } )" +{ + /* $1 */ + $0 + +endsnippet + +snippet scrollbar "scrollbar" +scrollbar-base-color: ${1:#CCCCCC};${2: +scrollbar-arrow-color: ${3:#000000}; +scrollbar-track-color: ${4:#999999}; +scrollbar-3dlight-color: ${5:#EEEEEE}; +scrollbar-highlight-color: ${6:#FFFFFF}; +scrollbar-face-color: ${7:#CCCCCC}; +scrollbar-shadow-color: ${9:#999999}; +scrollbar-darkshadow-color: ${8:#666666};} +endsnippet + +snippet selection "selection" +$1::-moz-selection, +$1::selection { + color: ${2:inherit}; + background: ${3:inherit}; +} +endsnippet + +snippet text "text-align: left:center:right (txt)" +text-align: ${1:left/right/center/justify};$0 +endsnippet + +snippet text "text-decoration: none:underline:overline:line-through:blink (text)" +text-decoration: ${1:none/underline/overline/line-through/blink};$0 +endsnippet + +snippet text "text-indent: length (text)" +text-indent: ${1:10}px;$0 +endsnippet + +snippet text "text-transform: capitalize:upper:lower (text)" +text-transform: ${1:capitalize/uppercase/lowercase};$0 +endsnippet + +snippet vertical "vertical-align: type (vertical)" +vertical-align: ${1:baseline/sub/super/top/text-top/middle/bottom/text-bottom/length/%};$0 +endsnippet + +snippet visibility "visibility: type (visibility)" +visibility: ${1:visible/hidden/collapse};$0 +endsnippet + +snippet white "white-space: normal:pre:nowrap (white)" +white-space: ${1:normal/pre/nowrap};$0 +endsnippet + +snippet word "word-spacing: length (word)" +word-spacing: ${1:10px};$0 +endsnippet + +snippet z "z-index: index (z)" +z-index: $1;$0 +endsnippet + +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/d.snippets b/vim/bundle/vim-snippets/UltiSnips/d.snippets new file mode 100644 index 0000000..9ce2751 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/d.snippets @@ -0,0 +1,584 @@ +# Simple shortcuts + +priority -50 + +snippet imp "import (imp)" b +import ${1:std.stdio}; +endsnippet + +snippet pimp "public import (pimp)" b +public import ${1:/*module*/}; +endsnippet + +snippet over "override (over)" b +override ${1:/*function*/} +endsnippet + +snippet al "alias (al)" +alias ${1:/*orig*/} ${2:/*alias*/}; +endsnippet + +snippet mixin "mixin (mixin)" b +mixin ${1:/*mixed_in*/} ${2:/*name*/}; +endsnippet + +snippet new "new (new)" +new ${1}(${2}); +endsnippet + +snippet scpn "@safe const pure nothrow (scpn)" +@safe const pure nothrow +endsnippet + +snippet spn "@safe pure nothrow (spn)" +@safe pure nothrow +endsnippet + +snippet cont "continue (cont)" +continue; +endsnippet + +snippet dis "@disable (dis)" b +@disable ${1:/*method*/}; +endsnippet + +snippet pub "public (pub)" b +public: + ${1:/*members*/} +endsnippet + +snippet priv "private (priv)" b +private: + ${1:/*members*/} +endsnippet + +snippet prot "protected (prot)" b +protected: + ${1:/*members*/} +endsnippet + +snippet pack "package (pack)" b +package: + ${1:/*members*/} +endsnippet + +snippet ret "return (ret)" +return ${1:/*value to return*/}; +endsnippet + +snippet auto "auto (auto)" b +auto ${1:/*variable*/} = ${2:/*value*/}; +endsnippet + +snippet con "const (con)" b +const ${1:/*variable*/} = ${2:/*value*/}; +endsnippet + +snippet siz "size_t (siz)" b +size_t ${1:/*variable*/} = ${2:/*value*/}; +endsnippet + +snippet sup "super (sup)" b +super(${1:/*args*/}); +endsnippet + +# Phobos + +snippet tup "tuple (tup)" +tuple(${1:/*args*/}) +endsnippet + +snippet wr "writeln (wr)" +writeln(${1:/*args*/}); +endsnippet + +snippet to "to (to)" +to!(${1:/*type*/})(${2:/*arg*/}) +endsnippet + +snippet enf "enforce (enf)" b +enforce(${1:/*condition*/}, + new ${2}Exception(${3:/*args*/})); +endsnippet + +# Branches + +snippet if "if .. (if)" +if(${1:/*condition*/}) +{ + ${VISUAL}${0} +} +endsnippet + +snippet ife "if .. else (ife)" b +if(${1:/*condition*/}) +{ + ${2} +} +else +{ + ${3:/*else*/} +} +endsnippet + +snippet el "else (el)" b +else +{ + ${VISUAL}${1} +} +endsnippet + +snippet elif "else if (elif)" b +else if(${1:/*condition*/}) +{ + ${VISUAL}${0} +} +endsnippet + +snippet sw "switch (sw)" +switch(${1:/*var*/}) +{ + case ${2:/*value*/}: + ${3} + break; + case ${4:/*value*/}: + ${5} + break; + ${7:/*more cases*/} + default: + ${6:assert(false);} +} +endsnippet + +snippet fsw "final switch (fsw)" +final switch(${1:/*var*/}) +{ + case ${2:/*value*/}: + ${3} + break; + case ${4:/*value*/}: + ${5} + break; + ${7:/*more cases*/} +} +endsnippet + +snippet case "case (case)" b +case ${1:/*value*/}: + ${2} + break; +endsnippet + +snippet ?: "ternary operator (?:)" +${1:/*condition*/} ? ${2:/*then*/} : ${3:/*else*/}$4 +endsnippet + +# Loops + +snippet do "do while (do)" b +do +{ + ${VISUAL}${2} +} while(${1:/*condition*/}); +endsnippet + +snippet wh "while (wh)" b +while(${1:/*condition*/}) +{ + ${VISUAL}${2} +} +endsnippet + +snippet for "for (for)" b +for (${4:size_t} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}) +{ + ${VISUAL}${0} +} +endsnippet + +snippet forever "forever (forever)" b +for(;;) +{ + ${VISUAL}${0} +} +endsnippet + +snippet fore "foreach (fore)" +foreach(${1:/*elem*/}; ${2:/*range*/}) +{ + ${VISUAL}${3} +} +endsnippet + +snippet forif "foreach if (forif)" b +foreach(${1:/*elem*/}; ${2:/*range*/}) if(${3:/*condition*/}) +{ + ${VISUAL}${4} +} +endsnippet + +# Contracts +snippet in "in contract (in)" b +in +{ + assert(${1:/*condition*/}, "${2:error message}"); + ${3} +} +body +endsnippet + +snippet out "out contract (out)" b +out${1:(result)} +{ + assert(${2:/*condition*/}, "${3:error message}"); + ${4} +} +body +endsnippet + +snippet inv "invariant (inv)" b +invariant() +{ + assert(${1:/*condition*/}, "${2:error message}"); + ${3} +} +endsnippet + +# Functions (generic) + +snippet fun "function definition (fun)" +${1:void} ${2:/*function name*/}(${3:/*args*/}) ${4:@safe pure nothrow} +{ + ${VISUAL}${5} +} +endsnippet + +snippet void "void function definition (void)" +void ${1:/*function name*/}(${2:/*args*/}) ${3:@safe pure nothrow} +{ + ${VISUAL}${4} +} +endsnippet + +snippet this "ctor (this)" w +this(${1:/*args*/}) +{ + ${VISUAL}${2} +} +endsnippet + +snippet get "getter property (get)" +@property ${1:/*type*/} ${2:/*member_name*/}() const pure nothrow {return ${3:$2_};} +endsnippet + +snippet set "setter property (set)" +@property void ${1:/*member_name*/}(${2:/*type*/} rhs) pure nothrow {${3:$1_} = rhs;} +endsnippet + +# Functions (concrete) + +snippet main "Main" b +void main(string[] args) +{ + ${VISUAL}${0: /*code*/} +} +endsnippet + +# Mixins + +snippet signal "signal (signal)" b +mixin Signal!(${1:/*args*/}) ${2:/*name*/}; +endsnippet + +# Scope + +snippet scope "scope (scope)" b +scope(${1:exit}) +{ + ${VISUAL}${2} +} +endsnippet + +# With + +snippet with "with (with)" +with(${1}) +{ + ${VISUAL}${2} +} +endsnippet + +# Exception handling + +snippet try "try/catch (try)" b +try +{ + ${VISUAL}${1:/*code to try*/} +} +catch(${2}Exception e) +{ + ${3:/*handle exception*/} +} +endsnippet + +snippet tryf "try/catch/finally (tryf)" b +try +{ + ${VISUAL}${1:/*code to try*/} +} +catch(${2}Exception e) +{ + ${3:/*handle exception*/} +} +finally +{ + ${4:/*cleanup*/} +} +endsnippet + +snippet catch "catch (catch)" b +catch(${1}Exception e) +{ + ${2:/*handle exception*/} +} +endsnippet + +snippet thr "throw (thr)" +throw new ${1}Exception("${2}"); +endsnippet + + +# Type declarations + +snippet struct "struct (struct)" +struct ${1:`!p snip.rv = (snip.basename or "name")`} +{ + ${2} +} +endsnippet + +snippet union "union (union)" +union ${1:`!p snip.rv = (snip.basename or "name")`} +{ + ${2} +} +endsnippet + +snippet class "class (class)" +class ${1:`!p snip.rv = (snip.basename or "name")`} +{ + ${2} +} +endsnippet + +snippet inter "interface (inter)" +interface ${1:`!p snip.rv = (snip.basename or "name")`} +{ + ${2} +} +endsnippet + +snippet enum "enum (enum)" +enum ${1:`!p snip.rv = (snip.basename or "name")`} +{ + ${2} +} +endsnippet + + +# Exception declarations + +snippet exc "exception declaration (exc)" b +/// ${3:/*documentation*/} +class ${1}Exception : ${2}Exception +{ + public this(string msg, string file = __FILE__, int line = __LINE__) + { + super(msg, file, line); + } +} +endsnippet + + +# Conditional compilation + +snippet version "version (version)" b +version(${1:/*version name*/}) +{ + ${VISUAL}${2} +} +endsnippet + +snippet debug "debug" b +debug +{ + ${VISUAL}${1} +} +endsnippet + + +# Templates + +snippet temp "template (temp)" b +template ${2:/*name*/}(${1:/*args*/}) +{ + ${3} +} +endsnippet + + +# Asserts + +snippet ass "assert (ass)" b +assert(${1:false}, "${2:TODO}"); + +endsnippet + + +# Unittests + +snippet unittest "unittest (unittest)" b +unittest +{ + ${1} +} +endsnippet + + +# Common member functions + +snippet opDis "opDispatch (opDis)" b +${1:/*return type*/} opDispatch(string s)() +{ + ${2}; +} +endsnippet + +snippet op= "opAssign (op=)" b +void opAssign(${1} rhs) ${2:@safe pure nothrow} +{ + ${2} +} +endsnippet + +snippet opCmp "opCmp (opCmp)" b +int opCmp(${1} rhs) @safe const pure nothrow +{ + ${2} +} +endsnippet + +snippet opApply "opApply (opApply)" b +int opApply(int delegate(ref ${1:/*iterated type/s*/}) dg) +{ + int result = 0; + ${2:/*loop*/} + { + result = dg(${3:/*arg/s*/}); + if(result){break;} + } + return result; +} +endsnippet + +snippet toString "toString (toString)" b +string toString() @safe const pure nothrow +{ + ${1} +} +endsnippet + + +# Comments + + +snippet todo "TODO (todo)" +// TODO: ${1} +endsnippet + + +# DDoc + +snippet doc "generic ddoc block (doc)" b +/// ${1:description} +/// +/// ${2:details} +endsnippet + +snippet fdoc "function ddoc block (fdoc)" b +/// ${1:description} +/// +/// ${2:Params: ${3:param} = ${4:param description} +/// ${5}} +/// +/// ${6:Returns: ${7:return value}} +/// +/// ${8:Throws: ${9}Exception ${10}} +endsnippet + +snippet Par "Params (Par)" +Params: ${1:param} = ${2:param description} +/// ${3} +endsnippet + +snippet Ret "Returns (Ret)" +Returns: ${1:return value/s} +endsnippet + +snippet Thr "Throws (Thr)" +Throws: ${1}Exception ${2} +endsnippet + +snippet Example "Examples (Example)" +Examples: +/// -------------------- +/// ${1:example code} +/// -------------------- +endsnippet + + +# License blocks + +snippet gpl "GPL (gpl)" b +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Copyright (C) ${1:Author}, `!v strftime("%Y")` + +${2} +endsnippet + +snippet boost "Boost (boost)" b +// Copyright ${1:Author} `!v strftime("%Y")`. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +${2} +endsnippet + + +# New module + +snippet module "New module (module)" b +// Copyright ${1:Author} `!v strftime("%Y")`. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +module ${2}.`!v vim_snippets#Filename('$1', 'name')`; + + +${3} +endsnippet diff --git a/vim/bundle/vim-snippets/UltiSnips/django.snippets b/vim/bundle/vim-snippets/UltiSnips/django.snippets new file mode 100644 index 0000000..0ba6c9d --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/django.snippets @@ -0,0 +1,361 @@ +priority -50 + +# This files will define django snippets from sublime text djaneiro +# FORMS SNIPPETS + +snippet form "Form" b +class ${1:FORMNAME}(forms.Form): + + ${2:# TODO: Define form fields here} +endsnippet + +snippet modelform "ModelForm" b +class ${1:MODELNAME}Form(forms.ModelForm): + + class Meta: + model = $1 +endsnippet + +snippet fbool "BooleanField" b +${1:FIELDNAME} = forms.BooleanField($2) +endsnippet + +snippet fchar "CharField" b +${1:FIELDNAME} = forms.CharField($2) +endsnippet + +snippet fchoice "ChoiceField" b +${1:FIELDNAME} = forms.ChoiceField($2) +endsnippet + +snippet fcombo "ComboField" b +${1:FIELDNAME} = forms.ComboField($2) +endsnippet + +snippet fdate "DateField" b +${1:FIELDNAME} = forms.DateField($2) +endsnippet + +snippet fdatetime "DateTimeField" b +${1:FIELDNAME} = forms.DateTimeField($2) +endsnippet + +snippet fdecimal "DecimalField" b +${1:FIELDNAME} = forms.DecimalField($2) +endsnippet + +snippet fmail "EmailField" b +${1:FIELDNAME} = forms.EmailField($2) +endsnippet + +snippet ffile "FileField" b +${1:FIELDNAME} = forms.FileField($2) +endsnippet + +snippet ffilepath "FilePathField" b +${1:FIELDNAME} = forms.FilePathField($2) +endsnippet + +snippet ffloat "FloatField" b +${1:FIELDNAME} = forms.FloatField($2) +endsnippet + +snippet fip "IPAddressField" b +${1:FIELDNAME} = forms.IPAddressField($2) +endsnippet + +snippet fimg "ImageField" b +${1:FIELDNAME} = forms.ImageField($2) +endsnippet + +snippet fint "IntegerField" b +${1:FIELDNAME} = forms.IntegerField($2) +endsnippet + +snippet fmochoice "ModelChoiceField" b +${1:FIELDNAME} = forms.ModelChoiceField($2) +endsnippet + +snippet fmomuchoice "ModelMultipleChoiceField" b +${1:FIELDNAME} = forms.ModelMultipleChoiceField($2) +endsnippet + +snippet fmuval "MultiValueField" b +${1:FIELDNAME} = forms.MultiValueField($2) +endsnippet + +snippet fmuchoice "MultipleChoiceField" b +${1:FIELDNAME} = forms.MultipleChoiceField($2) +endsnippet + +snippet fnullbool "NullBooleanField" b +${1:FIELDNAME} = forms.NullBooleanField($2) +endsnippet + +snippet freg "RegexField" b +${1:FIELDNAME} = forms.RegexField($2) +endsnippet + +snippet fslug "SlugField" b +${1:FIELDNAME} = forms.SlugField($2) +endsnippet + +snippet fsdatetime "SplitDateTimeField" b +${1:FIELDNAME} = forms.SplitDateTimeField($2) +endsnippet + +snippet ftime "TimeField" b +${1:FIELDNAME} = forms.TimeField($2) +endsnippet + +snippet ftchoice "TypedChoiceField" b +${1:FIELDNAME} = forms.TypedChoiceField($2) +endsnippet + +snippet ftmuchoice "TypedMultipleChoiceField" b +${1:FIELDNAME} = forms.TypedMultipleChoiceField($2) +endsnippet + +snippet furl "URLField" b +${1:FIELDNAME} = forms.URLField($2) +endsnippet + +# MODELS SNIPPETS + +snippet model "Model" b +class ${1:MODELNAME}(models.Model): + ${0} + class Meta: + verbose_name = "$1" + verbose_name_plural = "$1s" + + def __str__(self): + return super($1, self).__str__() + +endsnippet + +snippet modelfull "Model" b +class ${1:MODELNAME}(models.Model): + ${2:# TODO: Define fields here} + + class Meta: + verbose_name = "$1" + verbose_name_plural = "$1s" + + def __str__(self): + return super($1, self).__str__() + + def save(self): + return super($1, self).save() + + @models.permalink + def get_absolute_url(self): + return ('') + + ${3:# TODO: Define custom methods here} + +endsnippet + +snippet mauto "AutoField" b +${1:FIELDNAME} = models.AutoField($2) +endsnippet + +snippet mbigint "BigIntegerField" b +${1:FIELDNAME} = models.BigIntegerField($2) +endsnippet + +snippet mbool "BooleanField" b +${1:FIELDNAME} = models.BooleanField($2) +endsnippet + +snippet mchar "CharField" b +${1:FIELDNAME} = models.CharField($2, max_length=${3:50}) +endsnippet + +snippet mcoseint "CommaSeparatedIntegerField" b +${1:FIELDNAME} = models.CommaSeparatedIntegerField($2) +endsnippet + +snippet mdate "DateField" b +${1:FIELDNAME} = models.DateField($2) +endsnippet + +snippet mdatetime "DateTimeField" b +${1:FIELDNAME} = models.DateTimeField($2) +endsnippet + +snippet mdecimal "DecimalField" b +${1:FIELDNAME} = models.DecimalField(max_digits=${2:10}, decimal_places=${3:2}) +endsnippet + +snippet memail "EmailField" b +${1:FIELDNAME} = models.EmailField($2) +endsnippet + +snippet mfile "FileField" b +${1:FIELDNAME} = models.FileField($2) +endsnippet + +snippet mfilepath "FilePathField" b +${1:FIELDNAME} = models.FilePathField($2) +endsnippet + +snippet mfloat "FloatField" b +${1:FIELDNAME} = models.FloatField($2) +endsnippet + +snippet fk "ForeignKey" b +${1:FIELDNAME} = models.ForeignKey($2) +endsnippet + +snippet mip "IPAddressField" b +${1:FIELDNAME} = models.IPAddressField($2) +endsnippet + +snippet mimg "ImageField" b +${1:FIELDNAME} = models.ImageField($2) +endsnippet + +snippet mint "IntegerField" b +${1:FIELDNAME} = models.IntegerField($2) +endsnippet + +snippet m2m "ManyToManyField" b +${1:FIELDNAME} = models.ManyToManyField($2) +endsnippet + +snippet mnullbool "NullBooleanField" b +${1:FIELDNAME} = models.NullBooleanField($2) +endsnippet + +snippet o2o "OneToOneField" b +${1:FIELDNAME} = models.OneToOneField($2) +endsnippet + +snippet mphone "PhoneNumberField" b +${1:FIELDNAME} = models.PhoneNumberField($2) +endsnippet + +snippet mposint "PositiveIntegerField" b +${1:FIELDNAME} = models.PositiveIntegerField($2) +endsnippet + +snippet mpossmallint "PositiveSmallIntegerField" b +${1:FIELDNAME} = models.PositiveSmallIntegerField($2) +endsnippet + +snippet mslug "SlugField" b +${1:FIELDNAME} = models.SlugField($2) +endsnippet + +snippet msmallint "SmallIntegerField" b +${1:FIELDNAME} = models.SmallIntegerField($2) +endsnippet + +snippet mtext "TextField" b +${1:FIELDNAME} = models.TextField($2) +endsnippet + +snippet mtime "TimeField" b +${1:FIELDNAME} = models.TimeField($2) +endsnippet + +snippet murl "URLField" b +${1:FIELDNAME} = models.URLField($2) +endsnippet + +snippet musstate "USStateField" b +${1:FIELDNAME} = models.USStateField($2) +endsnippet + +snippet mxml "XMLField" b +${1:FIELDNAME} = models.XMLField($2) +endsnippet + +# VIEWS SNIPPETS + +snippet adminview "Model Admin View" b +class ${1}Admin(admin.ModelAdmin): + ''' + Admin View for ${1} + ''' + list_display = ('${2}',) + list_filter = ('${3}',) + inlines = [ + ${4}Inline, + ] + raw_id_fields = ('${5}',) + readonly_fields = ('${6}',) + search_fields = ['${7}'] +admin.site.register(${1}, ${1}Admin) +endsnippet + +snippet createview "Generic Create View" b +class ${1:MODEL_NAME}CreateView(CreateView): + model = ${1:MODEL_NAME} + template_name = "${2:TEMPLATE_NAME}" +endsnippet + +snippet deleteview "Generic Delete View" b +class ${1:MODEL_NAME}DeleteView(DeleteView): + model = ${1:MODEL_NAME} + template_name = "${2:TEMPLATE_NAME}" +endsnippet + +snippet detailview "Generic Detail View" b +class ${1:MODEL_NAME}DetailView(DetailView): + model = ${1:MODEL_NAME} + template_name = "${2:TEMPLATE_NAME}" +endsnippet + +snippet listview "Generic List View" b +class ${1:MODEL_NAME}ListView(ListView): + model = ${1:MODEL_NAME} + template_name = "${2:TEMPLATE_NAME}" +endsnippet + +snippet stackedinline "Stacked Inline" b +class ${1}Inline(admin.StackedInline): + ''' + Stacked Inline View for ${1} + ''' + model = ${2:${1}} + min_num = ${3:3} + max_num = ${4:20} + extra = ${5:1} + raw_id_fields = (${6},) +endsnippet + +snippet tabularinline "Tabular Inline" b +class ${1}Inline(admin.TabularInline): + ''' + Tabular Inline View for ${1} + ''' + model = ${2:${1}} + min_num = ${3:3} + max_num = ${4:20} + extra = ${5:1} + raw_id_fields = (${6},) +endsnippet + +snippet templateview "Generic Template View" b +class ${1:CLASS_NAME}(TemplateView): + template_name = "${2:TEMPLATE_NAME}" +endsnippet + +snippet updateview "Generic Update View" b +class ${1:MODEL_NAME}UpdateView(UpdateView): + model = ${1:MODEL_NAME} + template_name = "${2:TEMPLATE_NAME}" +endsnippet + +snippet dispatch "Dispatch View method" b +def dispatch(self, request, *args, **kwargs): + return super(${1:CLASS_NAME}, self).dispatch(request, *args, **kwargs) +endsnippet + +snippet context "get_context_data view method" b +def get_context_data(self, **kwargs): + kwargs['extra_context'] = ${1:'New Value'} + return super(${2:CLASS_NAME}, self).get_context_data(**kwargs) +endsnippet diff --git a/vim/bundle/vim-snippets/UltiSnips/eelixir.snippets b/vim/bundle/vim-snippets/UltiSnips/eelixir.snippets new file mode 100644 index 0000000..72fb7ce --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/eelixir.snippets @@ -0,0 +1,39 @@ +priority -50 + +extends html + +snippet % "<% %>" w +<% $0 %> +endsnippet + +snippet = "<%= %>" w +<%= $0 %> +endsnippet + +snippet end "<% end %>" w +<% end %> +endsnippet + +snippet for +<%= for ${1:item} <- ${2:$1s} ${3:@conn} do %> + $0 +<% end %> +endsnippet + +snippet ft "form_tag" w +<%= form_tag(${1:"${2:/users}"}, method: ${3::post}) %> + $0 +</form> +endsnippet + +snippet lin "link" w +<%= link ${1:"${2:Submit}"}, to: ${3:"${4:/users}"}, method: ${5::delete} %> +endsnippet + +snippet ff "form_for" w +<%= form_for @changeset, ${1:"${2:/users}"}, fn f -> %> + $0 + + <%= submit "Submit" %> +<% end %> +endsnippet diff --git a/vim/bundle/vim-snippets/UltiSnips/erlang.snippets b/vim/bundle/vim-snippets/UltiSnips/erlang.snippets new file mode 100644 index 0000000..f317685 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/erlang.snippets @@ -0,0 +1,108 @@ +########################################################################### +# TEXTMATE SNIPPETS # +########################################################################### + +priority -50 + +snippet pat "Case:Receive:Try Clause" +${1:pattern}${2: when ${3:guard}} -> + ${4:body} +endsnippet + +snippet beh "Behaviour Directive" b +-behaviour(${1:behaviour}). +endsnippet + +snippet case "Case Expression" +case ${1:expression} of + ${2:pattern}${3: when ${4:guard}} -> + ${5:body} +end +endsnippet + +snippet def "Define Directive" b +-define(${1:macro}${2: (${3:param})}, ${4:body}). +endsnippet + +snippet exp "Export Directive" b +-export([${1:function}/${2:arity}]). +endsnippet + +snippet fun "Fun Expression" +fun + (${1:pattern})${2: when ${3:guard}} -> + ${4:body} +end +endsnippet + +snippet fu "Function" +${1:function}(${2:param})${3: when ${4:guard}} -> + ${5:body} +endsnippet + +snippet if "If Expression" +if + ${1:guard} -> + ${2:body} +end +endsnippet + +snippet ifdef "Ifdef Directive" b +-ifdef(${1:macro}). +endsnippet + +snippet ifndef "Ifndef Directive" b +-ifndef(${1:macro}). +endsnippet + +snippet imp "Import Directive" b +-import(${1:module}, [${2:function}/${3:arity}]). +endsnippet + +snippet inc "Include Directive" b +-include("${1:file}"). +endsnippet + +snippet mod "Module Directive" b +-module(${1:`!p snip.rv = snip.basename or "module"`}). +endsnippet + +snippet rcv "Receive Expression" +receive +${1: ${2:pattern}${3: when ${4:guard}} -> + ${5:body}} +${6:after + ${7:expression} -> + ${8:body}} +end +endsnippet + +snippet rec "Record Directive" b +-record(${1:record}, {${2:field}${3: = ${4:value}}}). +endsnippet + +snippet try "Try Expression" +try${1: ${2:expression}${3: of + ${4:pattern}${5: when ${6:guard}} -> + ${7:body}}} +${8:catch + ${9:pattern}${10: when ${11:guard}} -> + ${12:body}} +${13:after + ${14:body}} +end +endsnippet + +snippet undef "Undef Directive" b +-undef(${1:macro}). +endsnippet + +snippet || "List Comprehension" +[${1:X} || ${2:X} <- ${3:List}${4:, gen}] +endsnippet + +snippet gen "Generator Expression" +${1:X} <- ${2:List}${3:, gen} +endsnippet + +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/eruby.snippets b/vim/bundle/vim-snippets/UltiSnips/eruby.snippets new file mode 100644 index 0000000..fe38c2f --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/eruby.snippets @@ -0,0 +1,237 @@ +extends html + +priority -50 + +# TextMate added these variables to cope with changes in ERB handling +# in different versions of Rails -- for instance, Rails 3 automatically +# strips whitespace so that it's no longer necessary to use a form like +# <% end -%>, but if you're still maintaining Rails 2 projects, you +# can't omit the minus sign and get the same behavior. +# +# The following regex replace substitutes the function below for the +# TextMate variable references after the snippets are converted: +# +# /\v\$\{(TM_RAILS_TEMPLATE_([^_]+)_RUBY_([^_\s]+))\}/`!p textmate_var('\1', snip)`/g +# +global !p +def textmate_var(var, snip): + lookup = dict( + TM_RAILS_TEMPLATE_START_RUBY_EXPR = snip.opt('g:tm_rails_template_start_ruby_expr', '<%= '), + TM_RAILS_TEMPLATE_END_RUBY_EXPR = snip.opt('g:tm_rails_template_end_ruby_expr', ' %>'), + TM_RAILS_TEMPLATE_START_RUBY_INLINE = snip.opt('g:tm_rails_template_start_ruby_inline', '<% '), + TM_RAILS_TEMPLATE_END_RUBY_INLINE = snip.opt('g:tm_rails_template_end_ruby_inline', ' %>'), + TM_RAILS_TEMPLATE_END_RUBY_BLOCK = '<% end %>' + ) + snip.rv = lookup[var] + return +endglobal + + +snippet % "<% ${0} %>" i +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`${0}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_INLINE', snip)` +endsnippet + +snippet = "<%= ${0} %>" i +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`${0}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +########################################################################### +# GENERATED FROM get_tm_snippets.py + REGEX REPLACE # +########################################################################### + +snippet fi "<%= Fixtures.identify(:symbol) %>" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`Fixtures.identify(:${1:name})`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)`$0 +endsnippet + +snippet ft "form_tag" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`form_tag(${1::action => '${2:update}'}${3:, ${4:${5:class} => '${6:form}'\}}}) do`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` + $0 +`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)` +endsnippet + +snippet ffs "form_for submit 2" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`${1:f}.submit '${2:Submit}'${3:, :disable_with => '${4:$2ing...}'}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet f. "f_fields_for (nff)" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`f.fields_for :${1:attribute} do |${2:f}|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_INLINE', snip)` + $0 +`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)` +endsnippet + +snippet f. "f.checkbox" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.check_box :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet f. "f.file_field" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.file_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet f. "f.hidden_field" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.hidden_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet f. "f.label" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.label :${1:attribute}${2:, "${3:${1/[[:alpha:]]+|(_)/(?1: :\u$0)/g}}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet f. "f.password_field" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.password_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet f. "f.radio_button" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.radio_button :${1:attribute}, :${2:tag_value}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet f. "f.submit" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.submit "${1:Submit}"${2:, :disable_with => '${3:$1ing...}'}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet f. "f.text_area" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.text_area :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet f. "f.text_field" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.text_field :${1:attribute}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet ffe "form_for with errors" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`error_messages_for :${1:model}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` + +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`form_for @${2:$1} do |f|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` + $0 +`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)` +endsnippet + +snippet ff "form_for" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`form_for @${1:model} do |f|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` + $0 +`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)` +endsnippet + +snippet ist "image_submit_tag" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`image_submit_tag("${1:agree.png}"${2:${3:, :id => "${4:${1/^(\w+)(\.\w*)?$/$1/}}"}${5:, :name => "${6:${1/^(\w+)(\.\w*)?$/$1/}}"}${7:, :class => "${8:${1/^(\w+)(\.\w*)?$/$1/}-button}"}${9:, :disabled => ${10:false}}})`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet it "image_tag" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`image_tag "$1${2:.png}"${3:${4:, :title => "${5:title}"}${6:, :class => "${7:class}"}}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet layout "layout" +layout "${1:template_name}"${2:${3:, :only => ${4:[:${5:action}, :${6:action}]}}${7:, :except => ${8:[:${9:action}, :${10:action}]}}} +endsnippet + +snippet jit "javascript_include_tag" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`javascript_include_tag ${1::all}${2:, :cache => ${3:true}}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet lt "link_to (name, dest)" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", ${2:dest}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet lia "link_to (action)" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", :action => "${2:index}"`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet liai "link_to (action, id)" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", :action => "${2:edit}", :id => ${3:@item}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet lic "link_to (controller)" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", :controller => "${2:items}"`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet lica "link_to (controller, action)" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", :controller => "${2:items}", :action => "${3:index}"`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet licai "link_to (controller, action, id)" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", :controller => "${2:items}", :action => "${3:edit}", :id => ${4:@item}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet linpp "link_to (nested path plural)" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:"${2:link text...}"}, ${3:${10:parent}_${11:child}_path(${12:@}${13:${10}})}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet linp "link_to (nested path)" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:"${2:link text...}"}, ${3:${12:parent}_${13:child}_path(${14:@}${15:${12}}, ${16:@}${17:${13}})}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet lipp "link_to (path plural)" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:"${2:link text...}"}, ${3:${4:model}s_path}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet lip "link_to (path)" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:"${2:link text...}"}, ${3:${12:model}_path(${13:@}${14:${12}})}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet lim "link_to model" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to ${1:model}.${2:name}, ${3:${4:$1}_path(${14:$1})}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet hide "page.hide (*ids)" +page.hide ${1:"${2:id(s)}"} +endsnippet + +snippet ins "page.insert_html (position, id, partial)" +page.insert_html :${1:top}, ${2:"${3:id}"}, :${4:partial => "${5:template}"} +endsnippet + +snippet rep "page.replace (id, partial)" +page.replace ${1:"${2:id}"}, :${3:partial => "${4:template}"} +endsnippet + +snippet reph "page.replace_html (id, partial)" +page.replace_html ${1:"${2:id}"}, :${3:partial => "${4:template}"} +endsnippet + +snippet show "page.show (*ids)" +page.show ${1:"${2:id(s)}"} +endsnippet + +snippet tog "page.toggle (*ids)" +page.toggle ${1:"${2:id(s)}"} +endsnippet + +snippet vis "page.visual_effect (effect, id)" +page.visual_effect :${1:toggle_slide}, ${2:"${3:DOM ID}"} +endsnippet + +snippet rp "render (partial) (rp)" +render :partial => "${1:item}" +endsnippet + +snippet rpc "render (partial,collection) (rpc)" +render :partial => "${1:item}", :collection => ${2:@$1s} +endsnippet + +snippet rpl "render (partial,locals) (rpl)" +render :partial => "${1:item}", :locals => { :${2:$1} => ${3:@$1}$0 } +endsnippet + +snippet rpo "render (partial,object) (rpo)" +render :partial => "${1:item}", :object => ${2:@$1} +endsnippet + +snippet rps "render (partial,status) (rps)" +render :partial => "${1:item}", :status => ${2:500} +endsnippet + +snippet slt "stylesheet_link_tag" w +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`stylesheet_link_tag ${1::all}${2:, :cache => ${3:true}}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet st "submit_tag" w +`!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)" +<% else %> + $0 +endsnippet + +snippet lf "link_to_function" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to_function ${1:"${2:Greeting}"}, "${3:alert('Hello world!')}"$4`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/go.snippets b/vim/bundle/vim-snippets/UltiSnips/go.snippets new file mode 100644 index 0000000..b6891ff --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/go.snippets @@ -0,0 +1,115 @@ +# Snippets for Go + +priority -50 + +# when to abbriviate and when not? +# b doesn't work here, because it ignores whitespace +# optional local name? +snippet /^import/ "Import declaration" r +import ( + "${1:package}" +) +endsnippet + +snippet /^package/ "Package declaration" r +// Package $1 provides ... +package ${1:main} +endsnippet + +# Mostly converted from: https://github.com/AlanQuatermain/go-tmbundle +snippet /^cons/ "Constants declaration" r +const ( + ${1:constant}${2/(.+)/ /}${2:type} = ${0:value} +) +endsnippet + +snippet /^con/ "Constant declaration" r +const ${1:name}${2/(.+)/ /}${2:type} = ${0:value} +endsnippet + +snippet iota "Iota constant generator" b +const ( + ${1:constant}${2/(.+)/ /}${2:type} = iota +) +endsnippet + +snippet struct "Struct declaration" b +type ${1:Struct} struct { + ${0:${VISUAL}} +} +endsnippet + +snippet interface "Interface declaration" b +type ${1:Interface} interface { + ${0:${VISUAL}} +} +endsnippet + +snippet if "If statement" b +if ${1:condition}${1/(.+)/ /}{ + ${0:${VISUAL}} +} +endsnippet + +snippet switch "Switch statement" b +switch ${1:expression}${1/(.+)/ /}{ +case${0} +} +endsnippet + +# functions +snippet /^main/ "Main function" r +func main() { + ${0:${VISUAL}} +} +endsnippet + +snippet /^meth/ "Method" r +func (${1:receiver} ${2:type}) ${3:name}(${4:params})${5/(.+)/ /}${5:type} { + ${0:${VISUAL}} +} +endsnippet + +snippet func "Function" b +func ${1:name}(${2:params})${3/(.+)/ /}${3:type} { + ${0:${VISUAL}} +} +endsnippet + +snippet funch "HTTP handler" b +func ${1:handler}(${2:w} http.ResponseWriter, ${3:r} *http.Request) { + ${0:${VISUAL}} +} +endsnippet + +# types and variables +snippet map "Map type" b +map[${1:keytype}]${2:valtype} +endsnippet + +snippet : "Variable declaration :=" b +${1:name} := ${0:value} +endsnippet + +snippet var "Variable declaration" b +var ${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value}} +endsnippet + +snippet vars "Variables declaration" b +var ( + ${1:name}${2/(.+)/ /}${2:type}${3: = ${0:value} } +) +endsnippet + +snippet json "JSON field" +\`json:"${1:displayName}"\` +endsnippet + +# vim:ft=snippets: + +# error handling +snippet err "Basic error handling" b +if err != nil { + log.${1:Fatal}(err) +} +endsnippet diff --git a/vim/bundle/vim-snippets/UltiSnips/help.snippets b/vim/bundle/vim-snippets/UltiSnips/help.snippets new file mode 100644 index 0000000..b07a7de --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/help.snippets @@ -0,0 +1,37 @@ +# Snippets for VIM Help Files + +priority -50 + +global !p +def sec_title(snip, t): + file_start = snip.fn.split('.')[0] + sec_name = t[1].strip("1234567890. ").lower().replace(' ', '-') + return ("*%s-%s*" % (file_start, sec_name)).rjust(78-len(t[1])) +endglobal + +snippet sec "Section marker" b +============================================================================== +${1:SECTION}`!p snip.rv = sec_title(snip, t)` + +$0 +endsnippet + +snippet ssec "Sub section marker" b +${1:Subsection}`!p snip.rv = sec_title(snip, t) +snip += "-"*len(t[1])` + +$0 +endsnippet + +snippet sssec "Subsub Section marker" b +${1:SubSubsection}:`!p snip.rv = sec_title(snip, t)` + +$0 +endsnippet + +# For vim help, follow the same settings as the official docs. +snippet modeline "Vim help modeline" + `!v 'vim'`:tw=78:ts=8:ft=help:norl: +endsnippet + +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/html.snippets b/vim/bundle/vim-snippets/UltiSnips/html.snippets new file mode 100644 index 0000000..fd1aca5 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/html.snippets @@ -0,0 +1,306 @@ +priority -50 + +########################################################################### +# TextMate Snippets # +########################################################################### + +global !p +def x(snip): + if snip.ft.startswith("x"): + snip.rv = '/' + else: + snip.rv = "" +endglobal + +############ +# Doctypes # +############ +snippet doctype "DocType XHTML 1.0 Strict" b +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> + +endsnippet + +snippet doctype "DocType XHTML 1.0 Transitional" b +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + +endsnippet + +snippet doctype "DocType XHTML 1.1" b +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" + "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> + +endsnippet + +snippet doctype "HTML - 4.0 Transitional (doctype)" b +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" + "http://www.w3.org/TR/html4/loose.dtd"> + +endsnippet + +snippet doctype "HTML - 5.0 (doctype)" b +<!DOCTYPE html> + +endsnippet + +############# +# Shortcuts # +############# +snippet down "Down (down)" +↓ +endsnippet + +snippet enter "Enter (enter)" +⌅ +endsnippet + +snippet escape "Escape (escape)" +⎋ +endsnippet + +snippet shift "Shift (shift)" +⇧ +endsnippet + +snippet tab "Tab (tab)" +⇥ +endsnippet + +snippet up "Up (up)" +↑ +endsnippet + +snippet return "Return (return)" +↩ +endsnippet + +snippet right "Right (right)" +→ +endsnippet + +snippet left "Left (left)" +← +endsnippet + +snippet option "Option (option)" +⌥ +endsnippet + +####################### +# Conditional inserts # +####################### +snippet ! "IE Conditional Comment: Internet Explorer 5_0 only" +<!--[if IE 5.0]>${1:IE Conditional Comment: Internet Explorer 5.0 only }<![endif]-->$0 +endsnippet + +snippet ! "IE Conditional Comment: Internet Explorer 5_5 only" +<!--[if IE 5.5000]>${1:IE Conditional Comment: Internet Explorer 5.5 only }<![endif]-->$0 +endsnippet + +snippet ! "IE Conditional Comment: Internet Explorer 5_x" +<!--[if lt IE 6]>${1:IE Conditional Comment: Internet Explorer 5.x }<![endif]-->$0 +endsnippet + +snippet ! "IE Conditional Comment: Internet Explorer 6 and below" +<!--[if lte IE 6]>${1:IE Conditional Comment: Internet Explorer 6 and below }<![endif]-->$0 +endsnippet + +snippet ! "IE Conditional Comment: Internet Explorer 6 only" +<!--[if IE 6]>${1:IE Conditional Comment: Internet Explorer 6 only }<![endif]-->$0 +endsnippet + +snippet ! "IE Conditional Comment: Internet Explorer 7+" +<!--[if gte IE 7]>${1:IE Conditional Comment: Internet Explorer 7 and above }<![endif]-->$0 +endsnippet + +snippet ! "IE Conditional Comment: Internet Explorer" +<!--[if IE]>${1: IE Conditional Comment: Internet Explorer }<![endif]-->$0 +endsnippet + +snippet ! "IE Conditional Comment: NOT Internet Explorer" +<!--[if !IE]><!-->${1: IE Conditional Comment: NOT Internet Explorer }<!-- <![endif]-->$0 +endsnippet + +############# +# HTML TAGS # +############# +snippet input "Input with Label" w +<label for="${2:${1/[[:alpha:]]+|( )/(?1:_:\L$0)/g}}">$1</label><input type="${3:text/submit/hidden/button}" name="${4:$2}" value="$5"${6: id="${7:$2}"}`!p x(snip)`> + +endsnippet + +snippet input "XHTML <input>" w +<input type="${1:text/submit/hidden/button}" name="${2:some_name}" value="$3"${4: id="${5:$2}"}`!p x(snip)`> +endsnippet + + +snippet opt "Option" w +<option${1: value="${2:option}"}>${3:$2}</option> +endsnippet + +snippet select "Select Box" w +<select name="${1:some_name}" id="${2:$1}"${3:${4: multiple}${5: onchange="${6:}"}${7: size="${8:1}"}}> + <option${9: value="${10:option1}"}>${11:$10}</option> + <option${12: value="${13:option2}"}>${14:$13}</option>${15:} + $0 +</select> +endsnippet + + +snippet textarea "XHTML <textarea>" w +<textarea name="${1:Name}" rows="${2:8}" cols="${3:40}">$0</textarea> +endsnippet + +snippet mailto "XHTML <a mailto: >" w +<a href="mailto:${1:joe@example.com}?subject=${2:feedback}">${3:email me}</a> +endsnippet + +snippet base "XHTML <base>" w +<base href="$1"${2: target="$3"}`!p x(snip)`> +endsnippet + +snippet body "<body>" +<body> + $0 +</body> +endsnippet + +snippet div "<div>" w +<div> + $0 +</div> +endsnippet + +snippet div. "<div> with class" w +<div`!p snip.rv=' class="' if t[1] else ""`${1:name}`!p snip.rv = '"' if t[1] else ""`> + $0 +</div> +endsnippet + +snippet div# "<div> with ID & class" w +<div`!p snip.rv=' id="' if t[1] else ""`${1:name}`!p snip.rv = '"' if t[1] else ""``!p snip.rv=' class="' if t[2] else ""`${2:name}`!p snip.rv = '"' if t[2] else ""`> + $0 +</div> +endsnippet + +snippet form "XHTML <form>" w +<form action="${1:`!p +snip.rv = (snip.basename or 'unnamed') + '_submit' +`}" method="${2:get}" accept-charset="utf-8"> + $0 + + <p><input type="submit" value="Continue →"`!p x(snip)`></p> +</form> +endsnippet + +snippet h1 "XHTML <h1>" w +<h1>$0</h1> +endsnippet + +snippet h2 "XHTML <h2>" w +<h2>$0</h2> +endsnippet + +snippet h3 "XHTML <h3>" w +<h3>$0</h3> +endsnippet + +snippet h4 "XHTML <h4>" w +<h4>$0</h4> +endsnippet + +snippet head "XHTML <head>" +<head> + <meta charset="utf-8"> + <title>${1:`!p snip.rv = snip.basename or "Page Title"`}</title> + $0 +</head> +endsnippet + +snippet link "XHTML <link>" w +<link rel="${1:stylesheet}" href="${2:/css/master.css}" type="text/css" media="${3:screen}" title="${4:no title}" charset="${5:utf-8}"`!p x(snip)`> +endsnippet + +snippet meta "XHTML <meta>" w +<meta name="${1:name}" content="${2:content}"`!p x(snip)`> +endsnippet + +snippet scriptsrc "XHTML <script src...>" w +<script src="$1" type="text/javascript" charset="${3:utf-8}"></script> +endsnippet + +snippet script "XHTML <script>" w +<script type="text/javascript" charset="utf-8"> + $0 +</script> +endsnippet + +snippet style "XHTML <style>" w +<style type="text/css" media="screen"> + $0 +</style> +endsnippet + +snippet table "XHTML <table>" w +<table border="${1:0}"${2: cellspacing="${3:5}" cellpadding="${4:5}"}> + <tr><th>${5:Header}</th></tr> + <tr><td>${0:Data}</td></tr> +</table> +endsnippet + +snippet a "Link" w +<a href="${1:http://www.${2:url.com}}"${3: target="_blank"}>${4:Anchor Text}</a> +endsnippet + +snippet p "paragraph" w +<p>$0</p> +endsnippet + +snippet li "list item" w +<li>$0</li> +endsnippet + +snippet ul "unordered list" w +<ul> +$0 +</ul> +endsnippet + +snippet td "table cell" w +<td>$0</td> +endsnippet + +snippet th "table header" w +<th>$0</th> +endsnippet + +snippet tr "table row" w +<tr>$0</tr> +endsnippet + +snippet title "XHTML <title>" w +<title>${1:`!p snip.rv = snip.basename or "Page Title"`}</title> +endsnippet + +snippet fieldset "Fieldset" w +<fieldset id="${1/[\w\d]+|( )/(?1:_:\L$0\E)/g}" ${2:class="${3:}"}> + <legend>$1</legend> + $0 +</fieldset> +endsnippet + +snippet movie "Embed QT movie (movie)" b +<object width="$2" height="$3" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab"> + <param name="src" value="$1"`!p x(snip)`> + <param name="controller" value="$4"`!p x(snip)`> + <param name="autoplay" value="$5"`!p x(snip)`> + <embed src="${1:movie.mov}" + width="${2:320}" height="${3:240}" + controller="${4:true}" autoplay="${5:true}" + scale="tofit" cache="true" + pluginspage="http://www.apple.com/quicktime/download/" + `!p x(snip)`> +</object> +endsnippet +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/html_minimal.snippets b/vim/bundle/vim-snippets/UltiSnips/html_minimal.snippets new file mode 100644 index 0000000..e7ca5e0 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/html_minimal.snippets @@ -0,0 +1,33 @@ +# more can be found in snippets/html_minimal.snippets +# these UltiSnips override snippets because nested placeholders are being used + +priority -50 + +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 diff --git a/vim/bundle/vim-snippets/UltiSnips/htmldjango.snippets b/vim/bundle/vim-snippets/UltiSnips/htmldjango.snippets new file mode 100644 index 0000000..37fa85f --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/htmldjango.snippets @@ -0,0 +1,299 @@ +priority -50 + +extends html + +# Generic Tags +snippet % "" bi +{% ${1} %}${2} +endsnippet + +snippet %% "" bi +{% ${1:tag_name} %} + ${2} +{% end$1 %} +endsnippet + +snippet { "" bi +{{ ${1} }}${2} +endsnippet + +# Template Tags + +snippet autoescape "" bi +{% autoescape ${1:off} %} + ${2} +{% endautoescape %} +endsnippet + +snippet block "" bi +{% block ${1} %} + ${2} +{% endblock $1 %} +endsnippet + +snippet # "" bi +{# ${1:comment} #} +endsnippet + +snippet comment "" bi +{% comment %} + ${1} +{% endcomment %} +endsnippet + +snippet cycle "" bi +{% cycle ${1:val1} ${2:val2} ${3:as ${4}} %} +endsnippet + +snippet debug "" bi +{% debug %} +endsnippet + +snippet extends "" bi +{% extends "${1:base.html}" %} +endsnippet + +snippet filter "" bi +{% filter ${1} %} + ${2} +{% endfilter %} +endsnippet + +snippet firstof "" bi +{% firstof ${1} %} +endsnippet + +snippet for "" bi +{% for ${1} in ${2} %} + ${3} +{% endfor %} +endsnippet + +snippet empty "" bi +{% empty %} + ${1} +endsnippet + +snippet if "" bi +{% if ${1} %} + ${2} +{% endif %} +endsnippet + +snippet iif "" bi +{% if ${1} %}${2}{% endif %} +endsnippet + +snippet ielse "" bi +{% else %}${1} +endsnippet + +snippet else "" bi +{% else %} + ${1} +endsnippet + +snippet ielif "" bi +{% elif %}${1} +endsnippet + +snippet elif "" bi +{% elif %} + ${1} +endsnippet + +snippet ifchanged "" bi +{% ifchanged %}${1}{% endifchanged %} +endsnippet + +snippet ifequal "" bi +{% ifequal ${1} ${2} %} + ${3} +{% endifequal %} +endsnippet + +snippet ifnotequal "" bi +{% ifnotequal ${1} ${2} %} + ${3} +{% endifnotequal %} +endsnippet + +snippet include "" bi +{% include "${1}" %} +endsnippet + +snippet load "" bi +{% load ${1} %} +endsnippet + +snippet now "" bi +{% now "${1:jS F Y H:i}" %} +endsnippet + +snippet regroup "" bi +{% regroup ${1} by ${2} as ${3} %} +endsnippet + +snippet spaceless "" bi +{% spaceless %}${1}{% endspaceless %} +endsnippet + +snippet ssi "" bi +{% ssi ${1} %} +endsnippet + +snippet trans "" bi +{% trans "${1:string}" %} +endsnippet + +snippet url "" bi +{% url ${1} as ${2} %} +endsnippet + +snippet widthratio "" bi +{% widthratio ${1:this_value} ${2:max_value} ${3:100} %} +endsnippet + +snippet with "" bi +{% with ${1} as ${2} %} + ${VISUAL} +{% endwith %} +endsnippet + +snippet verbatim "" bi +{% verbatim %} + ${VISUAL} +{% endverbatim %} +endsnippet + +snippet super "" bi +{{ block.super }} +endsnippet + +snippet staticu "" bi +{{ STATIC_URL }} +endsnippet + +snippet static "" bi +{% static "${VISUAL}" %} +endsnippet + +snippet mediau "" bi +{{ MEDIA_URL }} +endsnippet + +snippet iblock "" bi +{% block ${1:blockname} %}${VISUAL}{% endblock $1 %} +endsnippet + +snippet csrf "" bi +{% csrf_token %} +endsnippet + +snippet blocktrans "" bi +{% blocktrans %} + ${VISUAL} +{% endblocktrans %} +endsnippet + +snippet lorem "" bi +{% lorem ${1} %} +endsnippet + +# Template Filters + +# Note: Since SnipMate can't determine which template filter you are +# expanding without the "|" character, these do not add the "|" +# character. These save a few keystrokes still. + +# Note: Template tags that take no arguments are not implemented. + +snippet add "" bi +add:"${1}" +endsnippet + +snippet center "" bi +center:"${1}" +endsnippet + +snippet cut "" bi +cut:"${1}" +endsnippet + +snippet date "" bi +date:"${1}" +endsnippet + +snippet default "" bi +default:"${1}" +endsnippet + +snippet defaultifnone "" bi +default_if_none:"${1}" +endsnippet + +snippet dictsort "" bi +dictsort:"${1}" +endsnippet + +snippet dictsortrev "" bi +dictsortreversed:"${1}" +endsnippet + +snippet divisibleby "" bi +divisibleby:"${1}" +endsnippet + +snippet floatformat "" bi +floatformat:"${1}" +endsnippet + +snippet getdigit "" bi +get_digit:"${1}" +endsnippet + +snippet join "" bi +join:"${1}" +endsnippet + +snippet lengthis "" bi +length_is:"${1}" +endsnippet + +snippet pluralize "" bi +pluralize:"${1}" +endsnippet + +snippet removetags "" bi +removetags:"${1}" +endsnippet + +snippet slice "" bi +slice:"${1}" +endsnippet + +snippet stringformat "" bi +stringformat:"${1}" +endsnippet + +snippet time "" bi +time:"${1}" +endsnippet + +snippet truncatewords "" bi +truncatewords:${1} +endsnippet + +snippet truncatewordshtml "" bi +truncatewords_html:${1} +endsnippet + +snippet urlizetrunc "" bi +urlizetrunc:${1} +endsnippet + +snippet wordwrap "" bi +wordwrap:${1} +endsnippet + +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/htmljinja.snippets b/vim/bundle/vim-snippets/UltiSnips/htmljinja.snippets new file mode 100644 index 0000000..fa3b3c2 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/htmljinja.snippets @@ -0,0 +1,3 @@ +priority -50 + +extends html, jinja2 diff --git a/vim/bundle/vim-snippets/UltiSnips/java.snippets b/vim/bundle/vim-snippets/UltiSnips/java.snippets new file mode 100644 index 0000000..54d026d --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/java.snippets @@ -0,0 +1,435 @@ +priority -50 + +# Many of the snippets here use a global option called +# "g:ultisnips_java_brace_style" which, if set to "nl" will put a newline +# before '{' braces. +# Setting "g:ultisnips_java_junit" will change how the test method snippet +# looks, it is defaulted to junit4, setting this option to 3 will remove the +# @Test annotation from the method + +global !p +def junit(snip): + if snip.opt("g:ultisnips_java_junit", "") == "3": + snip += "" + else: + snip.rv += "@Test\n\t" + +def nl(snip): + if snip.opt("g:ultisnips_java_brace_style", "") == "nl": + snip += "" + else: + snip.rv += " " +def getArgs(group): + import re + word = re.compile('[a-zA-Z0-9><.]+ \w+') + return [i.split(" ") for i in word.findall(group) ] + +def camel(word): + if not word: return '' + return word[0].upper() + word[1:] + +def mixedCase(word): + if not word: return '' + return word[0].lower() + word[1:] + +endglobal + +snippet sleep "try sleep catch" b +try { + Thread.sleep(${1:1000}); +} catch (InterruptedException e){ + e.printStackTrace(); +} +endsnippet + +snippet /i|n/ "new primitive or int" br +${1:int} ${2:i} = ${3:1}; +$0 +endsnippet + +snippet /o|v/ "new Object or variable" br +${1:Object} ${2:var} = new $1(${3}); +endsnippet + +snippet f "field" b +${1:private} ${2:String} ${3:`!p snip.rv = t[2].lower()`}; +endsnippet + +snippet ab "abstract" b +abstract $0 +endsnippet + +snippet as "assert" b +assert ${1:test}${2/(.+)/(?1: \: ")/}${2:Failure message}${2/(.+)/(?1:")/}; +endsnippet + +snippet at "assert true" b +assertTrue(${1:actual}); +endsnippet + +snippet af "assert false" b +assertFalse(${1:actual}); +endsnippet + +snippet ae "assert equals" b +assertEquals(${1:expected}, ${2:actual}); +endsnippet + +snippet br "break" +break; + +endsnippet + +snippet cs "case" b +case $1: + $2 +$0 +endsnippet + +snippet ca "catch" b +catch (${1:Exception} ${2:e})`!p nl(snip)`{ + $0 +} +endsnippet + +snippet cle "class extends" b +public class ${1:`!p +snip.rv = snip.basename or "untitled"`} ${2:extends ${3:Parent} }${4:implements ${5:Interface} }{ + $0 +} +endsnippet + +snippet clc "class with constructor, fields, setter and getters" b +public class `!p +snip.rv = snip.basename or "untitled"` { +`!p +args = getArgs(t[1]) +if len(args) == 0: snip.rv = "" +for i in args: + snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";" +if len(args) > 0: + snip.rv += "\n"` + public `!p snip.rv = snip.basename or "unknown"`($1) {`!p +args = getArgs(t[1]) +for i in args: + snip.rv += "\n\t\tthis." + i[1] + " = " + i[1] + ";" +if len(args) == 0: + snip.rv += "\n"` + }$0 +`!p +args = getArgs(t[1]) +if len(args) == 0: snip.rv = "" +for i in args: + snip.rv += "\n\tpublic void set" + camel(i[1]) + "(" + i[0] + " " + i[1] + ") {\n" + "\ + \tthis." + i[1] + " = " + i[1] + ";\n\t}\n" + + snip.rv += "\n\tpublic " + i[0] + " get" + camel(i[1]) + "() {\n\ + \treturn " + i[1] + ";\n\t}\n" +` +} +endsnippet + +snippet clc "class with constructor, with field names" b +public class `!p +snip.rv = snip.basename or "untitled"` { +`!p +args = getArgs(t[1]) +for i in args: + snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";" +if len(args) > 0: + snip.rv += "\n"` + public `!p snip.rv = snip.basename or "unknown"`($1) {`!p +args = getArgs(t[1]) +for i in args: + snip.rv += "\n\t\tthis.%s = %s;" % (i[1], i[1]) +if len(args) == 0: + snip.rv += "\n"` + } +} +endsnippet + +snippet clc "class and constructor" b +public class `!p +snip.rv = snip.basename or "untitled"` { + + public `!p snip.rv = snip.basename or "untitled"`($2) { + $0 + } +} +endsnippet + +snippet cl "class" b +public class ${1:`!p +snip.rv = snip.basename or "untitled"`} { + $0 +} +endsnippet + +snippet cos "constant string" b +public static final String ${1:var} = "$2";$0 +endsnippet + +snippet co "constant" b +public static final ${1:String} ${2:var} = $3;$0 +endsnippet + +snippet de "default" b +default: + $0 +endsnippet + +snippet elif "else if" +else if ($1)`!p nl(snip)`{ + $0${VISUAL} +} +endsnippet + +snippet el "else" w +else`!p nl(snip)`{ + $0${VISUAL} +} +endsnippet + +snippet fi "final" b +final $0 +endsnippet + +snippet fore "for (each)" b +for ($1 : $2)`!p nl(snip)`{ + $0 +} +endsnippet + +snippet fori "for" b +for (int ${1:i} = 0; $1 < ${2:10}; $1++)`!p nl(snip)`{ + $0 +} +endsnippet + +snippet for "for" b +for ($1; $2; $3)`!p nl(snip)`{ + $0 +} +endsnippet + +snippet if "if" b +if ($1)`!p nl(snip)`{ + $0${VISUAL} +} +endsnippet + +snippet imt "import junit_framework_TestCase;" b +import junit.framework.TestCase; +$0 +endsnippet + +snippet im "import" b +import ${1:java}.${2:util}.$0; +endsnippet + +snippet in "interface" b +interface ${1:`!p snip.rv = snip.basename or "untitled"`} ${2:extends ${3:Parent} }{ + $0 +} +endsnippet + +snippet cc "constructor call or setter body" +this.${1:var} = $1; +endsnippet + +snippet list "Collections List" b +List<${1:String}> ${2:list} = new ${3:Array}List<$1>(); +endsnippet + +snippet map "Collections Map" b +Map<${1:String}, ${2:String}> ${3:map} = new ${4:Hash}Map<$1, $2>(); +endsnippet + +snippet set "Collections Set" b +Set<${1:String}> ${2:set} = new ${3:Hash}Set<$1>(); +endsnippet + +snippet /Str?|str/ "String" br +String $0 +endsnippet + +snippet cn "Constructor" b +public `!p snip.rv = snip.basename or "untitled"`(${1:}) { + $0 +} +endsnippet + +snippet cn "constructor, \w fields + assigments" b + `!p +args = getArgs(t[1]) +for i in args: + snip.rv += "\n\tprivate " + i[0] + " " + i[1]+ ";" +if len(args) > 0: + snip.rv += "\n"` +public `!p snip.rv = snip.basename or "unknown"`($1) {`!p +args = getArgs(t[1]) +for i in args: + snip.rv += "\n\t\tthis.%s = %s;" % (i[1], i[1]) +if len(args) == 0: + snip.rv += "\n"` +} +endsnippet + +snippet j.b "java_beans_" i +java.beans. +endsnippet + +snippet j.i "java_io" i +java.io. +endsnippet + +snippet j.m "java_math" i +java.math. +endsnippet + +snippet j.n "java_net_" i +java.net. +endsnippet + +snippet j.u "java_util_" i +java.util. +endsnippet + +snippet main "method (main)" b +public static void main(String[] args)`!p nl(snip)`{ + $0 +} +endsnippet + +snippet try "try/catch" b +try { + $1${VISUAL} +} catch(${2:Exception} ${3:e}){ + ${4:e.printStackTrace();} +} +endsnippet + +snippet mt "method throws" b +${1:private} ${2:void} ${3:method}(${4}) ${5:throws $6 }{ + $0 +} +endsnippet + +snippet m "method" b +${1:private} ${2:void} ${3:method}(${4}) { + $0 +} +endsnippet + +snippet md "Method With javadoc" b +/** + * ${7:Short Description}`!p +for i in getArgs(t[4]): + snip.rv += "\n\t * @param " + i[1] + " usage..."` + *`!p +if "throws" in t[5]: + snip.rv = "\n\t * @throws " + t[6] +else: + snip.rv = ""``!p +if not "void" in t[2]: + snip.rv = "\n\t * @return object" +else: + snip.rv = ""` + **/ +${1:public} ${2:void} ${3:method}($4) ${5:throws $6 }{ + $0 +} +endsnippet + +snippet /get(ter)?/ "getter" br +public ${1:String} get${2:Name}() { + return `!p snip.rv = mixedCase(t[2])`; +} +endsnippet + +snippet /set(ter)?/ "setter" br +public void set${1:Name}(${2:String} `!p snip.rv = mixedCase(t[1])`) { + this.`!p snip.rv = mixedCase(t[1])` = `!p snip.rv = mixedCase(t[1])`; +} +endsnippet + +snippet /se?tge?t|ge?tse?t|gs/ "setter and getter" br +public void set${1:Name}(${2:String} `!p snip.rv = mixedCase(t[1])`) { + this.`!p snip.rv = mixedCase(t[1])` = `!p snip.rv = mixedCase(t[1])`; +}`!p snip.rv += "\n"` +public $2 get$1() { + return `!p snip.rv = mixedCase(t[1])`; +} +endsnippet + +snippet pa "package" b +package $0 +endsnippet + +snippet p "print" b +System.out.print($1);$0 +endsnippet + +snippet pl "println" b +System.out.println($1);$0 +endsnippet + +snippet pr "private" b +private $0 +endsnippet + +snippet po "protected" b +protected $0 +endsnippet + +snippet pu "public" b +public $0 +endsnippet + +snippet re "return" b +return $0 +endsnippet + +snippet st "static" +static $0 +endsnippet + +snippet sw "switch" b +switch ($1)`!p nl(snip)`{ + case $2: $0 +} +endsnippet + +snippet sy "synchronized" +synchronized $0 +endsnippet + +snippet tc "test case" +public class ${1:`!p snip.rv = snip.basename or "untitled"`} extends ${2:TestCase}`!p nl(snip)`{ + $0 +} +endsnippet + +snippet t "test" b +`!p junit(snip)`public void test${1:Name}() { + $0 +} +endsnippet + +snippet tt "test throws" b +`!p junit(snip)`public void test${1:Name}() ${2:throws Exception }{ + $0 +} +endsnippet + +snippet th "throw" b +throw new $0 +endsnippet + +snippet wh "while" b +while ($1)`!p nl(snip)`{ + $0 +} +endsnippet + +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/javascript-angular.snippets b/vim/bundle/vim-snippets/UltiSnips/javascript-angular.snippets new file mode 100644 index 0000000..91b5931 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/javascript-angular.snippets @@ -0,0 +1,77 @@ +priority -50 + +snippet iti "it (js, inject)" b +it('${1:description}', inject(function($2) { + $0 +})); +endsnippet + +snippet befi "before each (js, inject)" b +beforeEach(inject(function($1) { + $0 +})); +endsnippet + +snippet aconf "angular config" i +config(function($1) { + $0 +}); +endsnippet + +snippet acont "angular controller" i +controller('${1:name}', [${2}function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) { + $0 +}]); +endsnippet + +snippet aconts "angular controller with scope" i +controller('${1:name}', [${2:'$scope', }function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) { + $0 +}]); +endsnippet + +snippet adir "angular directive" i +directive('${1}', [${2}function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) { + return { + restrict: '${3:EA}', + link: function(scope, element, attrs) { + ${0} + } + }; +}]); +endsnippet + +snippet adirs "angular directive with scope" i +directive('${1}', [${2:'$scope', }function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) { + return { + restrict: '${3:EA}', + link: function(scope, element, attrs) { + ${0} + } + }; +}]); +endsnippet + +snippet afact "angular factory" i +factory('${1:name}', [${2}function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) { + $0 +}]); +endsnippet + +snippet afacts "angular factory with scope" i +factory('${1:name}', [${2:'$scope', }function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) { + $0 +}]); +endsnippet + +snippet aserv "angular service" i +service('${1:name}', [${2}function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) { + $0 +}]); +endsnippet + +snippet aservs "angular service" i +service('${1:name}', [${2:'$scope', }function(${2/('|")([A-Z_$]+)?\1?((, ?)$)?/$2(?3::$4)/ig}) { + $0 +}]); +endsnippet diff --git a/vim/bundle/vim-snippets/UltiSnips/javascript-ember.snippets b/vim/bundle/vim-snippets/UltiSnips/javascript-ember.snippets new file mode 100644 index 0000000..1b7e7b8 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/javascript-ember.snippets @@ -0,0 +1,90 @@ +################################################################### +# Ember snippets # +################################################################### + +priority -50 + +# Application +snippet eapp "App.Name = Ember.Application.create({});" +${1:App.Name} = Ember.Application.create({}); +endsnippet + +# Models +snippet emod "App.ModelName = Ember.Model.extend({...});" +${1:model_name} = Ember.Model.extend({ + ${0://Properties here...} +}); +endsnippet + +# View +snippet eview "App.ViewName = Ember.Model.extend({...});" +${1:view_name} = Ember.View.extend({ + ${0://Properties here...} +}); +endsnippet + +# Controller +snippet econtroller "App.ControllerName = Ember.Model.extend({...});" +${1:controller_name} = Ember.ObjectController.extend({ + ${0://Properties here...} +}); +endsnippet + +# Route +snippet eroute "App.RouteName = Ember.Route.extend({...});" +${1:route_name} = Ember.Route.extend({ + ${0://Properties here...} +}); +endsnippet + +snippet eview "App.ViewName = Ember.Model.create({...});" +${1:view_name} = Ember.View.create({ + ${0://Properties here...} +}); +endsnippet + +# Object +snippet eobj "App.ObjectName = Ember.Object.extend({...});" +${1:object_name} = Ember.Object.create({ + ${0://Properties here...} +}); +endsnippet + +# Mixin +snippet emix "App.MixinName = Ember.Model.extend({...});" +${1:view_name} = Ember.Mixin.create({ + ${0://Properties here...} +}); +endsnippet + +# Ember getter and setter +snippet eget "this.get('property');" +${1:this}.get('${2:property}'); +endsnippet + +snippet eset "this.set('property', value);" +${1:this}.set('${2:property}', ${3:value}); +endsnippet + +# Computer properties +snippet cpro "property_name: function() {...}.property()," +${1:property_name}: function() { + ${0://body...} +}.property('${3:argumenet}'), +endsnippet + +snippet cpro ": function() {...}.property('property')," +${1:property_name}: function() { + ${0://body...} +}.property(), +endsnippet + + +# Observes +snippet proo "property_name: function() {...}.property()" +${1:property_name}: function() { + ${0://body...} +}.observes('${3:property}'), +endsnippet + +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/javascript-jasmine.snippets b/vim/bundle/vim-snippets/UltiSnips/javascript-jasmine.snippets new file mode 100644 index 0000000..77aec77 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/javascript-jasmine.snippets @@ -0,0 +1,218 @@ +priority -50 + +# JavaScript versions -- from the TextMate bundle + some additions +# for jasmine-jquery matchers +# + +snippet des "Describe (js)" b +describe('${1:description}', function() { + $0 +}); +endsnippet + +snippet it "it (js)" b +it('${1:description}', function() { + $0 +}); +endsnippet + +snippet bef "before each (js)" b +beforeEach(function() { + $0 +}); +endsnippet + +snippet aft "after each (js)" b +afterEach(function() { + $0 +}); +endsnippet + +snippet befa "before all (js)" b +beforeAll(function() { + $0 +}); +endsnippet + +snippet afta "after all (js)" b +afterAll(function() { + $0 +}); +endsnippet + +snippet any "any (js)" b +jasmine.any($1) +endsnippet + +snippet anyt "anything (js)" b +jasmine.anything() +endsnippet + +snippet objc "object containing (js)" b +jasmine.objectContaining({ + ${VISUAL}$0 +}); +endsnippet + +snippet arrc "array containing (js)" b +jasmine.arrayContaining([${1:value1}]); +endsnippet + +snippet strm "string matching (js)" b +jasmine.stringMatching("${1:matcher}") +endsnippet + +snippet ru "runs (js)" b +runs(function() { + $0 +}); +endsnippet + +snippet wa "waits (js)" b +waits($1); +endsnippet + +snippet ex "expect (js)" b +expect(${1:target})$0; +endsnippet + +snippet ee "expect to equal (js)" b +expect(${1:target}).toEqual(${2:value}); +endsnippet + +snippet el "expect to be less than (js)" b +expect(${1:target}).toBeLessThan(${2:value}); +endsnippet + +snippet eg "expect to be greater than (js)" b +expect(${1:target}).toBeGreaterThan(${2:value}); +endsnippet + +snippet eb "expect to be (js)" b +expect(${1:target}).toBe(${2:value}); +endsnippet + +snippet em "expect to match (js)" b +expect(${1:target}).toMatch(${2:pattern}); +endsnippet + +snippet eha "expect to have attribute (js)" b +expect(${1:target}).toHaveAttr('${2:attr}'${3:, '${4:value}'}); +endsnippet + +snippet et "expect to be truthy (js)" b +expect(${1:target}).toBeTruthy(); +endsnippet + +snippet ef "expect to be falsy (js)" b +expect(${1:target}).toBeFalsy(); +endsnippet + +snippet ed "expect to be defined (js)" b +expect(${1:target}).toBeDefined(); +endsnippet + +snippet eud "expect to be defined (js)" b +expect(${1:target}).toBeUndefined(); +endsnippet + +snippet en "expect to be null (js)" b +expect(${1:target}).toBeNull(); +endsnippet + +snippet ec "expect to contain (js)" b +expect(${1:target}).toContain(${2:value}); +endsnippet + +snippet ev "expect to be visible (js)" b +expect(${1:target}).toBeVisible(); +endsnippet + +snippet eh "expect to be hidden (js)" b +expect(${1:target}).toBeHidden(); +endsnippet + +snippet notx "expect not (js)" b +expect(${1:target}).not$0; +endsnippet + +snippet note "expect not to equal (js)" b +expect(${1:target}).not.toEqual(${2:value}); +endsnippet + +snippet notl "expect to not be less than (js)" b +expect(${1:target}).not.toBeLessThan(${2:value}); +endsnippet + +snippet notg "expect to not be greater than (js)" b +expect(${1:target})..not.toBeGreaterThan(${2:value}); +endsnippet + +snippet notm "expect not to match (js)" b +expect(${1:target}).not.toMatch(${2:pattern}); +endsnippet + +snippet notha "expect to not have attribute (js)" b +expect(${1:target}).not.toHaveAttr('${2:attr}'${3:, '${4:value}'}); +endsnippet + +snippet nott "expect not to be truthy (js)" b +expect(${1:target}).not.toBeTruthy(); +endsnippet + +snippet notf "expect not to be falsy (js)" b +expect(${1:target}).not.toBeFalsy(); +endsnippet + +snippet notd "expect not to be defined (js)" b +expect(${1:target}).not.toBeDefined(); +endsnippet + +snippet notn "expect not to be null (js)" b +expect(${1:target}).not.toBeNull(); +endsnippet + +snippet notc "expect not to contain (js)" b +expect(${1:target}).not.toContain(${2:value}); +endsnippet + +snippet notv "expect not to be visible (js)" b +expect(${1:target}).not.toBeVisible(); +endsnippet + +snippet noth "expect not to be hidden (js)" b +expect(${1:target}).not.toBeHidden(); +endsnippet + +snippet s "spy on (js)" b +spyOn(${1:object}, '${2:method}')$0; +endsnippet + +snippet sr "spy on and return (js)" b +spyOn(${1:object}, '${2:method}').and.returnValue(${3:arguments}); +endsnippet + +snippet st "spy on and throw (js)" b +spyOn(${1:object}, '${2:method}').and.throwError(${3:exception}); +endsnippet + +snippet sct "spy on and call through (js)" b +spyOn(${1:object}, '${2:method}').and.callThrough(); +endsnippet + +snippet scf "spy on and call fake (js)" b +spyOn(${1:object}, '${2:method}').and.callFake(${3:function}); +endsnippet + +snippet ethbc "expect to have been called (js)" b +expect(${1:target}).toHaveBeenCalled(); +endsnippet + +snippet nthbc "expect not to have been called (js)" b +expect(${1:target}).not.toHaveBeenCalled(); +endsnippet + +snippet ethbcw "expect to have been called with (js)" b +expect(${1:target}).toHaveBeenCalledWith(${2:arguments}); +endsnippet + diff --git a/vim/bundle/vim-snippets/UltiSnips/javascript-jsdoc.snippets b/vim/bundle/vim-snippets/UltiSnips/javascript-jsdoc.snippets new file mode 100644 index 0000000..959f805 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/javascript-jsdoc.snippets @@ -0,0 +1,51 @@ +priority -50 + +# JSDoc snippets + +snippet /* "A JSDoc comment" b +/** + * ${1:${VISUAL}}$0 + */ +endsnippet + +snippet @au "@author email (First Last)" +@author ${1:`!v g:snips_author`} [${2:`!v g:snips_author_email`}] +endsnippet + +snippet @li "@license Description" +@license ${1:MIT}$0 +endsnippet + +snippet @ver "@version Semantic version" +@version ${1:0.1.0}$0 +endsnippet + +snippet @fileo "@fileoverview Description" b +/** + * @fileoverview ${1:${VISUAL:A description of the file}}$0 + */ +endsnippet + +snippet @constr "@constructor" +@constructor +endsnippet + +snippet @p "@param {Type} varname Description" +@param {${1:Type}} ${2:varname} ${3:Description} +endsnippet + +snippet @ret "@return {Type} Description" +@return {${1:Type}} ${2:Description} +endsnippet + +snippet @pri "@private" +@private +endsnippet + +snippet @over "@override" +@override +endsnippet + +snippet @pro "@protected" +@protected +endsnippet diff --git a/vim/bundle/vim-snippets/UltiSnips/javascript-node.snippets b/vim/bundle/vim-snippets/UltiSnips/javascript-node.snippets new file mode 100644 index 0000000..7a14dee --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/javascript-node.snippets @@ -0,0 +1,65 @@ +priority -50 + +snippet #! "shebang" +#!/usr/bin/env node +endsnippet + +snippet vreq "assign a CommonJS-style module to a var" +var ${0:${1/(.+\/)*(\w+)(-|\b|$)(\..+$)?/\u$2/g}} = require('${1}'); +endsnippet + +snippet ex "module.exports" +module.exports = ${1}; +endsnippet + +snippet hcs "http.createServer" +http.createServer(${1}).listen(${2}); +endsnippet + +snippet ncs "net.createServer" +net.createServer(function(${1:socket}){ + ${1}.on('data', function(${3:data}){ + ${4} + }); + ${1}.on('end', function(){ + ${5} + }); +}).listen(${6:8124}); +endsnippet + +snippet pipe "pipe" +pipe(${1:stream})${2} +endsnippet + +# Express snippets + +snippet eget "express GET" +${1:app}.get('${2}', ${3}); +endsnippet + +snippet epost "express POST" +${1:app}.post('${2}', ${3}); +endsnippet + +snippet eput "express PUT" +${1:app}.put('${2}', ${3}); +endsnippet + +snippet edelete "express DELETE" +${1:app}.delete('${2}', ${3}); +endsnippet + +# process snippets + +snippet stdout "stdout" +process.stdout +endsnippet + +snippet stdin "stdin" +process.stdin +endsnippet + +snippet stderr "stderr" +process.stderr +endsnippet + diff --git a/vim/bundle/vim-snippets/UltiSnips/javascript-openui5.snippets b/vim/bundle/vim-snippets/UltiSnips/javascript-openui5.snippets new file mode 100644 index 0000000..5553c79 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/javascript-openui5.snippets @@ -0,0 +1,205 @@ +snippet sapmlabel + var ${1} = new sap.m.Label({ + design : ${2}, + text : ${3}, + visible : ${4}, + textAlign : ${5}, + textDirection : ${6}, + width : ${7}, + required : ${7} + }); + +snippet sapmtext + var ${1} = new sap.m.Text({ + text :${2}, + textDirection :${3}, + visible :${4}, + wrapping : ${5}, + textAlign : ${6}, + width :${7}, + maxLines :${8} + }); + +snippet sapmbutton + var ${1} = new sap.m.Button({ + text : ${2}, + type : ${3}, + width : ${4}, + enabled :${5}, + visible :${6}, + icon : ${7}, + iconFirst : ${8}, + activeIcon :${9}, + iconDensityAware : ${10}, + }); +snippet sapmflexbox + var ${1} = new sap.m.FlexBox({ + visible : ${2}, + height : ${3}, + width : ${4}, + displayInline :${5}, + direction :${6}, + fitContainer : ${7}, + renderType : ${8}, + justifyContent :${9}, + alignItems : ${10}, + items:[] + }); +snippet sapmhbox + var ${1} = new sap.m.HBox({ + visible : ${2}, + height : ${3}, + width : ${4}, + displayInline :${5}, + direction :${6}, + fitContainer : ${7}, + renderType : ${8}, + justifyContent :${9}, + alignItems : ${10}, + items:[] + }); + +snippet sapmvbox + var ${1} = new sap.m.VBox({ + visible : ${2}, + height : ${3}, + width : ${4}, + displayInline :${5}, + direction :${6}, + fitContainer : ${7}, + renderType : ${8}, + justifyContent :${9}, + alignItems : ${10}, + items:[] + }); + +snippet sapcomponent + sap.ui.controller("${1}", { + onInit: function(){ + }, + onAfterRendering: function() { + }, + onAfterRendering: function() { + }, + onExit: function() { + }, + }); + +snippet sapminput + var ${1} = new sap.m.Input({ + value :${2}, + width : ${3}, + enabled :${4}, + visible :${5}, + valueState :${6}, + name : ${7}, + placeholder : ${8}, + editable : ${9}, + type : ${10}, + maxLength :${11}, + valueStateText :${12}, + showValueStateMessage :${13}, + dateFormat :${14}, + showValueHelp :${15}, + showSuggestion :${16}, + valueHelpOnly :${17}, + filterSuggests :${18}, + maxSuggestionWidth :${19}, + startSuggestion : ${20}, + showTableSuggestionValueHelp : ${21}, + description : ${22}, + fieldWidth : ${23}, + valueLiveUpdate :${24}, + suggestionItems :[${25}], + suggestionColumns : [${26}], + suggestionRows : [${27}], + liveChange : ${28}, + valueHelpRequest :${29}, + suggest : ${30}, + suggestionItemSelected : ${31} + }); +snippet _sthis + var _self = this; + +snippet sapmresponsivepopup + var ${1} = new sap.m.ResponsivePopover({ + placement :${2} ,//sap.m.PlacementType (default: sap.m.PlacementType.Right) + showHeader :${3} ,//boolean (default: true) + title : ${4},//string + icon :${5} ,//sap.ui.core.URI + modal :${6} ,// boolean + offsetX :${7}, //int + offsetY :${8}, //int + contentWidth : ${9},//sap.ui.core.CSSSize + contentHeight :${10}, //sap.ui.core.CSSSize + horizontalScrolling :${11}, //boolean + verticalScrolling :${12}, //boolean + showCloseButton :${13}, //boolean (default: true) + //Aggregations + content :${14}, //sap.ui.core.Control[] + customHeader :${15}, //sap.m.IBar + subHeader : ${16}, //sap.m.IBar + beginButton :${17}, //sap.m.Button + endButton : ${18}, //sap.m.Button + //Associations + initialFocus : ${19}, //string | sap.ui.core.Control + //Events + beforeOpen :${20}, //fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject] + afterOpen : ${21}, //fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject] + beforeClose : ${22}, //fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject] + afterClose : ${23} //fnList + }); + +snippet sapicon + var ${1} = new sap.ui.core.Icon({ + src :${2} , //sap.ui.core.URI + size :${3} , //sap.ui.core.CSSSize + color :${4} , //sap.ui.core.CSSColor + hoverColor : ${5} , // sap.ui.core.CSSColor + activeColor :${6} , //sap.ui.core.CSSColor + width :${7} , //sap.ui.core.CSSSize + height : ${8} ,//sap.ui.core.CSSSize + backgroundColor :${8} , //sap.ui.core.CSSColor + hoverBackgroundColor :${9} , //sap.ui.core.CSSColor + activeBackgroundColor :${10} , //sap.ui.core.CSSColor + visible :${11} , //boolean (default: true) + decorative : ${12} ,//boolean (default: true) + }); +snippet extendVerticalL + sap.ui.layout.VerticalLayout.extend("${1}", { + metadata: { + properties: { + ${2} + }, + aggregations: { + ${3} + }, + events: { + ${4} + } + }, + init: function(){ + ${5} + }, + + renderer: "${6}" + }); +snippet extendHorizontalL + sap.ui.layout.HorizontalLayout.extend("${1}", { + metadata: { + properties: { + ${2} + }, + aggregations: { + ${3} + }, + events: { + ${4} + } + }, + init: function(){ + ${5} + }, + + renderer: "${6}" + }); diff --git a/vim/bundle/vim-snippets/UltiSnips/javascript.snippets b/vim/bundle/vim-snippets/UltiSnips/javascript.snippets new file mode 100644 index 0000000..4537bae --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/javascript.snippets @@ -0,0 +1,171 @@ +priority -50 + +########################################################################### +# TextMate Snippets # +########################################################################### +snippet get "Get Elements" +getElement${1/(T)|.*/(?1:s)/}By${1:T}${1/(T)|(I)|.*/(?1:agName)(?2:d)/}('$2') +endsnippet + +snippet '':f "object method string" +'${1:${2:#thing}:${3:click}}': function(element) { + ${VISUAL}$0 +}${10:,} +endsnippet + +snippet :f "Object Method" +${1:method_name}: function(${3:attribute}) { + ${VISUAL}$0 +}${10:,} +endsnippet + +snippet :, "Object Value JS" +${1:value_name}: ${0:value}, +endsnippet + +snippet : "Object key key: 'value'" +${1:key}: ${2:"${3:value}"}${4:, } +endsnippet + +snippet proto "Prototype (proto)" +${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) { + ${VISUAL}$0 +}; + +endsnippet + +snippet for "for (...) {...} (counting up)" b +for (var ${1:i} = 0, ${2:len} = ${3:Things.length}; $1 < $2; $1++) { + ${VISUAL}$0 +} +endsnippet + +snippet ford "for (...) {...} (counting down, faster)" b +for (var ${2:i} = ${1:Things.length} - 1; $2 >= 0; $2--) { + ${VISUAL}$0 +} +endsnippet + +snippet fun "function (fun)" +function ${1:function_name}(${2:argument}) { + ${VISUAL}$0 +} +endsnippet + +snippet vf "Function assigned to var" +${1:var }${2:function_name} = function $2(${3}) { + ${VISUAL}$0 +}; +endsnippet + +snippet af "Anonymous Function" i +function($1) { + ${VISUAL}$0 +} +endsnippet + +snippet iife "Immediately-Invoked Function Expression (iife)" +(function(${1:window}) { + ${VISUAL}$0 +}(${2:$1})); +endsnippet + +snippet timeout "setTimeout function" +setTimeout(function() { + ${VISUAL}$0 +}${2:.bind(${3:this})}, ${1:10}); +endsnippet + +snippet fi "for prop in obj using hasOwnProperty" b +for (${1:prop} in ${2:obj}){ + if ($2.hasOwnProperty($1)) { + ${VISUAL}$0 + } +} +endsnippet + +# Snippets for Console Debug Output + +snippet ca "console.assert" b +console.assert(${1:assertion}, ${2:"${3:message}"}); +endsnippet + +snippet cclear "console.clear" b +console.clear(); +endsnippet + +snippet cdir "console.dir" b +console.dir(${1:object}); +endsnippet + +snippet cdirx "console.dirxml" b +console.dirxml(${1:object}); +endsnippet + +snippet ce "console.error" b +console.error(${1:"${2:value}"}); +endsnippet + +snippet cgroup "console.group" b +console.group("${1:label}"); +${VISUAL}$0 +console.groupEnd(); +endsnippet + +snippet cgroupc "console.groupCollapsed" b +console.groupCollapsed("${1:label}"); +${VISUAL}$0 +console.groupEnd(); +endsnippet + +snippet ci "console.info" b +console.info(${1:"${2:value}"}); +endsnippet + +snippet cl "console.log" b +console.log(${1:"${2:value}"}); +endsnippet + +snippet cd "console.debug" b +console.debug(${1:"${2:value}"}); +endsnippet + +snippet cprof "console.profile" b +console.profile("${1:label}"); +${VISUAL}$0 +console.profileEnd(); +endsnippet + +snippet ctable "console.table" b +console.table(${1:"${2:value}"}); +endsnippet + +snippet ctime "console.time" b +console.time("${1:label}"); +${VISUAL}$0 +console.timeEnd("$1"); +endsnippet + +snippet ctimestamp "console.timeStamp" b +console.timeStamp("${1:label}"); +endsnippet + +snippet ctrace "console.trace" b +console.trace(); +endsnippet + +snippet cw "console.warn" b +console.warn(${1:"${2:value}"}); +endsnippet + +# AMD (Asynchronous Module Definition) snippets + +snippet def "define an AMD module" +define(${1:optional_name, }[${2:'jquery'}], ${3:callback}); +endsnippet + +snippet req "require an AMD module" +require([${1:'dependencies'}], ${2:callback}); +endsnippet + +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/jinja2.snippets b/vim/bundle/vim-snippets/UltiSnips/jinja2.snippets new file mode 100644 index 0000000..ded01dc --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/jinja2.snippets @@ -0,0 +1,209 @@ +priority -50 + +# http://jinja.pocoo.org/ + +# jinja2 is a full featured template engine for Python. It has full +# unicode support, an optional integrated sandboxed execution +# environment, widely used and BSD licensed. + +# possible extends: +#extends html + + +snippet block "block" b +{% block ${1:name} %} + $2 +{% endblock $1 %} +endsnippet + + +snippet {{ "variable" b +{{ $1 }} +endsnippet + + +snippet {# "comment" b +{# $1 #} +endsnippet + + +snippet # "comment" b +{# $1 #} +endsnippet + + +snippet raw "escaped block" b +{% raw %} + $1 +{% endraw %} +endsnippet + + +snippet extends "extends" b +{% extends "${1:template}" %} +endsnippet + + +snippet include "include" b +{% include "${1:template}" %} +endsnippet + + +snippet import "import" b +{% import "${1:template}" %} +endsnippet + + +snippet from "from/import/as" b +{% from "${1:template}" import ${2:name}${3: as ${4:$2}} %} +endsnippet + + +snippet filter "filter" b +{% filter ${1:filter} %} + $2 +{% endfilter %} +endsnippet + + +# Being able to quickly remove the whole 'else' block seems faster to me than +# choosing between 'for' and 'for/else' snippets from the menu. +# snippet for "for" b +# {% for ${1:item} in ${2:sequence} %} +# $3${4: +# {% else %} +# $5} +# {% endfor %} +# endsnippet + + +snippet for "for" b +{% for ${1:item} in ${2:sequence} %} + $3 +{% endfor %} +endsnippet + + +snippet for "for/else" b +{% for ${1:item} in ${2:sequence} %} + $3 +{% else %} + $4 +{% endfor %} +endsnippet + + +snippet if "if" b +{% if ${1:expr} %} + $2 +{% endif %} +endsnippet + + +snippet if "if/else" b +{% if ${1:expr} %} + $2 +{% else %} + $3 +{% endif %} +endsnippet + + +snippet if "if/elif/else" b +{% if ${1:expr} %} + $2 +{% elif %} + $3 +{% else %} + $4 +{% endif %} +endsnippet + + +snippet macro "macro" b +{% macro ${1:name}(${2:args}) %} + $3 +{% endmacro %} +endsnippet + + +snippet call "call" b +{% call ${1:name}(${2:args}) %} + $3 +{% endcall %} +endsnippet + + +snippet set "set" b +{% set ${1:name} = ${2:'value'} %} +endsnippet + + +snippet trans "translation" b +{% trans %} + $1 +{% endtrans %} +endsnippet + + +snippet with "with" b +{% with %} + $1 +{% endwith %} +endsnippet + +snippet autoescape "autoescape" b +{% autoescape ${1:true} %} + $2 +{% endautoescape %} +endsnippet + +# Filters +# @todo: expand only when snippet is preceeded by a | + +snippet batch "batch items" w +batch(linecount=$1, fill_with=${2:None}) +endsnippet + + +snippet dictsort "sort and yield (key, value) pairs" w +dictsort(case_sensitive=${1:False}, by=${2:'key'}) +endsnippet + + +snippet round "round number" w +round(precision=${1:0}, method=${2:'common|ceil|floor'}) +endsnippet + + +snippet urlize "convert plain-text url to <a/>" w +urlize(trim_url_limit=${1:None}, nofollow=${2:False}) +endsnippet + + +snippet wordwrap "wordwrap" w +wordwrap(width=${1:79}, break_long_words=${2:True}) +endsnippet + + +snippet truncate "truncate" w +truncate(lenght=${1:79}, killwords=${2:False}, end=${3:'...''}) +endsnippet + + +snippet sum "sum of sequence of numbers + start" w +sum(attribute=${1:None}, start=${2:0}) +endsnippet + + +snippet sort "sort an iterable" w +sort(reverse=${1:False}, case_sensitive=${2:False}, attribute=${3:None}) +endsnippet + + +snippet indent "indent" w +indent(width=${1:4}, indentfirst=${2:False}) +endsnippet + + +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/json.snippets b/vim/bundle/vim-snippets/UltiSnips/json.snippets new file mode 100644 index 0000000..75edef9 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/json.snippets @@ -0,0 +1,51 @@ +priority -50 + +snippet s "String" b +"${1:key}": "${0:value}", +endsnippet + +snippet n "Number" b +"${1:key}": ${0:value}, +endsnippet + +snippet a "Array" b +[ + ${VISUAL}$0 +], +endsnippet + +snippet na "Named array" b +"${1:key}": [ + ${VISUAL}$0 +], +endsnippet + +snippet o "Object" b +{ + ${VISUAL}$0 +}, +endsnippet + +snippet no "Named object" b +"${1:key}": { + ${VISUAL}$0 +}, +endsnippet + +snippet null "Null" b +"${0:key}": null, +endsnippet + + +global !p +def compB(t, opts): + if t: + opts = [m[len(t):] for m in opts if m.startswith(t)] + if len(opts) == 1: + return opts[0] + return "(" + '|'.join(opts) + ')' +endglobal + +snippet b "Bool" b +"${1:key}": $2`!p snip.rv=compB(t[2], ['true', 'false'])`, +endsnippet diff --git a/vim/bundle/vim-snippets/UltiSnips/julia.snippets b/vim/bundle/vim-snippets/UltiSnips/julia.snippets new file mode 100644 index 0000000..259c5f4 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/julia.snippets @@ -0,0 +1,34 @@ +# Documentation +snippet docf "function documentation" b +#' @description +#' +#' ${1:function description} +#' +#' ${2:@param ${3:name}::${4:Type} ${5:Description}} +#' +#' ${6:@returns ${7:name}::${8:Type} ${9:Description}} +#' +#' @examples +#' +#' ${10: function call examples} +endsnippet + +snippet doct "type definition" b +#' @description +#' +#' ${1:type description} +#' +#' ${2:@field ${3:name}::${4:Type} ${5:Description}} +#' +#' @examples +#' +#' ${10: constructor examples} +endsnippet + +snippet par "function parameter documentation" b +#' @param ${1:name}::${2:Type} ${0:Description} +endsnippet + +snippet fld "type field documentation" b +#' @field ${1:name}::${2:Type} ${0:Description} +endsnippet diff --git a/vim/bundle/vim-snippets/UltiSnips/ledger.snippets b/vim/bundle/vim-snippets/UltiSnips/ledger.snippets new file mode 100644 index 0000000..7d7a84d --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/ledger.snippets @@ -0,0 +1,7 @@ +priority -50 + +snippet t "Transaction" b +${1:`!v strftime("%Y")`}-${2:`!v strftime("%m")`}-${3:`!v strftime("%d")`} ${4:*} ${5:Payee} + ${6:Expenses} \$${7:0.00} + ${8:Assets:Checking}$0 +endsnippet diff --git a/vim/bundle/vim-snippets/UltiSnips/lhaskell.snippets b/vim/bundle/vim-snippets/UltiSnips/lhaskell.snippets new file mode 100644 index 0000000..29169a5 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/lhaskell.snippets @@ -0,0 +1,3 @@ +priority -50 + +extends haskell diff --git a/vim/bundle/vim-snippets/UltiSnips/lua.snippets b/vim/bundle/vim-snippets/UltiSnips/lua.snippets new file mode 100644 index 0000000..b6d0c1a --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/lua.snippets @@ -0,0 +1,98 @@ +priority -50 + +################################# +# Snippets for the Lua language # +################################# +snippet #! "Shebang header" b +#!/usr/bin/env lua +$0 +endsnippet + +snippet !fun(ction)?! "New function" br +function ${1:new_function}(${2:args}) + $0 +end +endsnippet + +snippet forp "pair for loop" b +for ${1:name},${2:val} in pairs(${3:table_name}) do + $0 +end +endsnippet + +snippet fori "ipair for foop" b +for ${1:idx},${2:val} in ipairs(${3:table_name}) do + $0 +end +endsnippet + +snippet for "numeric for loop" b +for ${1:i}=${2:first},${3:last}${4/^..*/(?0:,:)/}${4:step} do + $0 +end +endsnippet + +snippet do "do block" +do + $0 +end +endsnippet + +snippet repeat "repeat loop" b +repeat + $1 +until $0 +endsnippet + +snippet while "while loop" b +while $1 do + $0 +end +endsnippet + +snippet if "if statement" b +if $1 then + $0 +end +endsnippet + +snippet ife "if/else statement" b +if $1 then + $2 +else + $0 +end +endsnippet + +snippet eif "if/elseif statement" b +if $1 then + $2 +elseif $3 then + $0 +end +endsnippet + +snippet eife "if/elseif/else statement" b +if $1 then + $2 +elseif $3 then + $4 +else + $0 +end +endsnippet + +snippet pcall "pcall statement" b +local ok, err = pcall(${1:your_function}) +if not ok then + handler(${2:ok, err}) +${3:else + success(${4:ok, err}) +}end +endsnippet + +snippet local "local x = 1" +local ${1:x} = ${0:1} +endsnippet + +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/mako.snippets b/vim/bundle/vim-snippets/UltiSnips/mako.snippets new file mode 100644 index 0000000..fb31ec8 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/mako.snippets @@ -0,0 +1,92 @@ +priority -50 + +################# +# From snipmate # +################# +snippet def "definition" b +<%def name="${1:name}"> + ${2:} +</%def> +endsnippet + +snippet call "call" b +<%call expr="${1:name}"> + ${2:} +</%call> +endsnippet + +snippet doc "doc" b +<%doc> + ${1:} +</%doc> +endsnippet + +snippet text "text" b +<%text> + ${1:} +</%text> +endsnippet + +snippet for "for" b +% for ${1:i} in ${2:iter}: + ${3:} +% endfor +endsnippet + +snippet if "if " b +% if ${1:condition}: + ${2:} +% endif +endsnippet + +snippet if "if/else" b +% if ${1:condition}: + ${2:} +% else: + ${3:} +% endif +endsnippet + +snippet try "try" b +% try: + ${1:} +% except${2:}: + ${3:pass} +% endtry +endsnippet + +snippet wh "wh" b +% while ${1:}: + ${2:} +% endwhile +endsnippet + +snippet $ "$" i +${${1:}} +endsnippet + +snippet <% "<%" b +<% ${1:} %> +endsnippet + +snippet <!% "<!%" b +<!% ${1:} %> +endsnippet + +snippet inherit "inherit" b +<%inherit file="${1:filename}" /> +endsnippet + +snippet include "include" b +<%include file="${1:filename}" /> +endsnippet + +snippet namespace "namespace" b +<%namespace file="${1:name}" /> +endsnippet + +snippet page "page" b +<%page args="${1:}" /> +endsnippet + +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/markdown.snippets b/vim/bundle/vim-snippets/UltiSnips/markdown.snippets new file mode 100644 index 0000000..0720cbf --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/markdown.snippets @@ -0,0 +1,53 @@ +priority -50 + +########################### +# Sections and Paragraphs # +########################### +snippet sec "Section" b +# ${1:Section Name} # +$0 +endsnippet + +snippet ssec "Sub Section" b +## ${1:Section Name} ## +$0 +endsnippet + +snippet sssec "SubSub Section" b +### ${1:Section Name} ### +$0 +endsnippet + +snippet par "Paragraph" b +#### ${1:Paragraph Name} #### +$0 +endsnippet + +snippet spar "Paragraph" b +##### ${1:Paragraph Name} ##### +$0 +endsnippet + +################ +# Common stuff # +################ +snippet link "Link to something" +[${1:${VISUAL:Text}}](${3:http://${2:www.url.com}})$0 +endsnippet + +snippet img "Image" +![${1:pic alt}](${2:path}${3/.+/ "/}${3:opt title}${3/.+/"/})$0 +endsnippet + +snippet ilc "Inline Code" i +\`$1\`$0 +endsnippet + +snippet cbl "Codeblock" b +\`\`\` +$1 +\`\`\` +$0 +endsnippet + +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/objc.snippets b/vim/bundle/vim-snippets/UltiSnips/objc.snippets new file mode 100644 index 0000000..45e41fc --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/objc.snippets @@ -0,0 +1,272 @@ +priority -50 + +########################################################################### +# TextMate Snippets # +########################################################################### + +snippet imp "#import (imp)" b +#import "${1:`!p snip.rv = re.sub(r'\..*$', '.h', fn)`}" +endsnippet + +snippet Imp "#import <> (Imp)" +#import <${1:Cocoa/Cocoa.h}> +endsnippet + +snippet cl "020 Class (objc)" +@interface ${1:`!p +if len(fn): + snip.rv = re.sub(r'\..*$', '', fn) +else: + snip.rv = "object" +`} : ${2:NSObject} +{ +} +@end + +@implementation $1 +- (id)init +{ + if((self = [super init])) + {$0 + } + return self; +} +@end +endsnippet + +snippet array "NSArray (array)" +NSMutableArray *${1:array} = [NSMutableArray array]; +endsnippet + +snippet dict "NSDictionary (dict)" +NSMutableDictionary *${1:dict} = [NSMutableDictionary dictionary]; +endsnippet + +snippet forarray "for NSArray loop (forarray)" +unsigned int ${1:object}Count = [${2:array} count]; + +for(unsigned int index = 0; index < $1Count; index += 1) +{ + ${3:id} $1 = [$2 objectAtIndex:index]; + $0 +} +endsnippet + +snippet objacc "Object Accessors (objacc)" +- (${1:id})${2:thing} +{ + return $2; +} + +- (void)set${2/./\u$0/}:($1)aValue +{ + $0${1/( \*)?$/(?1:$1: )/}old${2/./\u$0/} = $2; + $2 = [aValue retain]; + [old${2/./\u$0/} release]; +} +endsnippet + +snippet sel "@selector" +@selector(${1:method}:) +endsnippet + +snippet cdacc "CoreData Accessors Implementation" +- (${1:id})${2:attribute} +{ + [self willAccessValueForKey:@"$2"]; + $1 value = [self primitiveValueForKey:@"$2"]; + [self didAccessValueForKey:@"$2"]; + return value; +} + +- (void)set${2/./\u$0/}:($1)aValue +{ + [self willChangeValueForKey:@"$2"]; + [self setPrimitiveValue:aValue forKey:@"$2"]; + [self didChangeValueForKey:@"$2"]; +} +endsnippet + +snippet delegate "Delegate Responds to Selector" +if([${1:[self delegate]} respondsToSelector:@selector(${2:selfDidSomething:})]) + [$1 ${3:${2/((^\s*([A-Za-z0-9_]*:)\s*)|(:\s*$)|(:\s*))/(?2:$2self :\:<>)(?4::)(?5: :)/g}}]; + +endsnippet + +snippet thread "Detach New NSThread" +[NSThread detachNewThreadSelector:@selector(${1:method}:) toTarget:${2:aTarget} withObject:${3:anArgument}] +endsnippet + +snippet ibo "IBOutlet (ibo)" +IBOutlet ${1:NSSomeClass} *${2:${1/^[A-Z](?:[A-Z]+|[a-z]+)([A-Z]\w*)/\l$1/}}; +endsnippet + +snippet I "Initialize Implementation (I)" ++ (void)initialize +{ + [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys: + $0@"value", @"key", + nil]]; +} +endsnippet + +snippet bind "Key:value binding (bind)" +bind:@"${1:binding}" toObject:${2:observableController} withKeyPath:@"${3:keyPath}" options:${4:nil} +endsnippet + +snippet arracc "LoD array (arracc)" +- (void)addObjectTo${1:Things}:(${2:id})anObject +{ + [${3:${1/./\l$0/}} addObject:anObject]; +} + +- (void)insertObject:($2)anObject in$1AtIndex:(unsigned int)i +{ + [$3 insertObject:anObject atIndex:i]; +} + +- ($2)objectIn$1AtIndex:(unsigned int)i +{ + return [$3 objectAtIndex:i]; +} + +- (unsigned int)indexOfObjectIn$1:($2)anObject +{ + return [$3 indexOfObject:anObject]; +} + +- (void)removeObjectFrom$1AtIndex:(unsigned int)i +{ + [$3 removeObjectAtIndex:i]; +} + +- (unsigned int)countOf$1 +{ + return [$3 count]; +} + +- (NSArray *${1/./\l$0/} +{ + return $3; +} + +- (void)set$1:(NSArray *)new$1 +{ + [$3 setArray:new$1]; +} +endsnippet + +snippet arracc "LoD array interface (arracc)" +- (void)addObjectTo${1:Things}:(${2:id})anObject; +- (void)insertObject:($2)anObject in$1AtIndex:(unsigned int)i; +- ($2)objectIn$1AtIndex:(unsigned int)i; +- (unsigned int)indexOfObjectIn$1:($2)anObject; +- (void)removeObjectFrom$1AtIndex:(unsigned int)i; +- (unsigned int)countOf$1; +- (NSArray *)${1/./\l$0/}; +- (void)set$1:(NSArray *)new$1; +endsnippet + +snippet focus "Lock Focus" +[self lockFocus]; +$0 +[self unlockFocus]; +endsnippet + +snippet pool "NSAutoreleasePool (pool)" +NSAutoreleasePool *pool = [NSAutoreleasePool new]; +$0 +[pool drain]; +endsnippet + +snippet log "NSLog (log) 2" +NSLog(@"$1"${1/[^%]*(%)?.*/(?1:, :\);)/}$2${1/[^%]*(%)?.*/(?1:\);)/} +endsnippet + +snippet alert "NSRunAlertPanel (alert)" +int choice = NSRunAlertPanel(@"${1:Something important!}", @"${2:Something important just happend, and now I need to ask you, do you want to continue?}", @"${3:Continue}", @"${4:Cancel}", nil); +if(choice == NSAlertDefaultReturn) // "$3" +{ + $0; +} +else if(choice == NSAlertAlternateReturn) // "$4" +{ + $0 +} +endsnippet + +snippet format "NSString stringWithFormat (format)" +[NSString stringWithFormat:@"$1", $2]$0 +endsnippet + +snippet objacc "Object Accessors Interface (objacc)" +- (${1:id})${2:thing}; +- (void)set${2/./\u$0/}:($1)aValue; +endsnippet + +snippet prop "Property" +@property (${1/^(e)$|.*/(?1:r)/}${1:r}${1/^(?:(r)|(e)|(c)|(a))$|.*/(?1:etain)(?2:adonly)(?3:opy)(?4:ssign)/}) ${2:NSSomeClass}$ *${3:${2/^[A-Z](?:[A-Z]+|[a-z]+)([A-Z]\w*)/\l$1/}}; +endsnippet + +snippet getprefs "Read from defaults (getprefs)" +[[NSUserDefaults standardUserDefaults] objectForKey:${1:key}]; +endsnippet + +snippet obs "Register for Notification" +[[NSNotificationCenter defaultCenter] addObserver:${1:self} selector:@selector(${3:${2/^([A-Z]{2})?(.+?)(Notification)?$/\l$2/}}:) name:${2:NSWindowDidBecomeMainNotification} object:${4:nil}]; +endsnippet + +snippet responds "Responds to Selector" +if ([${1:self} respondsToSelector:@selector(${2:someSelector:})]) +{ + [$1 ${3:${2/((:\s*$)|(:\s*))/:<>(?3: )/g}}]; +} +endsnippet + +snippet gsave "Save and Restore Graphics Context (gsave)" +[NSGraphicsContext saveGraphicsState]; +$0 +[NSGraphicsContext restoreGraphicsState]; + +endsnippet + +snippet acc "Scalar Accessors (acc)" +- (${1:unsigned int})${2:thing} +{ + return ${3:$2}; +} + +- (void)set${2/./\u$0/}:(${1:unsigned int})new${2/./\u$0/} +{ + $3 = new${2/./\u$0/}; +} +endsnippet + +snippet acc "Scalar Accessors Interface (acc)" +- (${1:unsigned int})${2:thing}; +- (void)set${2/./\u$0/}:($1)new${2/./\u$0/}; +endsnippet + +snippet stracc "String Accessors (stracc)" +- (NSString *)${1:thing} +{ + return ${2:$1}; +} + +- (void)set${1/.*/\u$0/}:(NSString *)/})${3:a${1/.*/\u$0/}} +{ + $3 = [$3 copy]; + [$2 release]; + $2 = $3; +} +endsnippet + +snippet syn "Synthesize" +@synthesize ${1:property}; +endsnippet + +snippet setprefs "Write to defaults (setprefs)" +[[NSUserDefaults standardUserDefaults] setObject:${1:object} forKey:${2:key}]; +endsnippet + +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/ocaml.snippets b/vim/bundle/vim-snippets/UltiSnips/ocaml.snippets new file mode 100644 index 0000000..1ebc347 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/ocaml.snippets @@ -0,0 +1,174 @@ +priority -50 + +snippet rs "raise" b +raise (${1:Not_found}) +endsnippet + +snippet open "open" +let open ${1:module} in +${2:e} +endsnippet + +snippet try "try" +try ${1:e} +with ${2:Not_found} -> ${3:()} +endsnippet + +snippet ref "ref" +let ${1:name} = ref ${2:val} in +${3:e} +endsnippet + +snippet matchl "pattern match on a list" +match ${1:list} with +| [] -> ${2:()} +| x::xs -> ${3:()} +endsnippet + +snippet matcho "pattern match on an option type" +match ${1:x} with +| Some(${2:y}) -> ${3:()} +| None -> ${4:()} +endsnippet + +snippet fun "anonymous function" +(fun ${1:x} -> ${2:x}) +endsnippet + +snippet cc "commment" +(* ${1:comment} *) +endsnippet + +snippet let "let .. in binding" +let ${1:x} = ${2:v} in +${3:e} +endsnippet + +snippet lr "let rec" +let rec ${1:f} = + ${2:expr} +endsnippet + +snippet if "if" +if ${1:(* condition *)} then + ${2:(* A *)} +else + ${3:(* B *)} +endsnippet + +snippet If "If" +if ${1:(* condition *)} then + ${2:(* A *)} +endsnippet + +snippet while "while" +while ${1:(* condition *)} do + ${2:(* A *)} +done +endsnippet + +snippet for "for" +for ${1:i} = ${2:1} to ${3:10} do + ${4:(* BODY *)} +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} +endsnippet + +snippet class "class" +class ${1:name} = object + ${2:methods} +end +endsnippet + +snippet obj "obj" +object + ${2:methods} +end +endsnippet + +snippet Obj "object" +object (self) + ${2:methods} +end +endsnippet + +snippet {{ "object functional update" +{< ${1:x} = ${2:y} >} +endsnippet + +snippet beg "beg" +begin + ${1:block} +end +endsnippet + +snippet ml "module instantiantion with functor" +module ${1:Mod} = ${2:Functor}(${3:Arg}) +endsnippet + +snippet mod "module - no signature" +module ${1:(* Name *)} = struct + ${2:(* BODY *)} +end +endsnippet + +snippet Mod "module with signature" +module ${1:(* Name *)} : ${2:(* SIG *)} = struct + ${3:(* BODY *)} +end +endsnippet + +snippet sig "anonymous signature" +sig + ${2:(* BODY *)} +end +endsnippet + +snippet sigf "functor signature or anonymous functor" +functor (${1:Arg} : ${2:ARG}) -> ${3:(* BODY *)} +endsnippet + +snippet func "define functor - no signature" +module ${1:M} (${2:Arg} : ${3:ARG}) = struct + ${4:(* BODY *)} +end +endsnippet + +snippet Func "define functor - with signature" +module ${1:M} (${2:Arg} : ${3:ARG}) : ${4:SIG} = struct + ${5:(* BODY *)} +end +endsnippet + +snippet mot "Declare module signature" +module type ${1:(* Name *)} = sig + ${2:(* BODY *)} +end +endsnippet + +snippet module "Module with anonymous signature" +module ${1:(* Name *)} : sig + ${2:(* SIGNATURE *)} +end = struct + ${3:(* BODY *)} +end +endsnippet + +snippet oo "odoc" +(** ${1:odoc} *) +endsnippet + +snippet qt "inline qtest" +(*$T ${1:name} + ${2:test} +*) +endsnippet diff --git a/vim/bundle/vim-snippets/UltiSnips/pandoc.snippets b/vim/bundle/vim-snippets/UltiSnips/pandoc.snippets new file mode 100644 index 0000000..ce858f0 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/pandoc.snippets @@ -0,0 +1,12 @@ +extends markdown + +# overwrite if necessary +priority -49 + +snippet title "Title Header" b +% ${1:`!v vim_snippets#Filename('$1', 'title')`} +% ${2:`!v g:snips_author`} +% ${3:`!v strftime("%d %B %Y")`} + +$0 +endsnippet diff --git a/vim/bundle/vim-snippets/UltiSnips/perl.snippets b/vim/bundle/vim-snippets/UltiSnips/perl.snippets new file mode 100644 index 0000000..67c7f27 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/perl.snippets @@ -0,0 +1,139 @@ +priority -50 + +########################################################################### +# TextMate Snippets # +########################################################################### +snippet ife "Conditional if..else (ife)" +if ($1) { + ${2:# body...} +} +else { + ${3:# else...} +} + +endsnippet + +snippet ifee "Conditional if..elsif..else (ifee)" +if ($1) { + ${2:# body...} +} +elsif ($3) { + ${4:# elsif...} +} +else { + ${5:# else...} +} + +endsnippet + +snippet xunless "Conditional one-line (unless)" +${1:expression} unless ${2:condition}; + +endsnippet + +snippet xif "Conditional one-line (xif)" +${1:expression} if ${2:condition}; + +endsnippet + +snippet sub "Function (sub)" +sub ${1:function_name} { + ${2:# body...} +} + +endsnippet + +snippet xfore "Loop one-line (xforeach)" +${1:expression} foreach @${2:array}; + +endsnippet + +snippet xwhile "Loop one-line (xwhile)" +${1:expression} while ${2:condition}; + +endsnippet + +snippet test "Test" +#!/usr/bin/env perl -w + +use strict; +use Test::More tests => ${1:1}; +use ${2:ModuleName}; + +ok(${3:assertion}); + +endsnippet + +snippet class "class" +package ${1:ClassName}; + +${2:use parent qw(${3:ParentClass});}${2/.+/\n\n/}sub new { + my $class = shift; + $class = ref $class if ref $class; + my $self = bless {}, $class; + $self; +} + +1; + +endsnippet + +snippet eval "eval" +local $@; +eval { + ${1:# do something risky...} +}; +if (my $${2:exception} = $@) { + ${3:# handle failure...} +} + +endsnippet + +snippet for "for" +for (my $${1:var} = 0; $$1 < ${2:expression}; $$1++) { + ${3:# body...} +} + +endsnippet + +snippet fore "foreach" +foreach ${1:my $${2:x}} (@${3:array}) { + ${4:# body...} +} + +endsnippet + +snippet if "if" +if ($1) { + ${2:# body...} +} + +endsnippet + +snippet slurp "slurp" +my $${1:var} = do { local $/ = undef; open my $fh, '<', ${2:$file}; <$fh> }; + +endsnippet + +snippet unless "unless" +unless ($1) { + ${2:# body...} +} + +endsnippet + +snippet while "while" +while ($1) { + ${2:# body...} +} + +endsnippet + +snippet until "until" +until ($1) { + ${2:# body...} +} + +endsnippet + +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/php-laravel.snippets b/vim/bundle/vim-snippets/UltiSnips/php-laravel.snippets new file mode 100644 index 0000000..7367a14 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/php-laravel.snippets @@ -0,0 +1,270 @@ +#resource controller +snippet l_rsc "Laravel resource controller" b +/*! + * \class $1 + * + * \author ${3:`!v g:snips_author`} + * \date `!v strftime('%d-%m-%y')` + */ + +class ${1:`!v expand('%:t:r')`} extends ${2:BaseController} { + function __construct() { + } + + public function index() { + } + + public function create() { + } + + public function store() { + } + + public function show($id) { + } + + public function edit($id) { + } + + public function update($id) { + } + + public function destroy($id) { + } +} +endsnippet + +#service service provider +snippet l_ssp "Laravel service provider for service" b +<?php + +/*! + * \namespace $1 + * \class $2 + * + * \author ${3:`!v g:snips_author`} + * \date `!v strftime('%d-%m-%y')` + */ + +namespace ${1:Services}; + +use Illuminate\Support\ServiceProvider; + +class ${2:`!v expand('%:t:r')`} extends ServiceProvider { + + public function register() { + $this->app->bind('${4}Service', function ($app) { + return new ${5}( + $app->make('Repositories\\${6}Interface') + ); + }); + } +} +endsnippet + +#repository service provider +snippet l_rsp "Laravel service provider for repository" b +<?php + +/*! + * \namespace $2 + * \class $3 + * + * \author ${4:`!v g:snips_author`} + * \date `!v strftime('%d-%m-%y')` + */ + +namespace ${2:Repositories\\${1:}}; + +use Entities\\$1; +use $2\\$1Repository; +use Illuminate\Support\ServiceProvider; + +class ${3:`!v expand('%:t:r')`} extends ServiceProvider { + /*! + * \var defer + * \brief Defer service + */ + protected $defer = ${5:true}; + + public function register() { + $this->app->bind('$2\\$1Interface', function($app) { + return new $1Repository(new $1()); + }); + } + + /*! + * \brief If $defer == true need this fn + */ + public function provides() { + return ['$2\\$1Interface']; + } +} +endsnippet + +#model +snippet l_md "Laravel simple model" b +<?php + +/*! + * \namespace $1 + * \class $2 + * + * \author ${3:`!v g:snips_author`} + * \date `!v strftime('%d-%m-%y')` + */ + +namespace ${1:Entities}; + +class ${2:`!v expand('%:t:r')`} extends \Eloquent { + protected $table = '${4:`!p snip.rv = t[2].lower()`}'; + + public $timestamps = ${5:false}; + + protected $hidden = array(${6}); + + protected $guarded = array(${7:'id'}); +} +endsnippet + +#abstract repository +snippet l_ar "Laravel abstract Repository" b +<?php + +/*! + * \namespace $1 + * \class $2 + * \implements $3 + * + * \author ${4:`!v g:snips_author`} + * \date `!v strftime('%d-%m-%y')` + */ + +namespace ${1:Repositories}; + +use Illuminate\Database\Eloquent\Model; + +abstract class ${2:`!v expand('%:t:r')`} implements ${3:BaseRepositoryInterface} { + protected $model; + + /*! + * \fn __construct + * + * \brief Take the model + */ + + public function __construct(Model $model) { + $this->model = $model; + } + + /*! + * \fn all + * + * \return Illuminate\Database\Eloquent\Collection + */ + public function all($columns = array('*')) { + return $this->model->all()->toArray(); + } + + /*! + * \fn create + * + * \return Illuminate\Database\Eloquent\Model + */ + public function create(array $attributes) { + return $this->model->create($attributes); + } + + /*! + * \fn destroy + * + * \return int + */ + public function destroy($ids) { + return $this->model->destroy($ids); + } + + /*! + * \fn find + * + * \return mixed + */ + public function find($id, $columns = array('*')) { + return $this->model->find($id, $columns); + } +} +endsnippet + +#repository +snippet l_r "Laravel Repository" b +<?php + +/*! + * \namespace $1 + * \class $3 + * \implements $4 + * + * \author ${5:`!v g:snips_author`} + * \date `!v strftime('%d-%m-%y')` + */ + +namespace ${1:Repositories\\${2}}; + +class ${3:`!v expand('%:t:r')`} extends \\${6} implements ${4:$3RepositoryInterface} { + ${7} +} +endsnippet + +#service +snippet l_s "Laravel Service" b +<?php + +/*! + * \namespace $1 + * \class $2 + * + * \author ${6:`!v g:snips_author`} + * \date `!v strftime('%d-%m-%y')` + */ + +namespace Services\\${1}; + +use ${3:Repositories\\${4:Interface}}; + +class ${2:`!v expand('%:t:r')`} { + protected $${5:repo}; + + /*! + * \fn __construct + */ + public function __construct($4 $repo) { + $this->$5 = $repo; + } +} +endsnippet + +#facade +snippet l_f "Laravel Facade" b +<?php + +/*! + * \namespace $1 + * \class $2 + * + * \author ${5:`!v g:snips_author`} + * \date `!v strftime('%d-%m-%y')` + */ + +namespace ${1:Services}; + +use \Illuminate\Support\Facades\Facade; + +class ${2:`!v expand('%:t:r')`} extends Facade { + /*! + * \fn getFacadeAccessor + * + * \return string + */ + protected static function getFacadeAccessor() { return '${4:${3}Service}'; } +} +endsnippet diff --git a/vim/bundle/vim-snippets/UltiSnips/php-phpspec.snippets b/vim/bundle/vim-snippets/UltiSnips/php-phpspec.snippets new file mode 100644 index 0000000..08d84a0 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/php-phpspec.snippets @@ -0,0 +1,222 @@ +# Snippets for phpspec, to use add the following to your .vimrc +# `autocmd BufRead,BufNewFile,BufEnter *Spec.php UltiSnipsAddFiletypes php-phpspec` + +priority -50 + +snippet spec "class XYZSpec extends ObjectBehaviour" +<?php + +namespace `!p +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) +if m: + snip.rv = m.group().replace('/', '\\') +`; + +use PhpSpec\ObjectBehavior; +use Prophecy\Argument; + +/** + * @author `!v g:snips_author` + */ +class `!p +snip.rv = re.match(r'.*(?=\.)', fn).group() +` extends ObjectBehavior +{ + function it_${1}() + { + $0 + } +} +endsnippet + +snippet it "function it_does_something() { ... }" +function it_${1}() +{ + ${0:${VISUAL}} +} +endsnippet + +snippet let "function let() { ... }" +function let() +{ + ${0:${VISUAL}} +} +endsnippet + +snippet letgo "function letgo() { ... }" +function letgo() +{ + ${0:${VISUAL}} +} +endsnippet + +# Object construction +snippet cw "$this->beConstructedWith($arg)" +$this->beConstructedWith(${1}); +endsnippet + +snippet ct "$this->beConstructedThrough($methodName, [$arg])" +$this->beConstructedThrough(${1:'methodName'}, [${2:'$arg'}]); +endsnippet + +# Identity and comparison matchers +snippet sreturn "$this->XYZ()->shouldReturn('value')" +$this->${1:method}()->shouldReturn(${2:'value'}); +endsnippet + +snippet snreturn "$this->XYZ()->shouldNotReturn('value')" +$this->${1:method}()->shouldNotReturn(${2:'value'}); +endsnippet + +snippet sbe "$this->XYZ()->shouldBe('value')" +$this->${1:method}()->shouldBe(${2:'value'}); +endsnippet + +snippet snbe "$this->XYZ()->shouldNotBe('value')" +$this->${1:method}()->shouldNotBe(${2:'value'}); +endsnippet + +snippet sequal "$this->XYZ()->shouldEqual('value')" +$this->${1:method}()->shouldEqual(${2:'value'}); +endsnippet + +snippet snequal "$this->XYZ()->shouldNotEqual('value')" +$this->${1:method}()->shouldNotEqual(${2:'value'}); +endsnippet + +snippet sbequalto "$this->XYZ()->shouldBeEqualTo('value')" +$this->${1:method}()->shouldBeEqualTo(${2:'value'}); +endsnippet + +snippet snbequalto "$this->XYZ()->shouldNotBeEqualTo('value')" +$this->${1:method}()->shouldNotBeEqualTo(${2:'value'}); +endsnippet + +snippet sblike "$this->XYZ()->shouldBeLike('value')" +$this->${1:method}()->shouldBeLike(${2:'value'}); +endsnippet + +snippet snblike "$this->XYZ()->shouldNotBeLike('value')" +$this->${1:method}()->shouldNotBeLike(${2:'value'}); +endsnippet + +# Throw matcher +snippet sthrowm "$this->shouldThrow('\Exception')->duringXYZ($arg)" +$this->shouldThrow(${1:'\Exception'})->during${2:Method}(${3:'$arg'}); +endsnippet + +snippet sthrowi "$this->shouldThrow('\Exception')->duringInstantiation()" +$this->shouldThrow(${1:'\Exception'})->duringInstantiation(); +endsnippet + +# Type matchers +snippet stype "$this->shouldHaveType('Type')" +$this->shouldHaveType(${1}); +endsnippet + +snippet sntype "$this->shouldNotHaveType('Type')" +$this->shouldNotHaveType(${1}); +endsnippet + +snippet srinstance "$this->shouldReturnAnInstanceOf('Type')" +$this->shouldReturnAnInstanceOf(${1}); +endsnippet + +snippet snrinstance "$this->shouldNotReturnAnInstanceOf('Type')" +$this->shouldNotReturnAnInstanceOf(${1}); +endsnippet + +snippet sbinstance "$this->shouldBeAnInstanceOf('Type')" +$this->shouldBeAnInstanceOf(${1}); +endsnippet + +snippet snbinstance "$this->shouldNotBeAnInstanceOf('Type')" +$this->shouldNotBeAnInstanceOf(${1}); +endsnippet + +snippet simplement "$this->shouldImplement('Type')" +$this->shouldImplement(${1}); +endsnippet + +snippet snimplement "$this->shouldNotImplement('Type')" +$this->shouldNotImplement(${1}); +endsnippet + +# Object state matchers +snippet sbstate "$this->shouldBeXYZ()" +$this->shouldBe${1}(); +endsnippet + +snippet snbstate "$this->shouldNotBeXYZ()" +$this->shouldNotBe${1}(); +endsnippet + +# Count matchers +snippet scount "$this->XYZ()->shouldHaveCount(7)" +$this->${1:method}()->shouldHaveCount(${2:7}); +endsnippet + +snippet sncount "$this->XYZ()->shouldNotHaveCount(7)" +$this->${1:method}()->shouldNotHaveCount(${2:7}); +endsnippet + +# Scalar type matchers +snippet sbscalar "$this->XYZ()->shouldBeString|Array|Bool()" +$this->${1:method}()->shouldBe${2:String|Array|Bool}(); +endsnippet + +snippet snbscalar "$this->XYZ()->shouldNotBeString|Array|Bool()" +$this->${1:method}()->shouldNotBe${2:String|Array|Bool}(); +endsnippet + +# Contain matcher +snippet scontain "$this->XYZ()->shouldContain('value')" +$this->${1:method}()->shouldContain(${2:'value'}); +endsnippet + +snippet sncontain "$this->XYZ()->shouldNotContain('value')" +$this->${1:method}()->shouldNotContain(${2:'value'}); +endsnippet + +# Array matchers +snippet skey "$this->XYZ()->shouldHaveKey('key')" +$this->${1:method}()->shouldHaveKey(${2:'key'}); +endsnippet + +snippet snkey "$this->XYZ()->shouldNotHaveKey('key')" +$this->${1:method}()->shouldNotHaveKey(${2:'key'}); +endsnippet + +snippet skeyvalue "$this->XYZ()->shouldHaveKeyWithValue('key', 'value')" +$this->${1:method}()->shouldHaveKeyWithValue(${2:'key'}, ${3:'value'}); +endsnippet + +snippet snkeyvalue "$this->XYZ()->shouldNotHaveKeyWithValue('key', 'value')" +$this->${1:method}()->shouldNotHaveKeyWithValue(${2:'key'}, ${3:'value'}); +endsnippet + +# String matchers +snippet sstart "$this->XYZ()->shouldStartWith('string')" +$this->${1:method}()->shouldStartWith(${2:'string'}); +endsnippet + +snippet snstart "$this->XYZ()->shouldNotStartWith('string')" +$this->${1:method}()->shouldNotStartWith(${2:'string'}); +endsnippet + +snippet send "$this->XYZ()->shouldEndWith('string')" +$this->${1:method}()->shouldEndWith(${2:'string'}); +endsnippet + +snippet snend "$this->XYZ()->shouldNotEndWith('string')" +$this->${1:method}()->shouldNotEndWith(${2:'string'}); +endsnippet + +snippet smatch "$this->XYZ()->shouldMatch('/wizard/i')" +$this->${1:method}()->shouldMatch(${2:'/wizard/i'}); +endsnippet + +snippet snmatch "$this->XYZ()->shouldNotMatch('/wizard/i')" +$this->${1:method}()->shouldNotMatch(${2:'/wizard/i'}); +endsnippet diff --git a/vim/bundle/vim-snippets/UltiSnips/php-symfony2.snippets b/vim/bundle/vim-snippets/UltiSnips/php-symfony2.snippets new file mode 100644 index 0000000..2b127ee --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/php-symfony2.snippets @@ -0,0 +1,360 @@ +# sugguestion? report bugs? +# go to https://github.com/chrisyue/vim-snippets/issues + +priority -50 + +snippet classn "Basic class with namespace snippet" b +<?php + +namespace `!p +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) +if m: + snip.rv = m.group().replace('/', '\\') +`; + +/** + * ${1:@author `!v g:snips_author`} + */ +class `!p +snip.rv = re.match(r'.*(?=\.)', fn).group() +`$2 +{ + public function __construct(${3:$options}) + { + ${4:// code} + }$0 +} +endsnippet + +snippet contr "Symfony2 controller" b +<?php + +namespace `!p +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) +if m: + snip.rv = m.group().replace('/', '\\') +`; + +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; +use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Symfony\Component\HttpFoundation\Request; + +/** + * ${1:@author `!v g:snips_author`} + */ +class `!p +snip.rv = re.match(r'.*(?=\.)', fn).group() +` extends Controller +{ +} +endsnippet + +snippet sfa "Symfony 2 Controller action" +/** +* @Route("/${1:route_name}", name="$1") +* @Template() +*/ +public function $1Action($2) +{ + $3 + return ${4:array();}$0 +} +endsnippet + +snippet act "Symfony2 action" b +/** + * @Route("${3}", name="${4}") + * @Method({${5:"POST"}}) + * @Template() + */ +public function ${1}Action(${2}) +{ + ${6} +} +endsnippet + +snippet actt "Symfony2 action and template" b +/** + * @Route("${3}", name="${4}") + * @Method({${5:"GET"}}) + * @Template() + */ +public function ${1}Action(${2}) +{ + ${6} + return []; +}`!p +relpath = os.path.relpath(path)` +endsnippet + +snippet comm "Symfony2 command" b +<?php + +namespace `!p +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) +if m: + snip.rv = m.group().replace('/', '\\') +`; + +use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +/** + * ${3:@author `!v g:snips_author`} + */ +class `!p +snip.rv = re.match(r'.*(?=\.)', fn).group() +` extends ContainerAwareCommand +{ + protected function configure() + { + $this->setName('${1}') + ->setDescription('${2}') + ->setDefinition([ + new InputArgument('', InputArgument::REQUIRED, ''), + new InputOption('', null, InputOption::VALUE_NONE, ''), + ]); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + } +} +endsnippet + +snippet subs "Symfony2 subscriber" b +<?php + +namespace `!p +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) +if m: + snip.rv = m.group().replace('/', '\\') +`; + +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +/** + * ${1:@author `!v g:snips_author`} + */ +class `!p +snip.rv = re.match(r'.*(?=\.)', fn).group() +` implements EventSubscriberInterface +{ + public function __construct() + { + } + + /** + * {@inheritDoc} + */ + public static function getSubscribedEvents() + { + return []; + } +} +endsnippet + +snippet transf "Symfony2 form data transformer" b +<?php + +namespace `!p +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) +if m: + snip.rv = m.group().replace('/', '\\') +`; + +use Symfony\Component\Form\DataTransformerInterface; +use Symfony\Component\Form\Exception\TransformationFailedException; + +/** + * ${3:@author `!v g:snips_author`} + */ +class `!p +snip.rv = re.match(r'.*(?=\.)', fn).group() +` implements DataTransformerInterface +{ + /** + * {@inheritDoc} + */ + public function transform(${1}) + { + } + + /** + * {@inheritDoc} + */ + public function reverseTransform(${2}) + { + } +} +endsnippet + +snippet ent "Symfony2 doctrine entity" b +<?php + +namespace `!p +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) +if m: + snip.rv = m.group().replace('/', '\\') +`; + +use Doctrine\ORM\Mapping as ORM; + +/** + * ${3:@author `!v g:snips_author`} + * + * @ORM\Entity() + * @ORM\Table(name="`!p +tmp = re.match(r'.*(?=\.)', fn).group() +tmp = re.sub(r'\B([A-Z])', r'_\1', tmp) +snip.rv = tmp.lower() +`") + */ +`!p +m = re.search(r'Abstract', path) +if m: + snip.rv = 'abstract ' +`class `!p +snip.rv = re.match(r'.*(?=\.)', fn).group() +` +{ + /** + * @ORM\Column(type="integer") + * @ORM\GeneratedValue + * @ORM\Id + */ + private $id; +} +endsnippet + +snippet form "Symfony2 form type" b +<?php + +namespace `!p +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) +if m: + snip.rv = m.group().replace('/', '\\') +`; + +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolverInterface; + +/** + * ${2:@author `!v g:snips_author`} + */ +class `!p +snip.rv = re.match(r'.*(?=\.)', fn).group() +` extends AbstractType +{ + /** + * {@inheritDoc} + */ + public function buildForm(FormBuilderInterface $builder, array $options) + { + } + + /** + * {@inheritDoc} + */ + public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $resolver->setDefaults(); + } + + /** + * {@inheritDoc} + */ + public function getName() + { + return '${1}'; + } +} +endsnippet + +snippet ev "Symfony2 event" b +<?php + +namespace `!p +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) +if m: + snip.rv = m.group().replace('/', '\\') +`; + +use Symfony\Component\EventDispatcher\Event; + +/** + * ${2:@author `!v g:snips_author`} + */ +class `!p +snip.rv = re.match(r'.*(?=\.)', fn).group() +` extends Event +{ +} +endsnippet + +snippet redir "Symfony2 redirect" b +$this->redirect($this->generateUrl('${1}', ${2})); +endsnippet + +snippet usecontroller "Symfony2 use Symfony\..\Controller" b +use Symfony\Bundle\FrameworkBundle\Controller\Controller;${1} +endsnippet + +snippet usereauest "Symfony2 use Symfony\..\Request" b +use Symfony\Component\HttpFoundation\Request;${1} +endsnippet + +snippet useroute "Symfony2 use Sensio\..\Route" b +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;${1} +endsnippet + +snippet useresponse "Symfony2 use Symfony\..\Response" b +use Symfony\Component\HttpFoundation\Response;${1} +endsnippet + +snippet usefile "Symfony2 use Symfony\..\File" b +use Symfony\Component\HttpFoundation\File\UploadedFile;${1} +endsnippet + +snippet useassert "Symfony2 use Symfony\..\Constraints as Assert" b +use Symfony\Component\Validator\Constraints as Assert;${1} +endsnippet + +snippet usetemplate "Symfony2 use Sensio\..\Template" b +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;${1} +endsnippet + +snippet usecache "Symfony2 use Sensio\..\Cache" b +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;${1} +endsnippet + +snippet usemethod "Symfony2 use Sensio\..\Method" b +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;${1} +endsnippet + +snippet usearray "Symfony2 use Doctrine\..\ArrayCollection" b +use Doctrine\Common\Collections\ArrayCollection;${1} +endsnippet + +snippet useorm "Symfony2 use Doctrine\..\Mapping as ORM" b +use Doctrine\ORM\Mapping as ORM;${1} +endsnippet + +snippet usesecure "Symfony2 use JMS\..\Secure" b +use JMS\SecurityExtraBundle\Annotation\Secure;${1} +endsnippet + diff --git a/vim/bundle/vim-snippets/UltiSnips/php.snippets b/vim/bundle/vim-snippets/UltiSnips/php.snippets new file mode 100644 index 0000000..7ba51c7 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/php.snippets @@ -0,0 +1,251 @@ +priority -50 + +## Snippets from SnipMate, taken from +## https://github.com/scrooloose/snipmate-snippets.git + +snippet gm "PHP Class Getter" b +/** + * Getter for $1 + * + * @return ${2:string} + */ +public function get${1/\w+\s*/\u$0/}() +{ + return $this->$1; +} +endsnippet + +snippet sm "PHP Class Setter" b +/** + * Setter for $1 + * + * @param ${2:string} $$1 + * @return ${3:`!p snip.rv=snip.basename`} + */ +public function set${1/\w+\s*/\u$0/}(${4:${2/(void|string|int|integer|double|float|object|boolear|null|mixed|number|resource)|(.*)/(?1::$2 )/}}$$1) +{ + $this->$1 = $$1; + + ${5:return $this;} +} +endsnippet + +snippet gs "PHP Class Getter Setter" b +/** + * Getter for $1 + * + * @return ${2:string} + */ +public function get${1/\w+\s*/\u$0/}() +{ + return $this->$1; +} + +/** + * Setter for $1 + * + * @param $2 $$1 + * @return ${3:`!p snip.rv=snip.basename`} + */ +public function set${1/\w+\s*/\u$0/}(${4:${2/(void|string|int|integer|double|float|object|boolear|null|mixed|number|resource)|(.*)/(?1::$2 )/}}$$1) +{ + $this->$1 = $$1; + + ${5:return $this;} +} +endsnippet + +snippet pub "Public function" b +/** + * ${3:undocumented function} + * + * @return ${4:void} + */ +public function ${1:name}(${2:$param}) +{ + ${VISUAL}${5:return null;} +} +$0 +endsnippet + +snippet pro "Protected function" b +/** + * ${3:undocumented function} + * + * @return ${4:void} + */ +protected function ${1:name}(${2:$param}) +{ + ${VISUAL}${5:return null;} +} +$0 +endsnippet + +snippet pri "Private function" b +/** + * ${3:undocumented function} + * + * @return ${4:void} + */ +private function ${1:name}(${2:$param}) +{ + ${VISUAL}${5:return null;} +} +$0 +endsnippet + +snippet pubs "Public static function" b +/** + * ${3:undocumented function} + * + * @return ${4:void} + */ +public static function ${1:name}(${2:$param}) +{ + ${VISUAL}${5:return null;} +} +$0 +endsnippet + +snippet pros "Protected static function" b +/** + * ${3:undocumented function} + * + * @return ${4:void} + */ +protected static function ${1:name}(${2:$param}) +{ + ${VISUAL}${5:return null;} +} +$0 +endsnippet + +snippet pris "Private static function" b +/** + * ${3:undocumented function} + * + * @return ${4:void} + */ +private static function ${1:name}(${2:$param}) +{ + ${VISUAL}${5:return null;} +} +$0 +endsnippet + +snippet fu "Function snip" b +function ${1:name}(${2:$param}) +{ + ${VISUAL}${3:return null;} +} +$0 +endsnippet + +snippet new "New class instance" b +$${1:variableName} = new ${2:${1/\w+\s*/\u$0/}}($3); +$0 +endsnippet + +snippet ns "namespace declaration" b +namespace ${1:`!p +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) +if m: + snip.rv = m.group().replace('/', '\\') +`}; +endsnippet + +snippet class "Class declaration template" b +<?php + +namespace ${1:`!p +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) +if m: + snip.rv = m.group().replace('/', '\\') +`}; + +/** + * Class ${1:`!p snip.rv=snip.basename`} + * @author ${2:`!v g:snips_author`} + */ +class $1 +{ +} +endsnippet + +snippet interface "Interface declaration template" b +<?php + +namespace ${1:`!p +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) +if m: + snip.rv = m.group().replace('/', '\\') +`}; + +/** + * Interface ${1:`!p snip.rv=snip.basename`} + * @author ${2:`!v g:snips_author`} + */ +interface $1 +{ + public function ${3:someFunction}();$4 +} +endsnippet + +snippet trait "Trait declaration template" b +<?php + +namespace ${1:`!p +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) +if m: + snip.rv = m.group().replace('/', '\\') +`}; + +/** + * Trait ${1:`!p snip.rv=snip.basename`} + * @author ${2:`!v g:snips_author`} + */ +trait $1 +{ +} +endsnippet + +snippet construct "__construct()" b +/** + * @param $2mixed ${1/, /\n * \@param mixed /g} + */ +public function __construct(${1:$dependencies}) +{${1/\$(\w+)(, )*/\n $this->$1 = $$1;/g} +} +$0 +endsnippet + +# PHPUnit snippets +snippet testcase "class XYZTest extends \PHPUnit_Framework_TestCase { ... }" +<?php + +namespace `!p +relpath = os.path.relpath(path) +m = re.search(r'[A-Z].+(?=/)', relpath) +if m: + snip.rv = m.group().replace('/', '\\') +`; + +/** + * @author `!v g:snips_author` + */ +class `!p +snip.rv = re.match(r'.*(?=\.)', fn).group() +` extends \PHPUnit_Framework_TestCase +{ + public function test${1}() + { + ${0:${VISUAL}} + } +} +endsnippet + +# :vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/proto.snippets b/vim/bundle/vim-snippets/UltiSnips/proto.snippets new file mode 100644 index 0000000..923be57 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/proto.snippets @@ -0,0 +1,52 @@ +priority -50 + +global !p +from vimsnippets import complete + +FIELD_TYPES = [ + 'double', + 'float', + 'int32', + 'int64', + 'uint32', + 'uint64', + 'sint32', + 'sint64', + 'fixed32', + 'fixed64', + 'sfixed32', + 'sfixed64', + 'bool', + 'string', + 'bytes'] +endglobal + +snippet mess "Proto message" b +// ${2:TODO(`whoami`): Describe this message.} +message ${1:Name} { + $0 + + // Next available id: 1 +} +endsnippet + +snippet reqf "Required field" b +// ${4:TODO(`whoami`): Describe this field.} +optional ${1}`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1}; // Required +endsnippet + +snippet optf "Optional field" b +// ${4:TODO(`whoami`): Describe this field.} +optional ${1}`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1}; +endsnippet + +snippet repf "Repeated field" b +// ${4:TODO(`whoami`): Describe this field.} +repeated ${1}`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1}; +endsnippet + +snippet enum "Enumeration" b +// ${2:TODO(`whoami`): Describe this enum.} +enum ${1:Name} { +} +endsnippet diff --git a/vim/bundle/vim-snippets/UltiSnips/puppet.snippets b/vim/bundle/vim-snippets/UltiSnips/puppet.snippets new file mode 100644 index 0000000..1b2cfc5 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/puppet.snippets @@ -0,0 +1,235 @@ +priority -50 + +######################################################################### +# Python helper code # +######################################################################### + +global !p +import vim +import os.path +def get_module_namespace_and_basename(): + """This function will try to guess the current class or define name you are + trying to create. Note that for this to work you should be using the module + structure as per the style guide. Examples inputs and it's output + * /home/nikolavp/puppet/modules/collectd/manifests/init.pp -> collectd + * /home/nikolavp/puppet/modules/collectd/manfistes/mysql.pp -> collectd::mysql + """ + first_time = True + current_file_path_without_ext = vim.eval('expand("%:p:r")') or "" + if not current_file_path_without_ext: + return "name" + parts = os.path.split(current_file_path_without_ext) + namespace = '' + while parts[0] and parts[0] != '/': + if parts[1] == 'init' and first_time and not namespace: + first_time = False + parts = os.path.split(parts[0]) + continue + if parts[1] == 'manifests': + return os.path.split(parts[0])[1] + ('::' + namespace).rstrip(':') + else: + namespace = parts[1] + '::' + namespace + parts = os.path.split(parts[0]) + # couldn't guess the namespace. The user is editing a raw file in no module like the site.pp file + return "name" +endglobal + +############################################################################### +# Puppet Language Constructs # +# See http://docs.puppetlabs.com/puppet/latest/reference/lang_summary.html # +############################################################################### + +snippet class "Class declaration" b +class ${1:`!p snip.rv = get_module_namespace_and_basename()`} { + ${0:# body} +} +endsnippet + +snippet define "Definition" b +define ${1:`!p snip.rv = get_module_namespace_and_basename()`} { + ${0:# body} +} +endsnippet + +################################################################# +# Puppet Types # +# See http://docs.puppetlabs.com/references/latest/type.html # +################################################################# + +snippet cron "Cron resource type" b +cron { '${1:name}': + user => ${2:user}, + command => '${3:command}', + minute => ${3:minute}, + hour => ${4:hour}, +} +endsnippet + +snippet exec "Exec resource type" b +exec { '${1:command}': + refreshonly => true, +} +endsnippet + +snippet file "File resource type" b +file { '${1:name}': + source => "puppet://${2:path}", + mode => ${3:mode}, +} +endsnippet + +snippet File "Defaults for file" b +File { + owner => ${1:username}, + group => ${2:groupname}, +} +endsnippet + +snippet group "Group resource type" b +group { '${1:groupname}': + ensure => ${3:present}, + gid => ${2:gid}, +} +endsnippet + +snippet mount "Mount resource type" b +mount { '${1:path}': + device => '${2:/dev}', + fstype => '${3:filesystem}', + ensure => mounted, + options => 'rw,errors=remount-ro', +} +endsnippet + +snippet package "Package resource type" b +package { '${1:name}': + ensure => ${2:installed}, +} +endsnippet + +snippet user "user resource type" b +user { '${1:username}': + ensure => ${2:present}, + uid => ${3:uid}, + gid => ${4:gid}, + comment => ${5:gecos}, + home => ${6:homedirectory}, + managehome => false, + require => Group['${7:group'}], +} +endsnippet + +snippet service "Service resource type" b +service { '${1:name}': + hasstatus => true, + enable => true, + ensure => running, +} +endsnippet + +######################################################################## +# Puppet Functions # +# See http://docs.puppetlabs.com/references/latest/function.html # +######################################################################## + +snippet alert "Alert Function" b +alert("${1:message}")${0} +endsnippet + +snippet crit "Crit Function" b +crit("${1:message}")${0} +endsnippet + +snippet debug "Debug Function" b +debug("${1:message}")${0} +endsnippet + +snippet defined "Defined Function" b +defined(${1:Resource}["${2:name}"])${0} +endsnippet + +snippet emerg "Emerg Function" b +emerg("${1:message}")${0} +endsnippet + +snippet extlookup "Simple Extlookup" b +$${1:Variable} = extlookup("${2:Lookup}")${0} +endsnippet + +snippet extlookup "Extlookup with defaults" b +$${1:Variable} = extlookup("${2:Lookup}", ${3:Default})${0} +endsnippet + +snippet extlookup "Extlookup with defaults and custom data file" b +$${1:Variable} = extlookup("${2:Lookup}", ${3:Default}, ${4:Data Source})${0} +endsnippet + +snippet fail "Fail Function" b +fail("${1:message}")${0} +endsnippet + +snippet hiera "Hiera Function" b +$${1:Variable} = hiera("${2:Lookup}")${0} +endsnippet + +snippet hiera "Hiera with defaults" b +$${1:Variable} = hiera("${2:Lookup}", ${3:Default})${0} +endsnippet + +snippet hiera "Hiera with defaults and override" b +$${1:Variable} = hiera("${2:Lookup}", ${3:Default}, ${4:Override})${0} +endsnippet + +snippet hiera_hash "Hiera Hash Function" b +$${1:Variable} = hiera_hash("${2:Lookup}")${0} +endsnippet + +snippet hiera_hash "Hiera Hash with defaults" b +$${1:Variable} = hiera_hash("${2:Lookup}", ${3:Default})${0} +endsnippet + +snippet hiera_hash "Hiera Hash with defaults and override" b +$${1:Variable} = hiera_hash("${2:Lookup}", ${3:Default}, ${4:Override})${0} +endsnippet + +snippet hiera_include "Hiera Include Function" b +hiera_include("${1:Lookup}")${0} +endsnippet + +snippet include "Include Function" b +include ${1:classname}${0} +endsnippet + +snippet info "Info Function" b +info("${1:message}")${0} +endsnippet + +snippet inline_template "Inline Template Function" b +inline_template("<%= ${1:template} %>")${0} +endsnippet + +snippet notice "Notice Function" b +notice("${1:message}")${0} +endsnippet + +snippet realize "Realize Function" b +realize(${1:Resource}["${2:name}"])${0} +endsnippet + +snippet regsubst "Regsubst Function" b +regsubst($${1:Target}, '${2:regexp}', '${3:replacement}')${0} +endsnippet + +snippet split "Split Function" b +$${1:Variable} = split($${1:Target}, '${2:regexp}')${0} +endsnippet + +snippet versioncmp "Version Compare Function" b +$${1:Variable} = versioncmp('${1:version}', '${2:version}')${0} +endsnippet + +snippet warning "Warning Function" b +warning("${1:message}")${0} +endsnippet + +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/python.snippets b/vim/bundle/vim-snippets/UltiSnips/python.snippets new file mode 100644 index 0000000..fa3ff8b --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/python.snippets @@ -0,0 +1,707 @@ +priority -50 + +########################################################################### +# TEXTMATE SNIPPETS # +########################################################################### + +#! header +snippet #! "Shebang header for python scripts" b +#!/usr/bin/env python +# -*- coding: utf-8 -*- +$0 +endsnippet + +snippet ifmain "ifmain" b +if __name__ == `!p snip.rv = get_quoting_style(snip)`__main__`!p snip.rv = get_quoting_style(snip)`: + ${1:${VISUAL:main()}} +endsnippet + +snippet with "with" b +with ${1:expr}`!p snip.rv = " as " if t[2] else ""`${2:var}: + ${3:${VISUAL:pass}} +${0} +endsnippet + +snippet for "for loop" b +for ${1:item} in ${2:iterable}: + ${3:${VISUAL:pass}} +endsnippet + +########## +# COMMON # +########## + +# The smart def and smart class snippets use a global option called +# "g:ultisnips_python_style" which, if set to "doxygen" will use doxygen +# style comments in docstrings. + +global !p + +NORMAL = 0x1 +DOXYGEN = 0x2 +SPHINX = 0x3 +GOOGLE = 0x4 +NUMPY = 0x5 +JEDI = 0x6 + +SINGLE_QUOTES = "'" +DOUBLE_QUOTES = '"' + + +class Arg(object): + def __init__(self, arg): + self.arg = arg + self.name = arg.split('=')[0].strip() + + def __str__(self): + return self.name + + def __unicode__(self): + return self.name + + def is_kwarg(self): + return '=' in self.arg + + +def get_args(arglist): + args = [Arg(arg) for arg in arglist.split(',') if arg] + args = [arg for arg in args if arg.name != 'self'] + + return args + + +def get_quoting_style(snip): + style = snip.opt("g:ultisnips_python_quoting_style", "double") + if style == 'single': + return SINGLE_QUOTES + return DOUBLE_QUOTES + +def triple_quotes(snip): + style = snip.opt("g:ultisnips_python_triple_quoting_style") + if not style: + return get_quoting_style(snip) * 3 + return (SINGLE_QUOTES if style == 'single' else DOUBLE_QUOTES) * 3 + +def triple_quotes_handle_trailing(snip, quoting_style): + """ + Generate triple quoted strings and handle any trailing quote char, + which might be there from some autoclose/autopair plugin, + i.e. when expanding ``"|"``. + """ + if not snip.c: + # Do this only once, otherwise the following error would happen: + # RuntimeError: The snippets content did not converge: … + _, col = vim.current.window.cursor + line = vim.current.line + + # Handle already existing quote chars after the trigger. + _ret = quoting_style * 3 + while True: + try: + nextc = line[col] + except IndexError: + break + if nextc == quoting_style and len(_ret): + _ret = _ret[1:] + col = col+1 + else: + break + snip.rv = _ret + else: + snip.rv = snip.c + +def get_style(snip): + style = snip.opt("g:ultisnips_python_style", "normal") + + if style == "doxygen": return DOXYGEN + elif style == "sphinx": return SPHINX + elif style == "google": return GOOGLE + elif style == "numpy": return NUMPY + elif style == "jedi": return JEDI + else: return NORMAL + + +def format_arg(arg, style): + if style == DOXYGEN: + return "@param %s TODO" % arg + elif style == SPHINX: + return ":param %s: TODO" % arg + elif style == NORMAL: + return ":%s: TODO" % arg + elif style == GOOGLE: + return "%s (TODO): TODO" % arg + elif style == JEDI: + return ":type %s: TODO" % arg + elif style == NUMPY: + return "%s : TODO" % arg + + +def format_return(style): + if style == DOXYGEN: + return "@return: TODO" + elif style in (NORMAL, SPHINX, JEDI): + return ":returns: TODO" + elif style == GOOGLE: + return "Returns: TODO" + + +def write_docstring_args(args, snip): + if not args: + snip.rv += ' {0}'.format(triple_quotes(snip)) + return + + snip.rv += '\n' + snip.mkline('', indent='') + + style = get_style(snip) + + if style == GOOGLE: + write_google_docstring_args(args, snip) + elif style == NUMPY: + write_numpy_docstring_args(args, snip) + else: + for arg in args: + snip += format_arg(arg, style) + + +def write_google_docstring_args(args, snip): + kwargs = [arg for arg in args if arg.is_kwarg()] + args = [arg for arg in args if not arg.is_kwarg()] + + if args: + snip += "Args:" + snip.shift() + for arg in args: + snip += format_arg(arg, GOOGLE) + snip.unshift() + snip.rv += '\n' + snip.mkline('', indent='') + + if kwargs: + snip += "Kwargs:" + snip.shift() + for kwarg in kwargs: + snip += format_arg(kwarg, GOOGLE) + snip.unshift() + snip.rv += '\n' + snip.mkline('', indent='') + + +def write_numpy_docstring_args(args, snip): + if args: + snip += "Parameters" + snip += "----------" + + kwargs = [arg for arg in args if arg.is_kwarg()] + args = [arg for arg in args if not arg.is_kwarg()] + + if args: + for arg in args: + snip += format_arg(arg, NUMPY) + if kwargs: + for kwarg in kwargs: + snip += format_arg(kwarg, NUMPY) + ', optional' + snip.rv += '\n' + snip.mkline('', indent='') + + +def write_init_body(args, parents, snip): + parents = [p.strip() for p in parents.split(",")] + parents = [p for p in parents if p != 'object'] + + for p in parents: + snip += p + ".__init__(self)" + + if parents: + snip.rv += '\n' + snip.mkline('', indent='') + + for arg in args: + snip += "self._%s = %s" % (arg, arg) + + +def write_slots_args(args, snip): + args = ['"_%s"' % arg for arg in args] + snip += '__slots__ = (%s,)' % ', '.join(args) + + +def write_function_docstring(t, snip): + """ + Writes a function docstring with the current style. + + :param t: The values of the placeholders + :param snip: UltiSnips.TextObjects.SnippetUtil object instance + """ + snip.rv = "" + snip >> 1 + + args = get_args(t[2]) + if args: + write_docstring_args(args, snip) + + style = get_style(snip) + + if style == NUMPY: + snip += 'Returns' + snip += '-------' + snip += 'TODO' + else: + snip += format_return(style) + snip.rv += '\n' + snip.mkline('', indent='') + snip += triple_quotes(snip) + +def get_dir_and_file_name(snip): + return os.getcwd().split(os.sep)[-1] + '.' + snip.basename + +endglobal + +######################################## +# Class & Special Method Name Snippets # +######################################## + +snippet class "class with docstrings" b +class ${1:MyClass}(${2:object}): + + `!p snip.rv = triple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = triple_quotes(snip)` + + def __init__(self$4): + `!p snip.rv = triple_quotes(snip)`${5:TODO: to be defined1.}`!p +snip.rv = "" +snip >> 2 + +args = get_args(t[4]) + +write_docstring_args(args, snip) +if args: + snip.rv += '\n' + snip.mkline('', indent='') + snip += '{0}'.format(triple_quotes(snip)) + +write_init_body(args, t[2], snip) +` + $0 +endsnippet + + +snippet slotclass "class with slots and docstrings" b +class ${1:MyClass}(${2:object}): + + `!p snip.rv = triple_quotes(snip)`${3:Docstring for $1. }`!p snip.rv = triple_quotes(snip)` +`!p +snip >> 1 +args = get_args(t[4]) +write_slots_args(args, snip) +` + + def __init__(self$4): + `!p snip.rv = triple_quotes(snip)`${5:TODO: to be defined.}`!p +snip.rv = "" +snip >> 2 + +args = get_args(t[4]) + +write_docstring_args(args, snip) +if args: + snip.rv += '\n' + snip.mkline('', indent='') + snip += triple_quotes(snip) + +write_init_body(args, t[2], snip) +` + $0 +endsnippet + + +snippet contain "methods for emulating a container type" b +def __len__(self): + ${1:pass} + +def __getitem__(self, key): + ${2:pass} + +def __setitem__(self, key, value): + ${3:pass} + +def __delitem__(self, key): + ${4:pass} + +def __iter__(self): + ${5:pass} + +def __reversed__(self): + ${6:pass} + +def __contains__(self, item): + ${7:pass} +endsnippet + + +snippet context "context manager methods" b +def __enter__(self): + ${1:pass} + +def __exit__(self, exc_type, exc_value, traceback): + ${2:pass} +endsnippet + + +snippet attr "methods for customizing attribute access" b +def __getattr__(self, name): + ${1:pass} + +def __setattr__(self, name, value): + ${2:pass} + +def __delattr__(self, name): + ${3:pass} +endsnippet + + +snippet desc "methods implementing descriptors" b +def __get__(self, instance, owner): + ${1:pass} + +def __set__(self, instance, value): + ${2:pass} + +def __delete__(self, instance): + ${3:pass} +endsnippet + + +snippet cmp "methods implementing rich comparison" +def __eq__(self, other): + ${1:pass} + +def __ne__(self, other): + ${2:pass} + +def __lt__(self, other): + ${3:pass} + +def __le__(self, other): + ${4:pass} + +def __gt__(self, other): + ${5:pass} + +def __ge__(self, other): + ${6:pass} + +def __cmp__(self, other): + ${7:pass} +endsnippet + + +snippet repr "methods implementing string representation" +def __repr__(self): + ${1:pass} + +def __str__(self): + ${2:pass} + +def __unicode__(self): + ${3:pass} +endsnippet + + +# note: reflected operands and augmented arithmeitc assignements have been +# intentionally ommited to reduce verbosity. +snippet numeric "methods for emulating a numeric type" b +def __add__(self, other): + ${1:pass} + +def __sub__(self, other): + ${2:pass} + +def __mul__(self, other): + ${3:pass} + +def __div__(self, other): + ${4:pass} + +def __truediv__(self, other): + ${5:pass} + +def __floordiv__(self, other): + ${6:pass} + + +def __mod__(self, other): + ${7:pass} + +def __divmod__(self, other): + ${8:pass} + +def __pow__(self, other): + ${9:pass} + + +def __lshift__(self, other): + ${10:pass} + +def __rshift__(self, other): + ${11:pass} + +def __and__(self, other): + ${12:pass} + +def __xor__(self, other): + ${13:pass} + +def __or__(self, other): + ${14:pass} + + +def __neg__(self): + ${15:pass} + +def __pos__(self): + ${16:pass} + +def __abs__(self): + ${17:pass} + +def __invert__(self): + ${18:pass} + + +def __complex__(self): + ${19:pass} + +def __int__(self): + ${20:pass} + +def __long__(self): + ${21:pass} + +def __float__(self): + ${22:pass} + + +def __oct__(self): + ${22:pass} + +def __hex__(self): + ${23:pass} + + +def __index__(self): + ${24:pass} + +def __coerce__(self, other): + ${25:pass} +endsnippet + +snippet def "function with docstrings" b +def ${1:function}(`!p +if snip.indent: + snip.rv = 'self' + (", " if len(t[2]) else "")`${2:arg1}): + `!p snip.rv = triple_quotes(snip)`${4:TODO: Docstring for $1.}`!p +write_function_docstring(t, snip) ` + ${5:${VISUAL:pass}} +endsnippet + + +snippet defc "class method with docstrings" b +@classmethod +def ${1:function}(`!p +if snip.indent: + snip.rv = 'cls' + (", " if len(t[2]) else "")`${2:arg1}): + `!p snip.rv = triple_quotes(snip)`${4:TODO: Docstring for $1.}`!p +write_function_docstring(t, snip) ` + ${5:${VISUAL:pass}} +endsnippet + + +snippet defs "static method with docstrings" b +@staticmethod +def ${1:function}(${2:arg1}): + `!p snip.rv = triple_quotes(snip)`${4:TODO: Docstring for $1.}`!p +write_function_docstring(t, snip) ` + ${5:${VISUAL:pass}} +endsnippet + + +# doesn't expand when there is a word in front +snippet /(^|(?<=\W))\./ "self." r +self. +endsnippet + +snippet from "from module import name" b +from ${1:module} import ${2:Stuff} +endsnippet + + +############## +# PROPERTIES # +############## +snippet roprop "Read Only Property" b +@property +def ${1:name}(self): + ${2:return self._$1}$0 +endsnippet + +snippet rwprop "Read write property" b +def ${1:name}(): + `!p snip.rv = triple_quotes(snip) if t[2] else '' +`${2:TODO: Docstring for $1.}`!p +if t[2]: + snip >> 1 + + style = get_style(snip) + snip.rv += '\n' + snip.mkline('', indent='') + snip += format_return(style) + snip.rv += '\n' + snip.mkline('', indent='') + snip += triple_quotes(snip) +else: + snip.rv = ""` + def fget(self): + return self._$1$0 + + def fset(self, value): + self._$1 = value + return locals() + +$1 = property(**$1(), doc=$1.__doc__) +endsnippet + + +#################### +# If / Else / Elif # +#################### +snippet if "If" b +if ${1:condition}: + ${2:${VISUAL:pass}} +endsnippet + +snippet ife "If / Else" b +if ${1:condition}: + ${2:${VISUAL:pass}} +else: + ${3:pass} +endsnippet + +snippet ifee "If / Elif / Else" b +if ${1:condition}: + ${2:${VISUAL:pass}} +elif ${3:condition}: + ${4:pass} +else: + ${5:pass} +endsnippet + + +########################## +# Try / Except / Finally # +########################## +snippet try "Try / Except" b +try: + ${1:${VISUAL:pass}} +except ${2:Exception} as ${3:e}: + ${4:raise $3} +endsnippet + +snippet trye "Try / Except / Else" b +try: + ${1:${VISUAL:pass}} +except ${2:Exception} as ${3:e}: + ${4:raise $3} +else: + ${5:pass} +endsnippet + +snippet tryf "Try / Except / Finally" b +try: + ${1:${VISUAL:pass}} +except ${2:Exception} as ${3:e}: + ${4:raise $3} +finally: + ${5:pass} +endsnippet + +snippet tryef "Try / Except / Else / Finally" b +try: + ${1:${VISUAL:pass}} +except${2: ${3:Exception} as ${4:e}}: + ${5:raise} +else: + ${6:pass} +finally: + ${7:pass} +endsnippet + + +###################### +# Assertions & Tests # +###################### + +snippet ae "Assert equal" b +self.assertEqual(${1:${VISUAL:first}},${2:second}) +endsnippet + +snippet at "Assert True" b +self.assertTrue(${1:${VISUAL:expression}}) +endsnippet + +snippet af "Assert False" b +self.assertFalse(${1:${VISUAL:expression}}) +endsnippet + +snippet aae "Assert almost equal" b +self.assertAlmostEqual(${1:${VISUAL:first}},${2:second}) +endsnippet + +snippet ar "Assert raises" b +self.assertRaises(${1:exception}, ${2:${VISUAL:func}}${3/.+/, /}${3:arguments}) +endsnippet + +snippet an "Assert is None" b +self.assertIsNone(${1:${VISUAL:expression}}) +endsnippet + +snippet ann "Assert is not None" b +self.assertIsNotNone(${1:${VISUAL:expression}}) +endsnippet + +snippet testcase "pyunit testcase" b +class Test${1:Class}(${2:unittest.TestCase}): + + `!p snip.rv = triple_quotes(snip)`${3:Test case docstring.}`!p snip.rv = triple_quotes(snip)` + + def setUp(self): + ${4:pass} + + def tearDown(self): + ${5:pass} + + def test_${6:name}(self): + ${7:${VISUAL:pass}} +endsnippet + +snippet " "triple quoted string (double quotes)" b +""" +${1:${VISUAL:doc}} +`!p triple_quotes_handle_trailing(snip, '"')` +endsnippet + +snippet ' "triple quoted string (single quotes)" b +''' +${1:${VISUAL:doc}} +`!p triple_quotes_handle_trailing(snip, "'")` +endsnippet + +snippet doc "doc block (triple quotes)" +`!p snip.rv = triple_quotes(snip)` +${1:${VISUAL:doc}} +`!p snip.rv = triple_quotes(snip)` +endsnippet + +snippet pmdoc "pocoo style module doc string" b +# -*- coding: utf-8 -*- +""" + `!p snip.rv = get_dir_and_file_name(snip)` + `!p snip.rv = '~' * len(get_dir_and_file_name(snip))` + + ${1:DESCRIPTION} + + :copyright: (c) `date +%Y` by ${2:YOUR_NAME}. + :license: ${3:LICENSE_NAME}, see LICENSE for more details. +""" +$0 +endsnippet + +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/r.snippets b/vim/bundle/vim-snippets/UltiSnips/r.snippets new file mode 100644 index 0000000..02c4c25 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/r.snippets @@ -0,0 +1,178 @@ +priority -50 + +global !p +import os +from vimsnippets import complete + +FIELD_TYPES = [ +'character', +'data.frame', +'integer', +'list', +'logical', +'matrix', +'numeric', +'vector'] +endglobal + +snippet #! "Hashbang for Rscript (#!)" b +#!/usr/bin/env Rscript +endsnippet + +snippet setwd "Set workingdir" b +setwd("${1:`!p snip.rv = os.getcwd()`}") +endsnippet + +snippet as "Apply type on variable" w +as.$1`!p snip.rv = complete(t[1], FIELD_TYPES)`(${2}${VISUAL}) +endsnippet + +snippet is "Test type on variable" w +is.$1`!p snip.rv = complete(t[1], FIELD_TYPES)`(${2}${VISUAL}) +endsnippet + +snippet dl "Download and install a package" b +download.file("${1:${VISUAL:url to package}}", destfile = "${2:${1/.*\/(\S*)$/(?1:$1)/ga}}") +install.packages("$2", type = "source", repos = NULL) +library("${3:${2/^(\w+)_.*$/(?1:$1)/ga}}") +endsnippet + +snippet lib "Import a library" +library(${0:package}) +endsnippet + +snippet req "Require a file" +require(${0:package}) +endsnippet + +snippet source "Source a file" +source('${0:file}') +endsnippet + +snippet if "If statement" +if (${1}) { + ${0} +} +endsnippet + +snippet eif "Else-If statement" +else if (${1}) { + ${0} +} +endsnippet + +snippet el "Else statement" +else { + ${0} +} +endsnippet + +snippet ife "if .. else" +if (${1}) { + ${2} +} else { + ${3} +} +endsnippet + +snippet wh "while loop" +while(${1}) { + ${2} +} +endsnippet + +snippet for "for loop" +for (${1:item} in ${2:list}) { + ${3} +} +endsnippet + +snippet fun "Function definition" +${1:name} <- function (${2}) { + ${0} +} +endsnippet + +snippet ret "Return call" +return(${0}) +endsnippet + +snippet df "Data frame" +${1:name}[${2:rows}, ${0:cols}] +endsnippet + +snippet c "c function" +c(${0:items}) +endsnippet + +snippet li "list function" +list(${0:items}) +endsnippet + +snippet mat "matrix function" +matrix(${1:data}, nrow = ${2:rows}, ncol = ${0:cols}) +endsnippet + +snippet apply "apply function" +apply(${1:array}, ${2:margin}, ${0:function}) +endsnippet + +snippet lapply "lapply function" +lapply(${1:list}, ${0:function}) +endsnippet + +snippet sapply "sapply function" +sapply(${1:list}, ${0:function}) +endsnippet + +snippet vapply "vapply function" +vapply(${1:list}, ${2:function}, ${0:type}) +endsnippet + +snippet mapply "mapply function" +mapply(${1:function}, ${0:...}) +endsnippet + +snippet tapply "tapply function" +tapply(${1:vector}, ${2:index}, ${0:function}) +endsnippet + +snippet rapply "rapply function" +rapply(${1:list}, ${0:function}) +endsnippet + +snippet pl "Plot function" +plot(${1:x}, ${0:y}) +endsnippet + +snippet ggp "ggplot2 plot" +ggplot(${1:data}, aes(${0:aesthetics})) +endsnippet + +snippet fis "Fisher test" +fisher.test(${1:x}, ${0:y}) +endsnippet + +snippet chi "Chi Squared test" +chisq.test(${1:x}, ${0:y}) +endsnippet + +snippet tt "t-test" +t.test(${1:x}, ${0:y}) +endsnippet + +snippet wil "Wilcox test" +wilcox.test(${1:x}, ${0:y}) +endsnippet + +snippet cor "Correlation test" +cor.test(${1:x}, ${0:y}) +endsnippet + +snippet fte "FTE test" +var.test(${1:x}, ${0:y}) +endsnippet + +snippet kvt "KV test" +kv.test(${1:x}, ${0:y}) +endsnippet diff --git a/vim/bundle/vim-snippets/UltiSnips/rails.snippets b/vim/bundle/vim-snippets/UltiSnips/rails.snippets new file mode 100644 index 0000000..e7b2757 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/rails.snippets @@ -0,0 +1,894 @@ +priority -50 + +snippet anaf "accepts_nested_attributes_for" +accepts_nested_attributes_for :${1:association_name}${2:${3:, :allow_destroy => true}${4:, :reject_if => proc \{ |obj| ${5:obj.blank?} \}}} + +endsnippet + +snippet tcbi "Create binary column" +t.binary :${1:title}${2:, :limit => ${3:2}.megabytes} +$0 +endsnippet + +snippet tcb "Create boolean column" +t.boolean :${1:title} +$0 +endsnippet + +snippet clac "Create controller class" +class ${1:Model}Controller < ApplicationController + before_filter :find_${2:model} + + $0 + + private + def find_${2} + @$2 = ${3:$1}.find(params[:id]) if params[:id] + end +end +endsnippet + +snippet tcda "Create date column" +t.date :${1:title} +$0 +endsnippet + +snippet tcdt "Create datetime column" +t.datetime :${1:title} +$0 +endsnippet + +snippet tcd "Create decimal column" +t.decimal :${1:title}${2:${3:, :precision => ${4:10}}${5:, :scale => ${6:2}}} +$0 +endsnippet + +snippet tcf "Create float column" +t.float :${1:title} +$0 +endsnippet + +snippet clact "Create functional test class" +require 'test_helper' + +class ${1:Model}ControllerTest < ActionController::TestCase + test$0 +end + +endsnippet + +snippet tci "Create integer column" +t.integer :${1:title} +$0 +endsnippet + +snippet tcl "Create lock_version column" +t.integer :lock_version, :null => false, :default => 0 +$0 +endsnippet + +# FIXME: handling literal bracket pair inside of nested tab groups? +snippet tcr "Create references column" +t.references :${1:taggable}${2:, :polymorphic => ${3:{ :default => '${4:Photo}' \}}} +$0 +endsnippet + +snippet resources "Create resources controller class" +class ${1:Model}sController < ApplicationController + before_filter :find_${1/./\l$0/}, :only => [:show, :edit, :update, :destroy] + + # GET /${1/./\l$0/}s + # GET /${1/./\l$0/}s.xml + def index + @${1/./\l$0/}s = ${1:Model}.all + + respond_to do |wants| + wants.html # index.html.erb + wants.xml { render :xml => @${1/./\l$0/}s } + end + end + + # GET /${1/./\l$0/}s/1 + # GET /${1/./\l$0/}s/1.xml + def show + respond_to do |wants| + wants.html # show.html.erb + wants.xml { render :xml => @${1/./\l$0/} } + end + end + + # GET /${1/./\l$0/}s/new + # GET /${1/./\l$0/}s/new.xml + def new + @${1/./\l$0/} = ${1:Model}.new + + respond_to do |wants| + wants.html # new.html.erb + wants.xml { render :xml => @${1/./\l$0/} } + end + end + + # GET /${1/./\l$0/}s/1/edit + def edit + end + + # POST /${1/./\l$0/}s + # POST /${1/./\l$0/}s.xml + def create + @${1/./\l$0/} = ${1:Model}.new(params[:${1/./\l$0/}]) + + respond_to do |wants| + if @${1/./\l$0/}.save + flash[:notice] = '${1:Model} was successfully created.' + wants.html { redirect_to(@${1/./\l$0/}) } + wants.xml { render :xml => @${1/./\l$0/}, :status => :created, :location => @${1/./\l$0/} } + else + wants.html { render :action => "new" } + wants.xml { render :xml => @${1/./\l$0/}.errors, :status => :unprocessable_entity } + end + end + end + + # PUT /${1/./\l$0/}s/1 + # PUT /${1/./\l$0/}s/1.xml + def update + respond_to do |wants| + if @${1/./\l$0/}.update(params[:${1/./\l$0/}]) + flash[:notice] = '${1:Model} was successfully updated.' + wants.html { redirect_to(@${1/./\l$0/}) } + wants.xml { head :ok } + else + wants.html { render :action => "edit" } + wants.xml { render :xml => @${1/./\l$0/}.errors, :status => :unprocessable_entity } + end + end + end + + # DELETE /${1/./\l$0/}s/1 + # DELETE /${1/./\l$0/}s/1.xml + def destroy + @${1/./\l$0/}.destroy + + respond_to do |wants| + wants.html { redirect_to(${1/./\l$0/}s_url) } + wants.xml { head :ok } + end + end + + private + def find_${1/./\l$0/} + @${1/./\l$0/} = ${1:Model}.find(params[:id]) + end + +end + +endsnippet + +snippet tcs "Create string column" +t.string :${1:title} +$0 +endsnippet + +snippet tct "Create text column" +t.text :${1:title} +$0 +endsnippet + +snippet tcti "Create time column" +t.time :${1:title} +$0 +endsnippet + +snippet tcts "Create timestamp column" +t.timestamp :${1:title} +$0 +endsnippet + +snippet tctss "Create timestamps columns" +t.timestamps +$0 +endsnippet + +snippet mcol "Migration Create Column (mcc)" +t.column ${1:title}, :${2:string} +$0 +endsnippet + +snippet mccc "Migration Create Column Continue (mccc)" +t.column ${1:title}, :${2:string} +mccc$0 +endsnippet + +snippet mtab "Migration Drop Create Table (mdct)" +drop_table :${1:table}${2: [press tab twice to generate create_table]} +endsnippet + +snippet mcol "Migration Remove and Add Column (mrac)" +remove_column :${1:table}, :${2:column}${3: [press tab twice to generate add_column]} +endsnippet + +snippet rdb "RAILS_DEFAULT_LOGGER.debug (rdb)" +RAILS_DEFAULT_LOGGER.debug "${1:message}"$0 +endsnippet + +snippet tre "Table column(s) rename" +t.rename(:${1:old_column_name}, :${2:new_column_name}) +$0 +endsnippet + +snippet art "Test Assert Redirected To (art)" +assert_redirected_to ${2::action => "${1:index}"} +endsnippet + +snippet asre "Test Assert Response (are)" +assert_response :${1:success}, @response.body$0 +endsnippet + +snippet aftc "after_create" +after_create $0 +endsnippet + +snippet aftd "after_destroy" +after_destroy $0 +endsnippet + +snippet afts "after_save" +after_save $0 +endsnippet + +snippet aftu "after_update" +after_update $0 +endsnippet + +snippet aftv "after_validation" +after_validation $0 +endsnippet + +snippet aftvoc "after_validation_on_create" +after_validation_on_create $0 +endsnippet + +snippet aftvou "after_validation_on_update" +after_validation_on_update $0 +endsnippet + +snippet asg "assert(var = assigns(:var))" +assert(${1:var} = assigns(:${1}), "Cannot find @${1}") +$0 +endsnippet + +snippet asd "assert_difference" +assert_difference "${1:Model}.${2:count}", ${3:1} do + $0 +end +endsnippet + +snippet asnd "assert_no_difference" +assert_no_difference "${1:Model}.${2:count}" do + $0 +end +endsnippet + +snippet artnpp "assert_redirected_to (nested path plural)" +assert_redirected_to ${10:${2:parent}_${3:child}_path(${4:@}${5:${2}})} +endsnippet + +snippet artnp "assert_redirected_to (nested path)" +assert_redirected_to ${2:${12:parent}_${13:child}_path(${14:@}${15:${12}}, ${16:@}${17:${13}})} +endsnippet + +snippet artpp "assert_redirected_to (path plural)" +assert_redirected_to ${10:${2:model}s_path} +endsnippet + +snippet artp "assert_redirected_to (path)" +assert_redirected_to ${2:${12:model}_path(${13:@}${14:${12}})} +endsnippet + +snippet asrj "assert_rjs" +assert_rjs :${1:replace}, ${2:"${3:dom id}"} +endsnippet + +snippet ass "assert_select" +assert_select '${1:path}'${2:, :${3:text} => ${4:'${5:inner_html}'}}${6: do + $0 +end} +endsnippet + +snippet befc "before_create" +before_create $0 +endsnippet + +snippet befd "before_destroy" +before_destroy $0 +endsnippet + +snippet befs "before_save" +before_save $0 +endsnippet + +snippet befu "before_update" +before_update $0 +endsnippet + +snippet befv "before_validation" +before_validation $0 +endsnippet + +snippet befvoc "before_validation_on_create" +before_validation_on_create $0 +endsnippet + +snippet befvou "before_validation_on_update" +before_validation_on_update +endsnippet + +snippet bt "belongs_to (bt)" +belongs_to :${1:object}${2:, :class_name => "${3:${1/[[:alpha:]]+|(_)/(?1::\u$0)/g}}", :foreign_key => "${4:${1}_id}"} +endsnippet + +snippet crw "cattr_accessor" +cattr_accessor :${0:attr_names} +endsnippet + +snippet defcreate "def create - resource" +def create + @${1:model} = ${2:${1/[[:alpha:]]+|(_)/(?1::\u$0)/g}}.new(params[:$1]) + $0 + respond_to do |wants| + if @$1.save + flash[:notice] = '$2 was successfully created.' + wants.html { redirect_to(@$1) } + wants.xml { render :xml => @$1, :status => :created, :location => @$1 } + else + wants.html { render :action => "new" } + wants.xml { render :xml => @$1.errors, :status => :unprocessable_entity } + end + end +end + +endsnippet + +snippet test "test do..end" +test "${1:something interesting}" do + $0 +end +endsnippet + +snippet deftg "def get request" +def test_should_get_${1:action} + ${2:@${3:model} = ${4:$3s}(:${5:fixture_name}) + }get :${1}${6:, :id => @$3.to_param} + assert_response :success + $0 +end +endsnippet + +snippet deftp "def post request" +def test_should_post_${1:action} + ${3:@$2 = ${4:$2s}(:${5:fixture_name}) + }post :${1}${6:, :id => @$2.to_param}, :${2:model} => { $0 } + assert_response :redirect + +end +endsnippet + +snippet fina "find(:all)" +find(:all${1:, :conditions => ['${2:${3:field} = ?}', ${5:true}]}) +endsnippet + +snippet finf "find(:first)" +find(:first${1:, :conditions => ['${2:${3:field} = ?}', ${5:true}]}) +endsnippet + +snippet fini "find(id)" +find(${1:id}) +endsnippet + +snippet fine "find_each" +find_each(${1::conditions => {:${2:field} => ${3:true}\}}) do |${4:${TM_CURRENT_WORD/(\w+)\./\L$1/g}}| + $0 +end +endsnippet + +snippet finb "find_in_batches" +find_in_batches(${1::conditions => {:${2:field} => ${3:true}\}}) do |${4:${TM_CURRENT_WORD/(\w+)\./\L$1/g}}s| + $4s.each do |$4| + $0 + end +end +endsnippet + +snippet habtm "has_and_belongs_to_many (habtm)" +has_and_belongs_to_many :${1:object}${2:, :join_table => "${3:table_name}", :foreign_key => "${4:${1}_id}"} +endsnippet + +snippet hm "has_many (hm)" +has_many :${1:object}s${2:, :class_name => "${1}", :foreign_key => "${4:reference}_id"} +endsnippet + +snippet hmt "has_many (through)" +has_many :${1:objects}, :through => :${2:join_association}${3:, :source => :${4:${2}_table_foreign_key_to_${1}_table}} +endsnippet + +snippet hmd "has_many :dependent => :destroy" +has_many :${1:object}s${2:, :class_name => "${1}", :foreign_key => "${4:reference}_id"}, :dependent => :destroy$0 +endsnippet + +snippet ho "has_one (ho)" +has_one :${1:object}${2:, :class_name => "${3:${1/[[:alpha:]]+|(_)/(?1::\u$0)/g}}", :foreign_key => "${4:${1}_id}"} +endsnippet + +snippet logd "logger.debug" +${1:Rails.}logger.debug { "${1:message}" }$0 +endsnippet + +snippet loge "logger.error" +logger.error { "${1:message}" }$0 +endsnippet + +snippet logf "logger.fatal" +logger.fatal { "${1:message}" }$0 +endsnippet + +snippet logi "logger.info" +logger.info { "${1:message}" }$0 +endsnippet + +snippet logw "logger.warn" +logger.warn { "${1:message}" }$0 +endsnippet + +snippet mp "map(&:sym_proc)" +map(&:${1:id}) +endsnippet + +snippet mapca "map.catch_all" +${1:map}.catch_all "*${2:anything}", :controller => "${3:default}", :action => "${4:error}" + +endsnippet + +snippet map "map.named_route" +${1:map}.${2:connect} '${3::controller/:action/:id}' +endsnippet + +snippet mapr "map.resource" +${1:map}.resource :${2:resource}${10: do |${11:$2}| + $0 +end} +endsnippet + +snippet maprs "map.resources" +${1:map}.resources :${2:resource}${10: do |${11:$2}| + $0 +end} +endsnippet + +snippet mapwo "map.with_options" +${1:map}.with_options :${2:controller} => '${3:thing}' do |${4:$3}| + $0 +end + +endsnippet + +snippet mrw "mattr_accessor" +mattr_accessor :${0:attr_names} +endsnippet + +snippet ncl "named_scope lambda" +named_scope :name, lambda { |${1:param}| { :conditions => ${3:['${4:${5:field} = ?}', ${6:$1}]} } } + +endsnippet + +snippet nc "named_scope" +named_scope :name${1:, :joins => :${2:table}}, :conditions => ${3:['${4:${5:field} = ?}', ${6:true}]} + +endsnippet + +snippet dscope "default_scope" +default_scope ${1:order(${2:'${3:created_at DESC}'})} +endsnippet + +snippet flash "flash[...]" +flash[:${1:notice}] = "${2:Successfully created...}"$0 +endsnippet + +snippet rea "redirect_to (action)" +redirect_to :action => "${1:index}" +endsnippet + +snippet reai "redirect_to (action, id)" +redirect_to :action => "${1:show}", :id => ${0:@item} +endsnippet + +snippet rec "redirect_to (controller)" +redirect_to :controller => "${1:items}" +endsnippet + +snippet reca "redirect_to (controller, action)" +redirect_to :controller => "${1:items}", :action => "${2:list}" +endsnippet + +snippet recai "redirect_to (controller, action, id)" +redirect_to :controller => "${1:items}", :action => "${2:show}", :id => ${0:@item} +endsnippet + +snippet renpp "redirect_to (nested path plural)" +redirect_to(${2:${10:parent}_${11:child}_path(${12:@}${13:${10}})}) +endsnippet + +snippet renp "redirect_to (nested path)" +redirect_to(${2:${12:parent}_${13:child}_path(${14:@}${15:${12}}, ${16:@}${17:${13}})}) +endsnippet + +snippet repp "redirect_to (path plural)" +redirect_to(${2:${10:model}s_path}) +endsnippet + +snippet rep "redirect_to (path)" +redirect_to(${2:${12:model}_path(${13:@}${14:${12}})}) +endsnippet + +snippet reb "redirect_to :back" +redirect_to :back +endsnippet + +snippet ra "render (action)... (ra)" +render :action => "${1:action}" +endsnippet + +snippet ral "render (action,layout) (ral)" +render :action => "${1:action}", :layout => "${2:layoutname}" +endsnippet + +snippet rf "render (file) (rf)" +render :file => "${1:filepath}" +endsnippet + +snippet rfu "render (file,use_full_path) (rfu)" +render :file => "${1:filepath}", :use_full_path => ${2:false} +endsnippet + +snippet ri "render (inline) (ri)" +render :inline => "${1:<%= 'hello' %>}" +endsnippet + +snippet ril "render (inline,locals) (ril)" +render :inline => "${1:<%= 'hello' %>}", :locals => { ${2::name} => "${3:value}"$4 } +endsnippet + +snippet rit "render (inline,type) (rit)" +render :inline => "${1:<%= 'hello' %>}", :type => ${2::rxml} +endsnippet + +snippet rl "render (layout) (rl)" +render :layout => "${1:layoutname}" +endsnippet + +snippet rn "render (nothing) (rn)" +render :nothing => ${1:true} +endsnippet + +snippet rns "render (nothing,status) (rns)" +render :nothing => ${1:true}, :status => ${2:401} +endsnippet + +snippet rt "render (text) (rt)" +render :text => "${1:text to render...}" +endsnippet + +snippet rtl "render (text,layout) (rtl)" +render :text => "${1:text to render...}", :layout => "${2:layoutname}" +endsnippet + +snippet rtlt "render (text,layout => true) (rtlt)" +render :text => "${1:text to render...}", :layout => ${2:true} +endsnippet + +snippet rts "render (text,status) (rts)" +render :text => "${1:text to render...}", :status => ${2:401} +endsnippet + +snippet ru "render (update)" +render :update do |${2:page}| + $2.$0 +end +endsnippet + +snippet rest "respond_to" +respond_to do |wants| + wants.${1:html}${2: { $0 \}} +end +endsnippet + +# FIXME +snippet returning "returning do |variable| ... end" +returning ${1:variable} do${2/(^(?<var>\s*[a-z_][a-zA-Z0-9_]*\s*)(,\g<var>)*,?\s*$)|.*/(?1: |)/}${2:v}${2/(^(?<var>\s*[a-z_][a-zA-Z0-9_]*\s*)(,\g<var>)*,?\s*$)|.*/(?1:|)/} + $0 +end +endsnippet + +snippet t. "t.binary (tcbi)" +t.binary :${1:title}${2:, :limit => ${3:2}.megabytes} +t.$0 +endsnippet + +snippet t. "t.boolean (tcb)" +t.boolean :${1:title} +t.$0 +endsnippet + +snippet t. "t.date (tcda)" +t.date :${1:title} +t.$0 +endsnippet + +snippet t. "t.datetime (tcdt)" +t.datetime :${1:title} +t.$0 +endsnippet + +snippet t. "t.decimal (tcd)" +t.decimal :${1:title}${2:${3:, :precision => ${4:10}}${5:, :scale => ${6:2}}} +t.$0 +endsnippet + +snippet t. "t.float (tcf)" +t.float :${1:title} +t.$0 +endsnippet + +snippet t. "t.integer (tci)" +t.integer :${1:title} +t.$0 +endsnippet + +snippet t. "t.lock_version (tcl)" +t.integer :lock_version, :null => false, :default => 0 +t.$0 +endsnippet + +snippet t. "t.references (tcr)" +t.references :${1:taggable}${2:, :polymorphic => ${3:{ :default => '${4:Photo}' \}}} +t.$0 +endsnippet + +snippet t. "t.rename (tre)" +t.rename(:${1:old_column_name}, :${2:new_column_name}) +t.$0 +endsnippet + +snippet t. "t.string (tcs)" +t.string :${1:title} +t.$0 +endsnippet + +snippet t. "t.text (tct)" +t.text :${1:title} +t.$0 +endsnippet + +snippet t. "t.time (tcti)" +t.time :${1:title} +t.$0 +endsnippet + +snippet t. "t.timestamp (tcts)" +t.timestamp :${1:title} +t.$0 +endsnippet + +snippet t. "t.timestamps (tctss)" +t.timestamps +t.$0 +endsnippet + +snippet vaoif "validates_acceptance_of if" +validates_acceptance_of :${1:terms}${2:${3:, :accept => "${4:1}"}${5:, :message => "${6:You must accept the terms of service}"}}, :if => proc { |obj| ${7:obj.condition?} }} +endsnippet + +snippet vao "validates_acceptance_of" +validates_acceptance_of :${1:terms}${2:${3:, :accept => "${4:1}"}${5:, :message => "${6:You must accept the terms of service}"}} +endsnippet + +snippet va "validates_associated (va)" +validates_associated :${1:attribute}${2:, :on => :${3:create}} +endsnippet + +snippet vaif "validates_associated if (vaif)" +validates_associated :${1:attribute}${2:, :on => :${3:create}, :if => proc { |obj| ${5:obj.condition?} }} +endsnippet + +snippet vc "validates_confirmation_of (vc)" +validates_confirmation_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:should match confirmation}"} +endsnippet + +snippet vcif "validates_confirmation_of if (vcif)" +validates_confirmation_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:should match confirmation}", :if => proc { |obj| ${5:obj.condition?} }} +endsnippet + +snippet ve "validates_exclusion_of (ve)" +validates_exclusion_of :${1:attribute}${2:, :in => ${3:%w( ${4:mov avi} )}, :on => :${5:create}, :message => "${6:extension %s is not allowed}"} +endsnippet + +snippet veif "validates_exclusion_of if (veif)" +validates_exclusion_of :${1:attribute}${2:, :in => ${3:%w( ${4:mov avi} )}, :on => :${5:create}, :message => "${6:extension %s is not allowed}"}, :if => proc { |obj| ${7:obj.condition?} }} +endsnippet + +snippet vfif "validates_format_of if" +validates_format_of :${1:attribute}, :with => /${2:^[${3:\w\d}]+\$}/${4:, :on => :${5:create}, :message => "${6:is invalid}"}, :if => proc { |obj| ${7:obj.condition?} }} +endsnippet + +snippet vf "validates_format_of" +validates_format_of :${1:attribute}, :with => /${2:^[${3:\w\d}]+\$}/${4:, :on => :${5:create}, :message => "${6:is invalid}"} +endsnippet + +snippet viif "validates_inclusion_of if" +validates_inclusion_of :${1:attribute}${2:, :in => ${3:%w( ${4:mov avi} )}, :on => :${5:create}, :message => "${6:extension %s is not included in the list}"}, :if => proc { |obj| ${7:obj.condition?} }} +endsnippet + +snippet vi "validates_inclusion_of" +validates_inclusion_of :${1:attribute}${2:, :in => ${3:%w( ${4:mov avi} )}, :on => :${5:create}, :message => "${6:extension %s is not included in the list}"} +endsnippet + +snippet vl "validates_length_of (vl)" +validates_length_of :${1:attribute}, :within => ${2:3..20}${3:, :on => :${4:create}, :message => "${5:must be present}"} +endsnippet + +snippet vlif "validates_length_of if" +validates_length_of :${1:attribute}, :within => ${2:3..20}${3:, :on => :${4:create}, :message => "${5:must be present}"}, :if => proc { |obj| ${6:obj.condition?} }} +endsnippet + +snippet vnif "validates_numericality_of if" +validates_numericality_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:is not a number}"}, :if => proc { |obj| ${5:obj.condition?} }} +endsnippet + +snippet vn "validates_numericality_of" +validates_numericality_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:is not a number}"} +endsnippet + +snippet vp "validates_presence_of (vp)" +validates_presence_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:can't be blank}"} +endsnippet + +snippet vpif "validates_presence_of if (vpif) 2" +validates_presence_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:can't be blank}"}, :if => proc { |obj| ${5:obj.condition?} }} +endsnippet + +snippet vu "validates_uniqueness_of (vu)" +validates_uniqueness_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:must be unique}"} +endsnippet + +snippet vuif "validates_uniqueness_of if (vuif)" +validates_uniqueness_of :${1:attribute}${2:, :on => :${3:create}, :message => "${4:must be unique}", :if => proc { |obj| ${6:obj.condition?} }} +endsnippet + +snippet verify "verify -- render" +verify :only => [:$1], :method => :post, :render => {:status => 500, :text => "use HTTP-POST"} + +endsnippet + +snippet verify "verify -- redirect" +verify :only => [:$1], :session => :user, :params => :id, :redirect_to => {:action => '${2:index}'} + +endsnippet + +snippet wants "wants_format" +wants.${1:js|xml|html}${2: { $0 \}} +endsnippet + +snippet xdelete "xhr delete" +xhr :delete, :${1:destroy}, :id => ${2:1}$0 +endsnippet + +snippet xget "xhr get" +xhr :get, :${1:show}${2:, :id => ${3:1}}$0 +endsnippet + +snippet xpost "xhr post" +xhr :post, :${1:create}, :${2:object} => { $3 } +endsnippet + +snippet xput "xhr put" +xhr :put, :${1:update}, :id => ${2:1}, :${3:object} => { $4 }$0 +endsnippet + +snippet sweeper "Create sweeper class" +class ${1:Model}Sweeper < ActionController::Caching::Sweeper + observe ${1:Model} + + def after_save(${1/./\l$0/}) + expire_cache(${1/./\l$0/}) + end + + def after_destroy(${1/./\l$0/}) + expire_cache(${1/./\l$0/}) + end + + private + + def expire_cache(${1/./\l$0/}) + ${0:expire_page ${1/./\l$0/}s_path + expire_page ${1/./\l$0/}_path(${1/./\l$0/})} + end + +end +endsnippet + +snippet col "collection routes" +collection do + ${1:get :${2:action}} + ${3:put :${4:action}} + ${5:post :${6:action}} + ${7:delete :${8:action}} +end +endsnippet + +snippet format "format (respond_with)" +format.${1:html|xml|json|js|any} { $0 } +endsnippet + +snippet gem "gem" +gem '${1:name}'${2:${3:, "${4:1.0}"}${5:${6:, :require => ${7:"${8:$1}"}}${9:, :group => :${10:test}}}} +endsnippet + +snippet gemg "gem :git" +gem '${1:paperclip}', :git => "${2:git://github.com/thoughtbot/paperclip.git}"${3:, :branch => "${4:rails3}"} +endsnippet + +snippet match "match" +match '${1:${2::controller}${3:/${4::action}${5:/${6::id}${7:(.:format)}}}}'${8: => '${9:$2}#${10:$4}'${11:, :as => :${12:$10}}} +endsnippet + +snippet member "member routes" +member do + ${1:get :${2:action}} + ${3:put :${4:action}} + ${5:post :${6:action}} + ${7:delete :${8:action}} +end +endsnippet + +snippet res "resources" +resources :${1:posts}${2: do + $3 +end} +endsnippet + +snippet scope "scope" +scope :${1:name}, ${2:joins(:${3:table}).}where(${4:'${5:$3.${6:field}} = ?', ${7:'${8:value}'}}) +endsnippet + +snippet scopel "scope lambda" +scope :${1:name}, lambda { |${2:param}| ${3:where(${4::${5:field} => ${6:"${7:value}"}})} } +endsnippet + +snippet scopee "scope with extension" +scope :${1:name}, ${2:where(${3::${4:field} => ${5:'${6:value}'}})} do + def ${7:method_name} + $0 + end +end +endsnippet + +snippet sb "scoped_by" +scoped_by_${1:attribute}(${2:id}) +endsnippet + +snippet setup "setup do..end" +setup do + $0 +end +endsnippet + +snippet trans "Translation snippet" +I18n.t('`!v substitute(substitute(substitute(@%, substitute(getcwd() . "/", "\/", "\\\\/", "g"), "", ""), "\\(\\.\\(html\\|js\\)\\.\\(haml\\|erb\\)\\|\\(_controller\\)\\?\\.rb\\)$", "", ""), "/", ".", "g")`.${2:${1/[^\w]/_/g}}${3}', :default => "${1:some_text}"${4})${5:$0} +endsnippet + +snippet route_spec +it 'routes to #${1:action}' do + ${2:get}('/${3:url}').should route_to('`!v substitute(expand('%:t:r'), '_routing_spec$', '', '')`#$1'${4:, ${5:params}})${6} +end +endsnippet + +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/rnoweb.snippets b/vim/bundle/vim-snippets/UltiSnips/rnoweb.snippets new file mode 100644 index 0000000..773b9aa --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/rnoweb.snippets @@ -0,0 +1,3 @@ +priority -50 + +extends tex, r diff --git a/vim/bundle/vim-snippets/UltiSnips/rst.snippets b/vim/bundle/vim-snippets/UltiSnips/rst.snippets new file mode 100644 index 0000000..0596eee --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/rst.snippets @@ -0,0 +1,293 @@ +# -*- coding: utf-8 -*- + +priority -50 + +########################################################################### +# General Stuff # +########################################################################### +global !p +import vim +from os import path as ospath +from string import Template +import re +from collections import Counter + +from vimsnippets import complete + +#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(s): + """Detect if s contains CJK characters.""" + return CJK_RE.search(s) is not None + +def real_filename(filename): + """pealeextension 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 + + +try: + rst_char_len = vim.strwidth # Requires Vim 7.3+ +except AttributeError: + from unicodedata import east_asian_width + def rst_char_len(s): + """Return the required over-/underline length for s.""" + result = 0 + for c in s: + result += 2 if east_asian_width(c) in ('W', 'F') else 1 + return result + + +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 range(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 +endglobal + +snippet part "Part" b +`!p snip.rv = rst_char_len(t[1])*'#'` +${1:${VISUAL:Part name}} +`!p snip.rv = rst_char_len(t[1])*'#'` + +$0 +endsnippet + +snippet chap "Chapter" b +`!p snip.rv = rst_char_len(t[1])*'*'` +${1:${VISUAL:Chapter name}} +`!p snip.rv = rst_char_len(t[1])*'*'` + +$0 +endsnippet + +snippet sec "Section" b +${1:${VISUAL:Section name}} +`!p snip.rv = rst_char_len(t[1])*'='` + +$0 +endsnippet + +snippet ssec "Subsection" b +${1:${VISUAL:Subsection name}} +`!p snip.rv = rst_char_len(t[1])*'-'` + +$0 +endsnippet + +snippet sssec "Subsubsection" b +${1:${VISUAL:Subsubsection name}} +`!p snip.rv = rst_char_len(t[1])*'^'` + +$0 +endsnippet + +snippet para "Paragraph" b +${1:${VISUAL:Paragraph name}} +`!p snip.rv = rst_char_len(t[1])*'"'` + +$0 +endsnippet + +snippet em "Emphasize string" i +`!p +# dirty but works with CJK character 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:`!p snip.rv = get_popular_code_type()`} + + ${2:${VISUAL: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:${VISUAL: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:${VISUAL: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:${VISUAL: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:${VISUAL:SideBar Content}} +endsnippet +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/ruby.snippets b/vim/bundle/vim-snippets/UltiSnips/ruby.snippets new file mode 100644 index 0000000..b7124f8 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/ruby.snippets @@ -0,0 +1,353 @@ +priority -50 + +snippet "^#!" "#!/usr/bin/env ruby" r +#!/usr/bin/env ruby +$0 +endsnippet + +snippet "^# ?[uU][tT][fF]-?8" "# encoding: UTF-8" r +# encoding: UTF-8 +$0 +endsnippet + +snippet "\b(de)?f" "def <name>..." r +def ${1:function_name}${2:(${3:*args})} + $0 +end +endsnippet + +snippet defi "def initialize ..." +def initialize${1:(${2:*args})} + $0 +end +endsnippet + +snippet defr "def <name> ... rescue ..." +def ${1:function_name}${2:(${3:*args})} + $4 +rescue + $0 +end +endsnippet + +snippet For "(<from>..<to>).each { |<i>| <block> }" +(${1:from}..${2:to}).each { |${3:i}| $0 } +endsnippet + +snippet "(\S+)\.Merge!" ".merge!(<other_hash>) { |<key>,<oldval>,<newval>| <block> }" r +`!p snip.rv=match.group(1)`.merge!(${1:other_hash}) { |${2:key},${3:oldval},${4:newval}| ${5:block} } +endsnippet + +snippet "(\S+)\.merge!" ".merge!(<other_hash>) do |<key>,<oldval>,<newval>| <block> end" r +`!p snip.rv=match.group(1)`.merge!(${1:other_hash}) do |${2:key},${3:oldval},${4:newval}| + ${0:block} +end +endsnippet + +snippet "(\S+)\.Del(ete)?_?if" ".delete_if { |<key>,<value>| <block> }" r +`!p snip.rv=match.group(1)`.delete_if { |${1:key},${2:value}| $0 } +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 +end +endsnippet + +snippet "(\S+)\.Keep_?if" ".keep_if { |<key>,<value>| <block> }" r +`!p snip.rv=match.group(1)`.keep_if { |${1:key},${2:value}| $0 } +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 +end +endsnippet + +snippet "(\S+)\.Reject" ".reject { |<key>,<value>| <block> }" r +`!p snip.rv=match.group(1)`.reject { |${1:key},${2:value}| $0 } +endsnippet + +snippet "(\S+)\.reject" ".reject do <key>,<value>| <block> end" r +`!p snip.rv=match.group(1)`.reject do |${1:key},${2:value}| + $0 +end +endsnippet + +snippet "(\S+)\.Select" ".select { |<item>| <block>}" r +`!p snip.rv=match.group(1)`.select { |${1:item}| ${2:block} } +endsnippet + +snippet "(\S+)\.select" ".select do |<item>| <block> end" r +`!p snip.rv=match.group(1)`.select do |${1:item}| + ${0:block} +end +endsnippet + +snippet "(\S+)\.Sort" ".sort { |<a>,<b>| <block> }" r +`!p snip.rv=match.group(1)`.sort { |${1:a},${2:b}| $0 } +endsnippet + +snippet "(\S+)\.sort" ".sort do |<a>,<b>| <block> end" r +`!p snip.rv=match.group(1)`.sort do |${1:a},${2:b}| + $0 +end +endsnippet + +snippet "(\S+)\.Each_?k(ey)?" ".each_key { |<key>| <block> }" r +`!p snip.rv=match.group(1)`.each_key { |${1:key}| $0 } +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 +end +endsnippet + +snippet "(\S+)\.Each_?val(ue)?" ".each_value { |<value>| <block> }" r +`!p snip.rv=match.group(1)`.each_value { |${1:value}| $0 } +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 +end +endsnippet + +snippet "(\S+)\.ea" "<elements>.each do |<element>| <block> end" r +`!p snip.rv=match.group(1)`.each { |${1:e}| $0 } +endsnippet + +snippet "(\S+)\.ead" "<elements>.each do |<element>| <block> end" r +`!p snip.rv=match.group(1)`.each do |${1:e}| + $0 +end +endsnippet + +snippet "each_?s(lice)?" "<array>.each_slice(n) do |slice| <block> end" r +${1:elements}.each_slice(${2:2}) do |${3:slice}| + $0 +end +endsnippet + +snippet "Each_?s(lice)?" "<array>.each_slice(n) { |slice| <block> }" r +${1:elements}.each_slice(${2:2}) { |${3:slice}| $0 } +endsnippet + +snippet "(\S+)\.Map" ".map { |<element>| <block> }" r +`!p snip.rv=match.group(1)`.map { |${1:`!p +element_name = match.group(1).lstrip('$@') +ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name) +try: + wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1)) + snip.rv = wmatch.group(1).lower() +except: + snip.rv = 'element' +`}| $0 } +endsnippet + +snippet "(\S+)\.map" ".map do |<element>| <block> end" r +`!p snip.rv=match.group(1)`.map do |${1:`!p +element_name = match.group(1).lstrip('$@') +ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name) +try: + wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1)) + snip.rv = wmatch.group(1).lower() +except: + snip.rv = 'element' +`}| + $0 +end +endsnippet + +snippet "(\S+)\.Rev(erse)?_?each" ".reverse_each { |<element>| <block> }" r +`!p snip.rv=match.group(1)`.reverse_each { |${1:`!p +element_name = match.group(1).lstrip('$@') +ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name) +try: + wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1)) + snip.rv = wmatch.group(1).lower() +except: + snip.rv = 'element' +`}| $0 } +endsnippet + +snippet "(\S+)\.rev(erse)?_?each" ".reverse_each do |<element>| <block> end" r +`!p snip.rv=match.group(1)`.reverse_each do |${1:`!p +element_name = match.group(1).lstrip('$@') +ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name) +try: + wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1)) + snip.rv = wmatch.group(1).lower() +except: + snip.rv = 'element' +`}| + $0 +end +endsnippet + +snippet "(\S+)\.Each" ".each { |<element>| <block> }" r +`!p snip.rv=match.group(1)`.each { |${1:`!p +element_name = match.group(1).lstrip('$@') +ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name) +try: + wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1)) + snip.rv = wmatch.group(1).lower() +except: + snip.rv = 'element' +`}| $0 } +endsnippet + +snippet "(\S+)\.each" ".each do |<element>| <block> end" r +`!p snip.rv=match.group(1)`.each do |${1:`!p +element_name = match.group(1).lstrip('$@') +ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name) +try: + wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1)) + snip.rv = wmatch.group(1).lower() +except: + snip.rv = 'element' +`}| + $0 +end +endsnippet + +snippet "(\S+)\.Each_?w(ith)?_?i(ndex)?" ".each_with_index { |<element>,<i>| <block> }" r +`!p snip.rv=match.group(1)`.each_with_index { |${1:`!p +element_name = match.group(1).lstrip('$@') +ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name) +try: + wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1)) + snip.rv = wmatch.group(1).lower() +except: + snip.rv = 'element' +`},${2:i}| $0 } +endsnippet + +snippet "(\S+)\.each_?w(ith)?_?i(ndex)?" ".each_with_index do |<element>,<i>| <block> end" r +`!p snip.rv=match.group(1)`.each_with_index do |${1:`!p +element_name = match.group(1).lstrip('$@') +ematch = re.search("([A-Za-z][A-Za-z0-9_]+?)s?[^A-Za-z0-9_]*?$", element_name) +try: + wmatch = re.search("([A-Za-z][A-Za-z0-9_]+)$", ematch.group(1)) + snip.rv = wmatch.group(1).lower() +except: + snip.rv = 'element' +`},${2:i}| + $0 +end +endsnippet + +snippet "(\S+)\.Each_?p(air)?" ".each_pair { |<key>,<value>| <block> }" r +`!p snip.rv=match.group(1)`.each_pair { |${1:key},${2:value}| $0 } +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 +end +endsnippet + +snippet "(\S+)\.sub" ".sub(<expression>) { <block> }" r +`!p snip.rv=match.group(1)`.sub(${1:expression}) { ${2:"replace_with"} } +endsnippet + +snippet "(\S+)\.gsub" ".gsub(<expression>) { <block> }" r +`!p snip.rv=match.group(1)`.gsub(${1:expression}) { ${2:"replace_with"} } +endsnippet + +snippet "(\S+)\.index" ".index { |item| <block> }" r +`!p snip.rv=match.group(1)`.index { |${1:item}| ${2:block} } +endsnippet + +snippet "(\S+)\.Index" ".index do |item| ... end" r +`!p snip.rv=match.group(1)`.index do |${1:item}| + ${0:block} +end +endsnippet + +snippet until "until <expression> ... end" +until ${1:expression} + $0 +end +endsnippet + +snippet Until "begin ... end until <expression>" +begin + $0 +end until ${1:expression} +endsnippet + +snippet while "while <expression> ... end" +while ${1:expression} + $0 +end +endsnippet + +snippet While "begin ... end while <expression>" +begin + $0 +end while ${1:expression} +endsnippet + +snippet begin "begin ... rescue ... end" +begin + $1 +rescue + $0 +end +endsnippet + +snippet begin "begin ... rescue ... else ... ensure ... end" +begin + ${1:# Raise exception} +rescue Exception => e + puts e.message + puts e.backtrace.inspect + ${2:# Rescue} +else + ${3:# other exception} +ensure + ${0:# always excute} +end +endsnippet + +snippet rescue +rescue Exception => e + puts e.message + puts e.backtrace.inspect + ${0:# Rescue} +endsnippet + +snippet "\b(case|sw(itch)?)" "case <variable> when <expression> ... end" r +case ${1:variable} +when ${2:expression} +$0 +end +endsnippet + +snippet alias "alias :<new_name> :<old_name>" +alias :${1:new_name} :${2:old_name} +endsnippet + +snippet class "class <class_name> def initialize ... end end" +class ${1:class_name} + def initialize(${2:*args}) + $0 + end +end +endsnippet + +snippet module "module" +module ${1:module_name} + $0 +end +endsnippet + +snippet ### +=begin + $0 +=end +endsnippet + +# vim: set ts=2 sw=2 expandtab: diff --git a/vim/bundle/vim-snippets/UltiSnips/rust.snippets b/vim/bundle/vim-snippets/UltiSnips/rust.snippets new file mode 100644 index 0000000..40e7605 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/rust.snippets @@ -0,0 +1,106 @@ +####################################################################### +# Rust Snippets # +####################################################################### + +priority -50 + +snippet let "let variable declaration" b +let ${1:name}${2:: ${3:type}} = ${4}; +endsnippet + +snippet letm "let mut variable declaration" b +let mut ${1:name}${2:: ${3:type}} = ${4}; +endsnippet + +snippet fn "A function, optionally with arguments and return type." +fn ${1:function_name}(${2})${3/..*/ -> /}${3} { + ${VISUAL}${0} +} +endsnippet + +snippet pfn "A public function, optionally with arguments and return type." +pub fn ${1:function_name}(${2})${3/..*/ -> /}${3} { + ${VISUAL}${0} +} +endsnippet + +snippet arg "Function Arguments" i +${1:a}: ${2:T}${3:, arg} +endsnippet + +snippet || "Closure, anonymous function (inline)" i +${1:move }|${2}| { $3 } +endsnippet + +snippet |} "Closure, anonymous function (block)" i +${1:move }|${2}| { + $3 +} +endsnippet + +snippet pri "print!(..)" b +print!("${1}"${2/..*/, /}${2}); +endsnippet + +snippet pln "println!(..)" b +println!("${1}"${2/..*/, /}${2}); +endsnippet + +snippet fmt "format!(..)" +format!("${1}"${2/..*/, /}${2}); +endsnippet + +snippet macro "macro_rules!" b +macro_rules! ${1:name} { + (${2:matcher}) => ( + ${3} + ) +} +endsnippet + +snippet mod "A module" b +mod ${1:`!p snip.rv = snip.basename.lower() or "name"`} { + ${VISUAL}${0} +} +endsnippet + +snippet for "for .. in .." b +for ${1:i} in ${2} { + ${VISUAL}${0} +} +endsnippet + +snippet todo "A Todo comment" +// [TODO]: ${1:Description} - `!v strftime("%Y-%m-%d %I:%M%P")` +endsnippet + +snippet st "Struct" b +struct ${1:`!p snip.rv = snip.basename.title() or "Name"`} { + ${VISUAL}${0} +} +endsnippet + +# TODO: fancy dynamic field mirroring like Python slotclass +snippet stn "Struct with new constructor." b +pub struct ${1:`!p snip.rv = snip.basename.title() or "Name"`} { + fd${0} +} + +impl $1 { + pub fn new(${2}) -> $1 { + $1 { ${3} } + } +} +endsnippet + +snippet fd "Struct field definition" w +${1:name}: ${2:Type}, +endsnippet + +snippet impl "Struct/Trait implementation" b +impl ${1:Type/Trait}${2: for ${3:Type}} { + ${0} +} +endsnippet + +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/sh.snippets b/vim/bundle/vim-snippets/UltiSnips/sh.snippets new file mode 100644 index 0000000..7018184 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/sh.snippets @@ -0,0 +1,99 @@ +priority -50 + +global !p +import vim + +# Tests for the existence of a variable declared by Vim's filetype detection +# suggesting the type of shell script of the current file +def testShell(scope, shell): + return vim.eval("exists('" + scope + ":is_" + shell + "')") + +# Loops over the possible variables, checking for global variables +# first since they indicate an override by the user. +def getShell(): + for scope in ["g", "b"]: + for shell in ["bash", "posix", "sh", "kornshell"]: + if testShell(scope, shell) == "1": + if shell == "kornshell": + return "ksh" + if shell == "posix": + return "sh" + return shell + return "sh" +endglobal + +########################################################################### +# TextMate Snippets # +########################################################################### +snippet #! +`!p snip.rv = '#!/bin/' + getShell() + "\n\n" ` +endsnippet + +snippet !env "#!/usr/bin/env (!env)" +`!p snip.rv = '#!/usr/bin/env ' + getShell() + "\n\n" ` +endsnippet + +snippet sbash "safe bash options" +#!/usr/bin/env bash +set -euo pipefail +IFS=$'\n\t' +`!p snip.rv ='\n\n' ` +endsnippet + +snippet temp "Tempfile" +${1:TMPFILE}="$(mktemp -t ${2:`!p +snip.rv = re.sub(r'[^a-zA-Z]', '_', snip.fn) or "untitled" +`})" +${3:${4/(.+)/trap "/}${4:rm -f '$${1/.*\s//}'}${4/(.+)/" 0 # EXIT\n/}${5/(.+)/trap "/}${5:rm -f '$${1/.*\s//}'; exit 1}${5/(.+)/" 2 # INT\n/}${6/(.+)/trap "/}${6:rm -f '$${1/.*\s//}'; exit 1}${6/(.+)/" 1 15 # HUP TERM\n/}} + +endsnippet + +snippet case "case .. esac (case)" +case ${1:word} in + ${2:pattern} ) + $0;; +esac +endsnippet + +snippet elif "elif .. (elif)" +elif ${2:[[ ${1:condition} ]]}; then + ${0:#statements} +endsnippet + +snippet for "for ... done (for)" +for (( i = 0; i < ${1:10}; i++ )); do + ${0:#statements} +done +endsnippet + +snippet forin "for ... in ... done (forin)" +for ${1:i}${2/.+/ in /}${2:words}; do + ${0:#statements} +done +endsnippet + +snippet here "here document (here)" +<<-${2:'${1:TOKEN}'} + $0 +${1/['"`](.+)['"`]/$1/} +endsnippet + +snippet if "if ... then (if)" +if ${2:[[ ${1:condition} ]]}; then + ${0:#statements} +fi +endsnippet + +snippet until "until ... (done)" +until ${2:[[ ${1:condition} ]]}; do + ${0:#statements} +done +endsnippet + +snippet while "while ... (done)" +while ${2:[[ ${1:condition} ]]}; do + ${0:#statements} +done +endsnippet + +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/snippets.snippets b/vim/bundle/vim-snippets/UltiSnips/snippets.snippets new file mode 100644 index 0000000..ee0c8c7 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/snippets.snippets @@ -0,0 +1,21 @@ +priority -50 + +# We use a little hack so that the snippet is expanded +# and parsed correctly +snippet snip "Snippet definition" b +`!p snip.rv = "snippet"` ${1:Tab_trigger} "${2:Description}" ${3:b} +$0 +`!p snip.rv = "endsnippet"` +endsnippet + +snippet global "Global snippet" b +`!p snip.rv = "global"` !p +$0 +`!p snip.rv = "endglobal"` +endsnippet + +snippet vis "${VISUAL}" i +\$\{VISUAL${1:${2:default}${3:/transform/}}\} +endsnippet + +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/soy.snippets b/vim/bundle/vim-snippets/UltiSnips/soy.snippets new file mode 100644 index 0000000..9a22a57 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/soy.snippets @@ -0,0 +1,63 @@ +priority -50 + +extends html + +snippet ns "Namespace" b +{namespace ${1:name}} +endsnippet + +snippet tmpl "Template" b +/** + * ${2:TODO(`whoami`): Describe this template.} + */ +{template .${1:name}} + $0 +{/template} +endsnippet + +snippet msg "Message" b +{msg desc="${1:description}"} + $0 +{/msg} +endsnippet + +snippet let "let command" b +{let $${1:identifier}: ${2:expression} /} +endsnippet + +snippet if "if .. (if)" b +{if ${1:expression}} + $0 +{/if} +endsnippet + +snippet ife "if .. else (ife)" b +{if ${1:expression}} + $2 +{else} + $0 +{/if} +endsnippet + +snippet eli "else if .. (eli)" b +{elif ${1:expression}} + $0 +endsnippet + +snippet fore "foreach command" b +{foreach $${1:var} in ${2:ref}} + $0 +{/foreach} +endsnippet + +snippet for "for command" b +{for $${1:var} in range(${2:rangeexpr})} + $0 +{/for} +endsnippet + +snippet call "template call" b +{call ${1:tmpl}} + $0 +{/call} +endsnippet diff --git a/vim/bundle/vim-snippets/UltiSnips/supercollider.snippets b/vim/bundle/vim-snippets/UltiSnips/supercollider.snippets new file mode 100644 index 0000000..b8538aa --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/supercollider.snippets @@ -0,0 +1,10 @@ +snippet for +for (${1:1}, ${2:10}) {${3: |i}|} + $0 +} +endsnippet +snippet sdef +SynthDef(\\${1:synthName}, {${2: |${3:x}|} + ${0} +}).add; +endsnippet diff --git a/vim/bundle/vim-snippets/UltiSnips/tcl.snippets b/vim/bundle/vim-snippets/UltiSnips/tcl.snippets new file mode 100644 index 0000000..6584915 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/tcl.snippets @@ -0,0 +1,52 @@ +priority -50 + +########################################################################### +# TEXTMATE SNIPPETS # +########################################################################### +snippet for "for... (for)" b +for {${1:set i 0}} {${2:\$i < \$n}} {${3:incr i}} { + ${4} +} + +endsnippet + +snippet foreach "foreach... (foreach)" +foreach ${1:var} ${2:\$list} { + ${3} +} + +endsnippet + +snippet if "if... (if)" b +if {${1:condition}} { + ${2} +} + +endsnippet + +snippet proc "proc... (proc)" b +proc ${1:name} {${2:args}} \ +{ + ${3} +} + +endsnippet + +snippet switch "switch... (switch)" b +switch ${1:-exact} -- ${2:\$var} { + ${3:match} { + ${4} + } + default {${5}} +} + +endsnippet + +snippet while "while... (while)" b +while {${1:condition}} { + ${2} +} + +endsnippet + +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/tex.snippets b/vim/bundle/vim-snippets/UltiSnips/tex.snippets new file mode 100644 index 0000000..4c7e44b --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/tex.snippets @@ -0,0 +1,121 @@ +priority -50 + +extends texmath + +snippet "b(egin)?" "begin{} / end{}" br +\begin{${1:something}} + ${0:${VISUAL}} +\end{$1} +endsnippet + +snippet tab "tabular / array environment" b +\begin{${1:t}${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}{${2:c}} +$0${2/((?<=.)c|l|r)|./(?1: & )/g} +\end{$1${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}} +endsnippet + +snippet table "Table environment" b +\begin{table}[${1:htpb}] + \centering + \caption{${2:caption}} + \label{tab:${3:label}} + \begin{${4:t}${4/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}{${5:c}} + $0${5/((?<=.)c|l|r)|./(?1: & )/g} + \end{$4${4/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}} +\end{table} +endsnippet + +snippet fig "Figure environment" b +\begin{figure}[${2:htpb}] + \centering + \includegraphics[width=${3:0.8}\linewidth]{${4:name.ext}} + \caption{${4/(\w+)\.\w+/\u$1/}$0} + \label{fig:${4/(\w+)\.\w+/$1/}} +\end{figure} +endsnippet + +snippet enum "Enumerate" b +\begin{enumerate} + \item $0 +\end{enumerate} +endsnippet + +snippet item "Itemize" b +\begin{itemize} + \item $0 +\end{itemize} +endsnippet + +snippet desc "Description" b +\begin{description} + \item[$1] $0 +\end{description} +endsnippet + +snippet it "Individual item" b +\item ${1} +$0 +endsnippet + +snippet part "Part" b +\part{${1:part name}} +\label{prt:${2:${1/(\w+)|\W+/(?1:\L$0\E:_)/ga}}} + +${0} +endsnippet + +snippet cha "Chapter" b +\chapter{${1:chapter name}} +\label{cha:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} + +${0} +endsnippet + +snippet sec "Section" b +\section{${1:section name}} +\label{sec:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} + +${0} +endsnippet + +snippet sub "Subsection" b +\subsection{${1:subsection name}} +\label{sub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} + +${0} +endsnippet + +snippet ssub "Subsubsection" b +\subsubsection{${1:subsubsection name}} +\label{ssub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} + +${0} +endsnippet + +snippet par "Paragraph" b +\paragraph{${1:paragraph name}} +\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} + +${0} +endsnippet + +snippet subp "Subparagraph" b +\subparagraph{${1:subparagraph name}} +\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/ga}}} + +${0} +endsnippet + +snippet ni "Non-indented paragraph" b +\noindent +${0} +endsnippet + +snippet pac "Package" b +\usepackage[${1:options}]{${2:package}}$0 +endsnippet + +snippet lp "Long parenthesis" +\left(${1:${VISUAL:contents}}\right)$0 +endsnippet +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/texmath.snippets b/vim/bundle/vim-snippets/UltiSnips/texmath.snippets new file mode 100644 index 0000000..d0a25e9 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/texmath.snippets @@ -0,0 +1,56 @@ +priority -50 + +############## +# MATH STUFF # +############## +snippet eq "Equation" b +\begin{equation} + $0 +\end{equation} +endsnippet + +snippet eqnn "Equation without number" b +\begin{equation*} + $0 +\end{equation*} +endsnippet + +snippet eqa "Equation array" b +\begin{eqnarray} + $1 & $2 & $0 +\end{eqnarray} +endsnippet + +snippet eqann "Equation array without numbers" b +\begin{eqnarray*} + $1 & $2 & $0 +\end{eqnarray*} + +endsnippet +snippet frac "Fraction" w +\frac{${1:${VISUAL:nom}}}{${2:denom}} +endsnippet + +snippet mat "Smart Matrix" +\begin{${1:p/b/v/V/B/small}matrix} + $0 +\end{$1matrix} +endsnippet + +snippet lr( "left( right)" w +\left( ${1:${VISUAL}} \right) +endsnippet + +snippet lr| "left| right|" w +\left| ${1:${VISUAL}} \right| +endsnippet + +snippet lr{ "left\{ right\}" w +\left\\{ ${1:${VISUAL}} \right\\} +endsnippet + +snippet lr[ "left[ right]" w +\left[ ${1:${VISUAL}} \right] +endsnippet + +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/typescript.snippets b/vim/bundle/vim-snippets/UltiSnips/typescript.snippets new file mode 100644 index 0000000..11072dd --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/typescript.snippets @@ -0,0 +1,3 @@ +priority -50 + +extends javascript diff --git a/vim/bundle/vim-snippets/UltiSnips/vim.snippets b/vim/bundle/vim-snippets/UltiSnips/vim.snippets new file mode 100644 index 0000000..dbb2396 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/vim.snippets @@ -0,0 +1,24 @@ +priority -50 + +########################################################################### +# SnipMate Snippets # +########################################################################### +snippet gvar "Global / configuration variable" b +if !exists("g:${1:MyUltraImportantVar}") + let g:$1 = ${2:"${3:<tab>}"} +endif +endsnippet + +snippet guard "script reload guard" b +if exists('${1:did_`!p snip.rv = snip.fn.replace('.','_')`}') || &cp${2: || version < 700} + finish +endif +let $1 = 1${3} +endsnippet + +snippet f "function" b +fun ${1:function_name}(${2}) + ${3:" code} +endf +endsnippet +# vim:ft=snippets: diff --git a/vim/bundle/vim-snippets/UltiSnips/xhtml.snippets b/vim/bundle/vim-snippets/UltiSnips/xhtml.snippets new file mode 100644 index 0000000..a9c5a29 --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/xhtml.snippets @@ -0,0 +1,3 @@ +priority -50 + +extends html diff --git a/vim/bundle/vim-snippets/UltiSnips/xml.snippets b/vim/bundle/vim-snippets/UltiSnips/xml.snippets new file mode 100644 index 0000000..92dfb6e --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/xml.snippets @@ -0,0 +1,16 @@ +priority -50 + +snippet xml "XML declaration" b +<?xml version="1.0"?> + +endsnippet + +snippet t "Simple tag" b +<${1:tag}> + ${2:content} +</${1/([\w:._-]+).*/$1/}> +endsnippet + +snippet ti "Inline tag" b +<${1:tag}>${2:content}</${1/([\w:._-]+).*/$1/}> +endsnippet diff --git a/vim/bundle/vim-snippets/UltiSnips/zsh.snippets b/vim/bundle/vim-snippets/UltiSnips/zsh.snippets new file mode 100644 index 0000000..f7986ea --- /dev/null +++ b/vim/bundle/vim-snippets/UltiSnips/zsh.snippets @@ -0,0 +1,17 @@ +priority -50 + +extends sh + +priority -49 + +snippet #! "shebang" b +#!/bin/zsh + +endsnippet + +snippet !env "#!/usr/bin/env (!env)" b +#!/usr/bin/env zsh + +endsnippet + +# vim:ft=snippets: |