diff --git a/AUTHORS b/AUTHORS index 1261dc8..22a3229 100644 --- a/AUTHORS +++ b/AUTHORS @@ -38,3 +38,6 @@ Dmitry Dementev Travis Holton Chrisyue Erik Westrup + +TODO: add contributors from github.com/SirVer/Ultisnip having contributed to +github.com/SirVer/Ultisnip/UltiSnips/* files diff --git a/README.md b/README.md index c1cc3a6..395dcc9 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,57 @@ IMPORTANT: comment on: [What about merging whith Ultisnip using its engine](https://github.com/garbas/vim-snipmate/issues/114) -Snipmate Snippets -================= +Snipmate & UltiSnip Snippets +============================ This repository contains snippets files for various programming languages. -It was originally written for the the famous [snipMate][1] plugin for vim. -However today there are at least 3 plugins which can make use of this snippet repository: - -1) [snipMate][1] - -2) [Shougo's neosnippet][5] has a compatible mode allowing - to reuse most snippets. - -3) [ultisnip][6] (stable enough to be used, branch master previously snipmate-merge) - This code is subject to change. Take it as preview. That branch - has additional notes for Snipmate users. at the bottom. - In the long run ultisnip will have its own set of snippets, because it is - more powerful cause it supports nested snippets. - - - It is community-maintained and many people have contributed snippet files and other -improvements already. Not sure whether it implements all features such as -guards - does anybody know? +improvements already. + +Contents +======== + + snippets/*: snippets using snipmate format + UltiSnips/*: snippets using UltiSnips format + +Snippet engines +=============== + +There are different forks of snippet engines which allow the user to insert +sippets by typing the name of a snippet hitting the expansion mapping. + + garbas/vim-snipmate [4]: + VimL, snipmate-snippets, engine sometimes behaves strange, supports + rewriting snippets on the fly (eg adding a second version with folding + markers) + + MarcWeber/UltiSnips [6]: + python, snipmate-snippets and UltiSnips-snippets + + SirVer/ultisnips [7]: + python, UltiSnips-snippets + + github.com/Shougo/neosnippet [5]: + viml, has a compatible mode allowing to reuse most snipmate snippets ? + + XPTemplate: + totally different syntax, does not read snippets contained in this file, + but it is also very powerful + + ... there are some more, but they have less features which is why I don't + mention them here + +UltiSnips engine has additional features such as "nested snippets". + +Which one to use? If you have python give MarcWeber/UltiSnips a try because its +fast and supports all important features. You can prefer the UltiSnip versions +of the snippets by setting the "always_use_first_snippet" option to 1. + +If you have VimL only (vim without python support) your best option is using +garbas/vim-snipmate and cope with the minor bugs found in the engine. + +Historical notes +================ [vim-snipmate][1] was originally started by [Michael Sanders][2] who has now unfortunately abandoned the project. [Rok Garbas][3] is now maintaining a @@ -50,6 +78,13 @@ Until further work is done on `vim-snipmate`, please don't add folding markers into snippets. `vim-snipmate` has some comments about how to patch all snippets on the fly adding those. +Because MarcWeber/UltiSnips [6] supports also snipmate-snippets there is no +need to duplicate all snippets - only those snippets who use advanced UltiSnips +features should be duplicated in UltiSnips (?) + +Currently all snippets from UltiSnips have been put into UltiSnips - some work +on merging should be done (dropping duplicates etc) + Authors ------- @@ -66,5 +101,6 @@ terms of the MIT license. [2]: http://github.com/msanders [3]: http://github.com/garbas [4]: http://github.com/garbas/vim-snipmate -[5]: https://github.com/Shougo/neosnippet -[6]: https://github.com/MarcWeber/UltiSnips/tree/snipmate-merge +[5]: http://github.com/Shougo/neosnippet +[6]: http://github.com/MarcWeber/UltiSnips +[7]: http://github.com/SirVer/ultisnips diff --git a/UltiSnips/README b/UltiSnips/README new file mode 100644 index 0000000..eafd086 --- /dev/null +++ b/UltiSnips/README @@ -0,0 +1,21 @@ +This directory contains the main scripts that come bundled with 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/ + +All snippets from those sources were copied and cleaned up, so that they are + - not using shell script, only python (so they are cross platform compatible) + - not using any feature that UltiSnips doesn't offer + +UltiSnips has seen contributions by various individuals. Those contributions +have been merged into this collection seamlessly and without further comments. + +-- vim:ft=rst:nospell: + diff --git a/UltiSnips/all.snippets b/UltiSnips/all.snippets new file mode 100644 index 0000000..8844e28 --- /dev/null +++ b/UltiSnips/all.snippets @@ -0,0 +1,112 @@ +# This file contains snippets that are always defined. I personally +# have snippets for signatures and often needed texts + +############## +# NICE BOXES # +############## +global !p +import string, vim + +""" Maps a filetype to comment format used for boxes. +Automatically filled during usage""" +_commentDict = { } + +def _parse_comments(s): + """ Parses vim's comments option to extract comment format """ + i = iter(s.split(",")) + + rv = [] + try: + while True: + # get the flags and text of a comment part + flags,text = i.next().split(':', 1) + + if len(flags) == 0: + if len(text) == 1: + rv.append((text,text,text, "")) + # parse 3-part comment, but ignore those with O flag + elif flags[0] == 's' and 'O' not in flags: + ctriple = [] + indent = "" + + if flags[-1] in string.digits: + indent = " " * int(flags[-1]) + ctriple.append(text) + + flags,text = i.next().split(':', 1) + assert(flags[0] == 'm') + ctriple.append(text) + + flags,text = i.next().split(':', 1) + assert(flags[0] == 'e') + ctriple.append(text) + ctriple.append(indent) + + rv.append(ctriple) + + elif flags[0] == 'b': + if len(text) == 1: + rv.insert(0, (text,text,text, "")) + + except StopIteration: + return rv + +def _get_comment_format(): + """ Returns a 4-element tuple representing the comment format for + the current file. """ + + ft = vim.eval("&filetype") + # check if the comment dict has the format for the current file + if _commentDict.has_key(ft): + return _commentDict[ft] + + # otherwise parse vim's comments and add it for later use + commentformat = _parse_comments(vim.eval("&comments"))[0] + _commentDict[ft] = commentformat + + return commentformat + + +def make_box(twidth, bwidth = None): + if bwidth is None: + bwidth = twidth + 2 + b,m,e,i = _get_comment_format() + sline = b + m + bwidth*m + 2*m + nspaces = (bwidth - twidth)//2 + mlines = i + m + " " + " "*nspaces + mlinee = " " + " "*(bwidth-twidth-nspaces) + m + eline = i + 2*m + bwidth*m + m + e + return sline, mlines, mlinee, eline +endglobal + +snippet box "A nice box with the current comment symbol" b +`!p +box = make_box(len(t[1])) +snip.rv = box[0] + '\n' + box[1] +`${1:content}`!p +box = make_box(len(t[1])) +snip.rv = box[2] + '\n' + box[3]` +$0 +endsnippet + +snippet bbox "A nice box over the full width" b +`!p +box = make_box(len(t[1]), 71) +snip.rv = box[0] + '\n' + box[1] +`${1:content}`!p +box = make_box(len(t[1]), 71) +snip.rv = box[2] + '\n' + box[3]` +$0 +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:ft=snippets: diff --git a/UltiSnips/bindzone.snippets b/UltiSnips/bindzone.snippets new file mode 100644 index 0000000..034ccde --- /dev/null +++ b/UltiSnips/bindzone.snippets @@ -0,0 +1,27 @@ +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/UltiSnips/c.snippets b/UltiSnips/c.snippets new file mode 100644 index 0000000..062a36a --- /dev/null +++ b/UltiSnips/c.snippets @@ -0,0 +1,117 @@ +########################################################################### +# TextMate Snippets # +########################################################################### + +snippet def "#define ..." +#define ${1} +endsnippet + +snippet ifndef "#ifndef ... #define ... #endif" +#ifndef ${1/([A-Za-z0-9_]+).*/$1/} +#define ${1:SYMBOL} ${2:value} +#endif +endsnippet + +snippet #if "#if #endif" !b +#if ${1:0} +${VISUAL:code}$0 +#endif +endsnippet + +snippet inc "#include local header (inc)" +#include "${1:`!p snip.rv = snip.basename + '.h'`}" +endsnippet + +snippet Inc "#include <> (Inc)" +#include <${1:.h}> +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 const *argv[]) +{ + ${0:/* code */} + return 0; +} +endsnippet + +snippet for "for int loop (fori)" +for (${4:size_t} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}) +{ + ${0:/* code */} +} +endsnippet + +snippet enum "Enumeration" +enum ${1:name} { $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 + +${0} + +#endif /* end of include guard: $1 */ + +endsnippet + +snippet td "Typedef" +typedef ${1:int} ${2:MyCustomType}; +endsnippet + +snippet do "do...while loop (do)" +do { + ${0:/* code */} +} while(${1:/* condition */}); +endsnippet + +snippet fprintf "fprintf ..." +fprintf(${1:stderr}, "${2:%s}\n"${2/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$3${2/([^%]|%%)*(%.)?.*/(?2:\);)/} +endsnippet + +snippet if "if .. (if)" +if (${1:/* condition */}) +{ + ${0:/* code */} +} +endsnippet + +snippet ife "if .. else (ife)" +if (${1:/* condition */}) +{ + ${2:/* code */} +} +else +{ + ${3:/* else */} +} +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 + +# vim:ft=snippets: diff --git a/UltiSnips/coffee.snippets b/UltiSnips/coffee.snippets new file mode 100644 index 0000000..8f347f1 --- /dev/null +++ b/UltiSnips/coffee.snippets @@ -0,0 +1,90 @@ +# From the TextMate bundle + +snippet fun "Function" b +${1:name} = (${2:args}) -> + ${0:# body...} +endsnippet + +snippet bfun "Function (bound)" b +${1:(${2:args}) }=> + ${0:# body...} +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}]${4: by ${5:step}} + ${0:# body...} +endsnippet + +snippet forrex "Range Comprehension (exclusive)" b +for ${1:name} in [${2:start}...${3:finish}]${4: by ${5:step}} + ${0:# body...} +endsnippet + +snippet swi "Switch" b +switch ${1:object} + when ${2:value} + ${0:# body...} +endsnippet + +snippet cla "Class" b +class ${1:ClassName}${2: extends ${3:Ancestor}} + + ${4:constructor: (${5:args}) -> + ${6:# body...}} + $7 +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" +#{$1}$0 +endsnippet + +snippet log "Log" b +console.log ${1:"${2:msg}"} +endsnippet + diff --git a/UltiSnips/coffee_jasmine.snippets b/UltiSnips/coffee_jasmine.snippets new file mode 100644 index 0000000..47d1e6b --- /dev/null +++ b/UltiSnips/coffee_jasmine.snippets @@ -0,0 +1,163 @@ +# +# CoffeeScript versions -- adapted from the JS TextMate bundle + additions +# for some jasmine-jquery matchers +# +extends coffee + +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/UltiSnips/cpp.snippets b/UltiSnips/cpp.snippets new file mode 100644 index 0000000..9d2eb86 --- /dev/null +++ b/UltiSnips/cpp.snippets @@ -0,0 +1,52 @@ +extends c + +########################################################################### +# 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"`} +{ + $0 +}${1/.+/ \/* /m}$1${1/.+/ *\/ /m} +endsnippet + +snippet readfile "read file (readF)" +std::vector 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 (template)" +template +endsnippet + +# vim:ft=snippets: diff --git a/UltiSnips/css.snippets b/UltiSnips/css.snippets new file mode 100644 index 0000000..d14d51c --- /dev/null +++ b/UltiSnips/css.snippets @@ -0,0 +1,405 @@ +########################################################################### +# Most of these came from TextMate # +########################################################################### + +snippet ! "!important CSS (!)" +${1:!important} +endsnippet + +snippet fixed "Fixed Position Bottom 100% wide IE6" +${2:bottom: auto;}top: expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-${1:THE HEIGHT OF THIS THING IN PIXELS})); +${3:left: expression(eval(document.documentElement.scrollLeft)); +}${4:width: expression(eval(document.documentElement.clientWidth));}$0 +endsnippet + +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-shadow: color-hex x y blur (text)" +text-shadow: #${1:DDD} ${2:10px} ${3:10px} ${4:2px};$0 +endsnippet + +snippet text "text-shadow: color-rgb x y blur (text)" +text-shadow: rgb(${1:255},${2:255},${3:255}) ${4:10px} ${5:10px} ${6:2px};$0 +endsnippet + +snippet text "text-shadow: none (text)" +text-shadow: none;$0 +endsnippet + +snippet text "text-transform: capitalize:upper:lower (text)" +text-transform: ${1:capitalize/uppercase/lowercase};$0 +endsnippet + +snippet text "text-transform: none (text)" +text-transform: none;$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 word "word-spacing: normal (word)" +word-spacing: normal;$0 +endsnippet + +snippet z "z-index: index (z)" +z-index: $1;$0 +endsnippet + +# vim:ft=snippets: diff --git a/UltiSnips/d.snippets b/UltiSnips/d.snippets new file mode 100644 index 0000000..8ed9b41 --- /dev/null +++ b/UltiSnips/d.snippets @@ -0,0 +1,583 @@ +# Simple shortcuts + +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:/*code*/} +} +endsnippet + +snippet ife "if .. else (ife)" b +if(${1:/*condition*/}) +{ + ${2:/*code*/} +} +else +{ + ${3:/*else*/} +} +endsnippet + +snippet el "else (el)" b +else +{ + ${VISUAL}${1:/*code*/} +} +endsnippet + +snippet elif "else if (elif)" b +else if(${1:/*condition*/}) +{ + ${VISUAL}${0:/*code*/} +} +endsnippet + +snippet sw "switch (sw)" +switch(${1:/*var*/}) +{ + case ${2:/*value*/}: + ${3:/*code*/} + break; + case ${4:/*value*/}: + ${5:/*code*/} + break; + ${7:/*more cases*/} + default: + ${6:assert(false);} +} +endsnippet + +snippet fsw "final switch (fsw)" +switch(${1:/*var*/}) +{ + case ${2:/*value*/}: + ${3:/*code*/} + break; + case ${4:/*value*/}: + ${5:/*code*/} + break; + ${7:/*more cases*/} +} +endsnippet + +snippet case "case (case)" b +case ${1:/*value*/}: + ${2:/*code*/} + break; +endsnippet + +snippet ?: "ternary operator (?:)" +${1:/*condition*/} ? ${2:/*then*/} : ${3:/*else*/}$4 +endsnippet + +# Loops + +snippet do "do while (do)" b +do +{ + ${VISUAL}${2:/*code*/} +} while(${1:/*condition*/}); +endsnippet + +snippet wh "while (wh)" b +while(${1:/*condition*/}) +{ + ${VISUAL}${2:/*code*/} +} +endsnippet + +snippet for "for (for)" b +for (${4:size_t} ${2:i} = 0; $2 < ${1:count}; ${3:++$2}) +{ + ${VISUAL}${0:/*code*/} +} +endsnippet + +snippet forever "forever (forever)" b +for(;;) +{ + ${VISUAL}${0:/*code*/} +} +endsnippet + +snippet fore "foreach (fore)" +foreach(${1:/*elem*/}; ${2:/*range*/}) +{ + ${VISUAL}${3:/*code*/} +} +endsnippet + +snippet forif "foreach if (forif)" b +foreach(${1:/*elem*/}; ${2:/*range*/}) if(${3:/*condition*/}) +{ + ${VISUAL}${4:/*code*/} +} +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:/*code*/} +} +endsnippet + +snippet void "void function definition (void)" +void ${1:/*function name*/}(${2:/*args*/}) ${3:@safe pure nothrow} +{ + ${VISUAL}${4:/*code*/} +} +endsnippet + +snippet this "ctor (this)" w +this(${1:/*args*/}) +{ + ${VISUAL}${2:/*code*/} +} +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:/*code*/} +} +endsnippet + +# With + +snippet with "with (with)" +with(${1}) +{ + ${VISUAL}${2:/*code*/} +} +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:/*code*/} +} +endsnippet + +snippet debug "debug" b +debug +{ + ${VISUAL}${1:/*code*/} +} +endsnippet + + +# Templates + +snippet temp "template (temp)" b +template ${2:/*name*/}(${1:/*args*/}) +{ + ${3:/*code*/} +} +endsnippet + + +# Asserts + +snippet ass "assert (ass)" b +assert(${1:false}, "${2:TODO}"); + +endsnippet + + +# Unittests + +snippet unittest "unittest (unittest)" b +unittest +{ + ${1:/*code*/} +} +endsnippet + + +# Common member functions + +snippet opDis "opDispatch (opDis)" b +${1:/*return type*/} opDispatch(string s)() +{ + ${2:/*code*/}; +} +endsnippet + +snippet op= "opAssign (op=)" b +void opAssign(${1} rhs) ${2:@safe pure nothrow} +{ + ${2:/*code*/} +} +endsnippet + +snippet opCmp "opCmp (opCmp)" b +int opCmp(${1} rhs) @safe const pure nothrow +{ + ${2:/*code*/} +} +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:/*code*/} +} +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 Filename('$1', 'name')`; + + +${3} +endsnippet diff --git a/UltiSnips/django.snippets b/UltiSnips/django.snippets new file mode 100644 index 0000000..59b77c5 --- /dev/null +++ b/UltiSnips/django.snippets @@ -0,0 +1,236 @@ +# Generic Tags +snippet % +{% ${1} %}${2} +endsnippet + +snippet %% +{% ${1:tag_name} %} + ${2} +{% end$1 %} +endsnippet + +snippet { +{{ ${1} }}${2} +endsnippet + +# Template Tags + +snippet autoescape +{% autoescape ${1:off} %} + ${2} +{% endautoescape %} +endsnippet + +snippet block +{% block ${1} %} + ${2} +{% endblock %} +endsnippet + +snippet # +{# ${1:comment} #} +endsnippet + +snippet comment +{% comment %} + ${1} +{% endcomment %} +endsnippet + +snippet cycle +{% cycle ${1:val1} ${2:val2} ${3:as ${4}} %} +endsnippet + +snippet debug +{% debug %} +endsnippet + +snippet extends +{% extends "${1:base.html}" %} +endsnippet + +snippet filter +{% filter ${1} %} + ${2} +{% endfilter %} +endsnippet + +snippet firstof +{% firstof ${1} %} +endsnippet + +snippet for +{% for ${1} in ${2} %} + ${3} +{% endfor %} +endsnippet + +snippet empty +{% empty %} + ${1} +endsnippet + +snippet if +{% if ${1} %} + ${2} +{% endif %} +endsnippet + +snippet else +{% else %} + ${1} +endsnippet + +snippet ifchanged +{% ifchanged %}${1}{% endifchanged %} +endsnippet + +snippet ifequal +{% ifequal ${1} ${2} %} + ${3} +{% endifequal %} +endsnippet + +snippet ifnotequal +{% ifnotequal ${1} ${2} %} + ${3} +{% endifnotequal %} +endsnippet + +snippet include +{% include "${1}" %} +endsnippet + +snippet load +{% load ${1} %} +endsnippet + +snippet now +{% now "${1:jS F Y H:i}" %} +endsnippet + +snippet regroup +{% regroup ${1} by ${2} as ${3} %} +endsnippet + +snippet spaceless +{% spaceless %}${1}{% endspaceless %} +endsnippet + +snippet ssi +{% ssi ${1} %} +endsnippet + +snippet trans +{% trans "${1:string}" %} +endsnippet + +snippet url +{% url ${1} as ${2} %} +endsnippet + +snippet widthratio +{% widthratio ${1:this_value} ${2:max_value} ${3:100} %} +endsnippet + +snippet with +{% with ${1} as ${2} %} +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 +add:"${1}" +endsnippet + +snippet center +center:"${1}" +endsnippet + +snippet cut +cut:"${1}" +endsnippet + +snippet date +date:"${1}" +endsnippet + +snippet default +default:"${1}" +endsnippet + +snippet defaultifnone +default_if_none:"${1}" +endsnippet + +snippet dictsort +dictsort:"${1}" +endsnippet + +snippet dictsortrev +dictsortreversed:"${1}" +endsnippet + +snippet divisibleby +divisibleby:"${1}" +endsnippet + +snippet floatformat +floatformat:"${1}" +endsnippet + +snippet getdigit +get_digit:"${1}" +endsnippet + +snippet join +join:"${1}" +endsnippet + +snippet lengthis +length_is:"${1}" +endsnippet + +snippet pluralize +pluralize:"${1}" +endsnippet + +snippet removetags +removetags:"${1}" +endsnippet + +snippet slice +slice:"${1}" +endsnippet + +snippet stringformat +stringformat:"${1}" +endsnippet + +snippet time +time:"${1}" +endsnippet + +snippet truncatewords +truncatewords:${1} +endsnippet + +snippet truncatewordshtml +truncatewords_html:${1} +endsnippet + +snippet urlizetrunc +urlizetrunc:${1} +endsnippet + +snippet wordwrap +wordwrap:${1} +endsnippet + +# vim:ft=snippets: diff --git a/UltiSnips/erlang.snippets b/UltiSnips/erlang.snippets new file mode 100644 index 0000000..7823162 --- /dev/null +++ b/UltiSnips/erlang.snippets @@ -0,0 +1,98 @@ +########################################################################### +# TEXTMATE SNIPPETS # +########################################################################### + +snippet pat "Case:Receive:Try Clause" +${1:pattern}${2: when ${3:guard}} ->; + ${4:body} +endsnippet + +snippet beh "Behaviour Directive" +-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" +-define (${1:macro}${2: (${3:param})}, ${4:body}). +endsnippet + +snippet exp "Export Directive" +-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" +-ifdef (${1:macro}). +endsnippet + +snippet ifndef "Ifndef Directive" +-ifndef (${1:macro}). +endsnippet + +snippet imp "Import Directive" +-import (${1:module}, [${2:function}/${3:arity}]). +endsnippet + +snippet inc "Include Directive" +-include ("${1:file}"). +endsnippet + +snippet mod "Module Directive" +-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" +-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" +-undef (${1:macro}). +endsnippet + +# vim:ft=snippets: diff --git a/UltiSnips/eruby.snippets b/UltiSnips/eruby.snippets new file mode 100644 index 0000000..1fdcfc1 --- /dev/null +++ b/UltiSnips/eruby.snippets @@ -0,0 +1,279 @@ +# 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 + + +########################################################################### +# 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" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`form_tag(${1::action => "${5:update}"}${6:, {:${8:class} => "${9: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 end "end (ERB)" +<% end -%> +endsnippet + +snippet for "for loop (ERB)" +<% if !${1:list}.blank? %> + <% for ${2:item} in ${1} %> + $3 + <% end %> +<% else %> + $4 +<% end %> + +endsnippet + +snippet ffcb "form_for check_box" +`!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 ffff "form_for file_field 2" +`!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 ffhf "form_for hidden_field 2" +`!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 ffl "form_for label 2" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR}f.label :${1:attribute', snip)`${2:, "${3:${1/[[:alpha:]]+|(_)/(?1: :\u$0)/g}}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet ffpf "form_for password_field 2" +`!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 ffrb "form_for radio_box 2" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.radio_box :${1:attribute}, :${2:tag_value}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet ffs "form_for submit 2" +`!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 ffta "form_for text_area 2" +`!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 fftf "form_for text_field 2" +`!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 fields "fields_for" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`fields_for :${1:model}, @${2:$1} do |$1|`!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_fields_for (nff)" +`!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" +`!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" +`!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" +`!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" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR}f.label :${1:attribute', snip)`${2:, "${3:${1/[[:alpha:]]+|(_)/(?1: :\u$0)/g}}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet f. "f.password_field" +`!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_box" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.radio_box :${1:attribute}, :${2:tag_value}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +endsnippet + +snippet f. "f.submit" +`!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" +`!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" +`!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" +`!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_INLINE', snip)`form_for @${2:$1} do |f|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_INLINE', snip)` + $0 +`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)` +endsnippet + +snippet ff "form_for" +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`form_for @${1:model} do |f|`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_INLINE', snip)` + $0 +`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)` +endsnippet + +snippet ist "image_submit_tag" +`!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" +`!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" +`!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 lia "link_to (action)" +`!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)" +`!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)" +`!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)" +`!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)" +`!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)" +`!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)" +`!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)" +`!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)" +`!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" +`!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" +`!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" +`!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 %> + +endsnippet + +snippet if "if (ERB)" +<% if ${1:condition} %>$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/UltiSnips/go.snippets b/UltiSnips/go.snippets new file mode 100644 index 0000000..ea46931 --- /dev/null +++ b/UltiSnips/go.snippets @@ -0,0 +1,107 @@ +# Snippets for Go + +# 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 + +# statements +snippet for "For loop" !b +for ${1:condition}${1/(.+)/ /}{ + ${0:${VISUAL}} +} +endsnippet + +snippet forr "For range loop" !b +for ${2:name} := range ${1:collection} { + ${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 + +snippet case "Case clause" !b +case ${1:condition}: + ${0:${VISUAL}} +endsnippet + +snippet default "Default clause" !b +default: + ${0:${VISUAL}} +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 + +# 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 + +# vim:ft=snippets: diff --git a/UltiSnips/haskell.snippets b/UltiSnips/haskell.snippets new file mode 100644 index 0000000..eb7b2c6 --- /dev/null +++ b/UltiSnips/haskell.snippets @@ -0,0 +1,61 @@ +snippet if "if ... then ... else ..." +if ${1:condition} + then ${2:expression} + else ${3:expression} +endsnippet + +snippet case "case ... of ..." +case ${1:expression} of + ${2:pattern} -> ${3:expression} + ${4:pattern} -> ${5:expression} +endsnippet + +snippet :: "Type signature" +${1:name} :: ${2:Type} -> ${3:Type} +endsnippet + +snippet => "Type constraint" +(${1:Class} ${2:Type var}) => ${3:$2} +endsnippet + +snippet def "Function definition" +${1:name} :: ${2:Type} -> ${3:Type} +endsnippet + +snippet def[] "Function definition for list patterns" +${1:name} :: [${2:Type}] -> ${3:Type} +$1 [] = ${4:undefined} +$1 ${5:(x:xs)} = ${6:undefined} +endsnippet + +snippet = "Function clause" +${1:name} ${2:pattern} = ${3:undefined} +endsnippet + +snippet 2= "Function clause" +${1:name} ${2:pattern} = ${3:undefined} +$1 ${4:pattern} = ${5:undefined} +endsnippet + +snippet 3= "Function clause" +${1:name} ${2:pattern} = ${3:undefined} +$1 ${4:pattern} = ${5:undefined} +$1 ${6:pattern} = ${7:undefined} +endsnippet + +snippet | "Guard" +| ${1:predicate} = ${2:undefined} +endsnippet + +snippet \ "Lambda expression" +\ ${1:pattern} -> ${2:expression} +endsnippet + +snippet [|] "List comprehension" +[${3:foo }$1 | ${1:x} <- ${2:xs} ] +endsnippet + +snippet let "let ... in ..." +let ${1:name} = ${2:expression} +in ${3:expression} +endsnippet diff --git a/UltiSnips/help.snippets b/UltiSnips/help.snippets new file mode 100644 index 0000000..bd0bb12 --- /dev/null +++ b/UltiSnips/help.snippets @@ -0,0 +1,30 @@ +# Snippets for VIM Help Files + +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 + +# vim:ft=snippets: diff --git a/UltiSnips/html.snippets b/UltiSnips/html.snippets new file mode 100644 index 0000000..bb07478 --- /dev/null +++ b/UltiSnips/html.snippets @@ -0,0 +1,297 @@ +########################################################################### +# 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 + + +endsnippet + +snippet doctype "DocType XHTML 1.0 Transitional" b + + +endsnippet + +snippet doctype "DocType XHTML 1.1" b + + +endsnippet + +snippet doctype "HTML - 4.0 Transitional (doctype)" b + + +endsnippet + +snippet doctype "HTML - 5.0 (doctype)" b + + +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" +$0 +endsnippet + +snippet ! "IE Conditional Comment: Internet Explorer 5_5 only" +$0 +endsnippet + +snippet ! "IE Conditional Comment: Internet Explorer 5_x" +$0 +endsnippet + +snippet ! "IE Conditional Comment: Internet Explorer 6 and below" +$0 +endsnippet + +snippet ! "IE Conditional Comment: Internet Explorer 6 only" +$0 +endsnippet + +snippet ! "IE Conditional Comment: Internet Explorer 7+" +$0 +endsnippet + +snippet ! "IE Conditional Comment: Internet Explorer" +$0 +endsnippet + +snippet ! "IE Conditional Comment: NOT Internet Explorer" +${1: IE Conditional Comment: NOT Internet Explorer }$0 +endsnippet + +############# +# HTML TAGS # +############# +snippet input "Input with Label" + + +endsnippet + +snippet input "XHTML " + +endsnippet + + +snippet opt "Option" +${3:$2} +endsnippet + +snippet select "Select Box" + +endsnippet + + +snippet textarea "XHTML +endsnippet + +snippet mailto "XHTML " +${3:email me} +endsnippet + +snippet base "XHTML " + +endsnippet + +snippet body "XHTML " + + $0 + +endsnippet + +snippet div "XHTML
" + + $0 +
+endsnippet + +snippet form "XHTML
" + + $0 + +

+
+endsnippet + +snippet h1 "XHTML

" +

${1}

+endsnippet + +snippet head "XHTML " + + + ${1:`!p snip.rv = snip.basename or "Page Title"`} + $0 + +endsnippet + +snippet link "XHTML " + +endsnippet + +snippet meta "XHTML " + +endsnippet + +snippet scriptsrc "XHTML +endsnippet + +snippet script "XHTML +endsnippet + +snippet style "XHTML +endsnippet + +snippet table "XHTML " +
+ + +
${5:Header}
${0:Data}
+endsnippet + +snippet a "Link" +${4:Anchor Text} +endsnippet + +snippet p "paragraph" +

$0

+endsnippet + +snippet li "list item" +
  • +endsnippet + +snippet ul "unordered list" +
      +$0 +
    +endsnippet + +snippet td "table cell" +$0 +endsnippet + +snippet tr "table row" +$0 +endsnippet + +snippet title "XHTML " +<title>${1:`!p snip.rv = snip.basename or "Page Title"`} +endsnippet + +snippet fieldset "Fieldset" +
    + $1 + + $0 +
    +endsnippet + +snippet movie "Embed QT movie (movie)" b + + + + + + +endsnippet + +snippet html5 "HTML5 Template" + + + + ${1} + + + +
    + ${2} +
    +
    + ${4} +
    + + +endsnippet +# vim:ft=snippets: diff --git a/UltiSnips/htmldjango.snippets b/UltiSnips/htmldjango.snippets new file mode 100644 index 0000000..9df5f78 --- /dev/null +++ b/UltiSnips/htmldjango.snippets @@ -0,0 +1 @@ +extends html, django diff --git a/UltiSnips/java.snippets b/UltiSnips/java.snippets new file mode 100644 index 0000000..6e1b3ff --- /dev/null +++ b/UltiSnips/java.snippets @@ -0,0 +1,212 @@ +########################################################################### +# TEXTMATE SNIPPETS # +########################################################################### + +# 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. + +global !p +def nl(snip): + if snip.opt("g:ultisnips_java_brace_style", "") == "nl": + snip += "" + else: + snip.rv += " " +endglobal + +snippet ab "abstract" b +abstract +endsnippet + +snippet as "assert" b +assert ${1:test}${2/(.+)/(?1: \: ")/}${2:Failure message}${2/(.+)/(?1:")/};$0 +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 cl "class" b +class ${1:`!p +snip.rv = snip.basename or "untitled"`} ${2:extends ${3:Parent} }${4:implements ${5:Interface} }{ + $0 +} +endsnippet + +snippet cos "constant string" b +static public final String ${1:var} = "$2";$0 +endsnippet + +snippet co "constant" b +static public final ${1:String} ${2:var} = $3;$0 +endsnippet + +snippet de "default" b +default: + $0 +endsnippet + +snippet elif "else if" b +else if ($1)`!p nl(snip)`{ + $0 +} +endsnippet + +snippet /el(se)?/ "else" br +else`!p nl(snip)`{ + $0 +} +endsnippet + +snippet fi "final" b +final +endsnippet + +snippet fore "for (each)" b +for ($1 : $2)`!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 +} +endsnippet + +snippet imt "import junit_framework_TestCase;" b +import junit.framework.TestCase; +$0 +endsnippet + +snippet im "import" b +import +endsnippet + +snippet in "interface" b +interface ${1:`!p snip.rv = snip.basename or "untitled"`} ${2:extends ${3:Parent} }{ + $0 +} +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 m "method" b +${1:void} ${2:method}($3) ${4:throws $5 }{ + $0 +} + +endsnippet + +snippet pa "package" b +package +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 +endsnippet + +snippet po "protected" b +protected +endsnippet + +snippet pu "public" b +public +endsnippet + +snippet re "return" b +return +endsnippet + +snippet st "static" +static +endsnippet + +snippet sw "switch" b +switch ($1)`!p nl(snip)`{ + $0 +} +endsnippet + +snippet sy "synchronized" +synchronized +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 +public void test${1:Name}() throws Exception`!p nl(snip)`{ + $0 +} +endsnippet + +snippet th "throw" b +throw $0 +endsnippet + +snippet v "variable" b +${1:String} ${2:var}${3: = ${0:null}}; +endsnippet + +snippet wh "while" b +while ($1)`!p nl(snip)`{ + $0 +} +endsnippet + +# vim:ft=snippets: diff --git a/UltiSnips/javascript.snippets b/UltiSnips/javascript.snippets new file mode 100644 index 0000000..e4e7f7a --- /dev/null +++ b/UltiSnips/javascript.snippets @@ -0,0 +1,65 @@ +########################################################################### +# 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){ + $0 +}${10:,} +endsnippet + +snippet :f "Object Method" +${1:method_name}: function(${3:attribute}){ + $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}) ,,{ + ${0:// body...} +}; + +endsnippet + +snippet for "for (...) {...} (faster)" +for (var ${2:i} = ${1:Things}.length - 1; $2 >= 0; $2--){ + ${3:$1[$2]}$0 +}; +endsnippet + +snippet for "for (...) {...}" +for (var ${2:i}=0; $2 < ${1:Things}.length; $2++) { + ${3:$1[$2]}$0 +}; +endsnippet + +snippet fun "function (fun)" +function ${1:function_name} (${2:argument}) { + ${0:// body...} +} +endsnippet + +snippet ife "if ___ else" +if (${1:true}) {$0} else{}; +endsnippet + +snippet if "if" +if (${1:true}) {$0}; +endsnippet + +snippet timeout "setTimeout function" +setTimeout(function() {$0}${2:}, ${1:10}); +endsnippet + +# vim:ft=snippets: diff --git a/UltiSnips/javascript_jasmine.snippets b/UltiSnips/javascript_jasmine.snippets new file mode 100644 index 0000000..49e38a3 --- /dev/null +++ b/UltiSnips/javascript_jasmine.snippets @@ -0,0 +1,168 @@ +# +# JavaScript versions -- from the TextMate bundle + some additions +# for jasmine-jquery matchers +# +extends javascript + +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 any "any (js)" b +jasmine.any($1) +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 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 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 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}').andReturn(${3:arguments}); +endsnippet + +snippet st "spy on and throw (js)" b +spyOn(${1:object}, '${2:method}').andThrow(${3:exception}); +endsnippet + +snippet sct "spy on and call through (js)" b +spyOn(${1:object}, '${2:method}').andCallThrough(); +endsnippet + +snippet scf "spy on and call fake (js)" b +spyOn(${1:object}, '${2:method}').andCallFake(${3:function}); +endsnippet + +snippet esc "expect was called (js)" b +expect(${1:target}).wasCalled(); +endsnippet + +snippet escw "expect was called with (js)" b +expect(${1:target}).wasCalledWith(${2:arguments}); +endsnippet + +snippet notsc "expect was not called (js)" b +expect(${1:target}).wasNotCalled(); +endsnippet + +snippet noscw "expect was not called with (js)" b +expect(${1:target}).wasNotCalledWith(${2:arguments}); +endsnippet + diff --git a/UltiSnips/jinja2.snippets b/UltiSnips/jinja2.snippets new file mode 100644 index 0000000..6fef6ed --- /dev/null +++ b/UltiSnips/jinja2.snippets @@ -0,0 +1,209 @@ + +# 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 " 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/UltiSnips/json.snippets b/UltiSnips/json.snippets new file mode 100644 index 0000000..81e6561 --- /dev/null +++ b/UltiSnips/json.snippets @@ -0,0 +1,19 @@ +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 o "Object" b +{ + ${VISUAL}$0 +}, +endsnippet + diff --git a/UltiSnips/lua.snippets b/UltiSnips/lua.snippets new file mode 100644 index 0000000..1b82a24 --- /dev/null +++ b/UltiSnips/lua.snippets @@ -0,0 +1,37 @@ +################################# +# 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 local "local x = 1" +local ${1:x} = ${0:1} +endsnippet + +# vim:ft=snippets: diff --git a/UltiSnips/mako.snippets b/UltiSnips/mako.snippets new file mode 100644 index 0000000..92a7be3 --- /dev/null +++ b/UltiSnips/mako.snippets @@ -0,0 +1,90 @@ +################# +# From snipmate # +################# +snippet def "definition" b +<%def name="${1:name}"> + ${2:} + +endsnippet + +snippet call "call" b +<%call expr="${1:name}"> + ${2:} + +endsnippet + +snippet doc "doc" b +<%doc> + ${1:} + +endsnippet + +snippet text "text" b +<%text> + ${1:} + +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 +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/UltiSnips/markdown.snippets b/UltiSnips/markdown.snippets new file mode 100644 index 0000000..c3189b8 --- /dev/null +++ b/UltiSnips/markdown.snippets @@ -0,0 +1,44 @@ +########################################################################### +# SNIPPETS for MARKDOWN # +########################################################################### + +########################### +# 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 + +# vim:ft=snippets: diff --git a/UltiSnips/objc.snippets b/UltiSnips/objc.snippets new file mode 100644 index 0000000..0c67664 --- /dev/null +++ b/UltiSnips/objc.snippets @@ -0,0 +1,270 @@ +########################################################################### +# 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" +{ + +} +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/UltiSnips/perl.snippets b/UltiSnips/perl.snippets new file mode 100644 index 0000000..6a9e8f9 --- /dev/null +++ b/UltiSnips/perl.snippets @@ -0,0 +1,127 @@ +########################################################################### +# 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/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 base 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" +eval { + ${1:# do something risky...} +}; +if ($@) { + ${2:# 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}; +{ local $/ = undef; local *FILE; open FILE, "<${2:file}"; $$1 = ; close FILE } + +endsnippet + +snippet unless "unless" +unless ($1) { + ${2:# body...} +} + +endsnippet + +snippet while "while" +while ($1) { + ${2:# body...} +} + +endsnippet + +# vim:ft=snippets: diff --git a/UltiSnips/php.snippets b/UltiSnips/php.snippets new file mode 100644 index 0000000..40461d2 --- /dev/null +++ b/UltiSnips/php.snippets @@ -0,0 +1,258 @@ +## Snippets from SnipMate, taken from +## https://github.com/scrooloose/snipmate-snippets.git + +snippet array "array" +$${1:arrayName} = array('${2}' => ${3});${4} +endsnippet + +snippet def "def" +define('${1}'${2});${3} +endsnippet + +snippet do "do" +do { + ${2:// code... } +} while (${1:/* condition */});" +endsnippet + +snippet doc_f "doc_f" +/** + * $2 + * @return ${4:void} + * @author ${5:`!v g:snips_author`} + **/ +${1:public }function ${2:someFunc}(${3}) +{${6} +} +endsnippet + +snippet doc_i "doc_i" +/** + * $1 + * @package ${2:default} + * @author ${3:`!v g:snips_author`} + **/ +interface ${1:someClass} +{${4} +} // END interface $1" +endsnippet + +snippet else "else" +else { + ${1:// code...} +} +endsnippet + +snippet for "for" +for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) { + ${4:// code...} +} +endsnippet + +snippet foreachk "foreachk" +foreach ($${1:variable} as $${2:key} => $${3:value}){ + ${4:// code...} +} +endsnippet + +snippet get "get" +$_GET['${1}']${2} +endsnippet + +snippet if "if" +if (${1:/* condition */}) { + ${2:// code...} +} +endsnippet + +snippet inc "inc" +include '${1:file}';${2} +endsnippet + +snippet log "log" +error_log(var_export(${1}, true));${2} +endsnippet + +snippet post "post" +$_POST['${1}']${2} +endsnippet + +snippet req1 "req1" +require_once '${1:file}';${2} +endsnippet + +snippet session "session" +$_SESSION['${1}']${2} +endsnippet + +snippet t "t" +$${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b};${5} +endsnippet + +snippet var "var" +var_export(${1});${2} +endsnippet + +snippet getter "PHP Class Getter" !b +/* + * Getter for $1 + */ +public function get${1/\w+\s*/\u$0/}() +{ + return $this->$1;$2 +} +$4 +endsnippet + +snippet setter "PHP Class Setter" !b +/* + * Setter for $1 + */ +public function set${1/\w+\s*/\u$0/}($$1) +{ + $this->$1 = $$1;$3 + ${4:return $this;} +} +$0 +endsnippet + +snippet gs "PHP Class Getter Setter" !b +protected $$1 + +/* + * Getter for $1 + */ +public function get${1/\w+\s*/\u$0/}() +{ + return $this->$1;$2 +} + +/* + * Setter for $1 + */ +public function set${1/\w+\s*/\u$0/}($$1) +{ + $this->$1 = $$1;$3 + ${4:return $this;} +} +$0 +endsnippet + +snippet pub "Public function" !b +public function ${1:name}(${2:$param}) +{ + ${VISUAL}${3:return null;} +} +$0 +endsnippet + +snippet pro "Protected function" !b +protected function ${1:name}(${2:$param}) +{ + ${VISUAL}${3:return null;} +} +$0 +endsnippet + +snippet pri "Private function" !b +private function ${1:name}(${2:$param}) +{ + ${VISUAL}${3:return null;} +} +$0 +endsnippet + +snippet pubs "Public static function" !b +public static function ${1:name}(${2:$param}) +{ + ${VISUAL}${3:return null;} +} +$0 +endsnippet + +snippet pros "Protected static function" !b +protected static function ${1:name}(${2:$param}) +{ + ${VISUAL}${3:return null;} +} +$0 +endsnippet + +snippet pris "Private static function" !b +private static function ${1:name}(${2:$param}) +{ + ${VISUAL}${3:return null;} +} +$0 +endsnippet + +snippet fu "Function snip" !b +function ${1:name}(${2:$param}) +{ + ${VISUAL}${3:return null;} +} +$0 +endsnippet +# :vim:ft=snippets + +snippet fore "Foreach loop" +foreach ($${1:variable} as $${3:value}){ + ${VISUAL}${4} +} +$0 +endsnippet + +snippet new "New class instance" !b +$$1 = new $1($2); +$0 +endsnippet + + +snippet ife "if else" +if (${1:/* condition */}) { + ${2:// code...} +} else { + ${3:// code...} +} +$0 +endsnippet + + +snippet class "Class declaration template" !b +/** + * Class ${1:`!p snip.rv=snip.fn.capitalize().split('.')[0]`} + * @author $2 + */ +class $1 +{ + public function ${3:__construct}(${4:$options}) + { + ${4:// code} + } +} +$0 +endsnippet + +snippet pr "Dumb debug helper in HTML" +echo '
    ' . var_export($1, 1) . '
    ';$0 +endsnippet + +snippet pc "Dumb debug helper in cli" +var_export($1);$0 +endsnippet + +# Symfony 2 based snippets +snippet sfa "Symfony 2 Controller action" +/** +* @Route("/${1:route_name}", name="$1") +* @Template() +*/ +public function $1Action($2) +{ + $3 + return ${4:array();}$0 +} +endsnippet + +# :vim:ft=snippets: + diff --git a/UltiSnips/puppet.snippets b/UltiSnips/puppet.snippets new file mode 100644 index 0000000..68ae0fe --- /dev/null +++ b/UltiSnips/puppet.snippets @@ -0,0 +1,78 @@ +# Snippets for Puppet + +snippet /^class/ "Class declaration" r +class ${1:name} { + ${0:# body} +} +endsnippet + +snippet File "Defaults for file" b +File { + owner => ${1:username}, + group => ${2:groupname}, +} +endsnippet + +# Resource types +snippet package "Package resource type" b +package { "${1:name}": + ensure => ${2:installed}, +} +endsnippet + +snippet file "File resource type" b +file { "${1:name}": + source => "puppet://${2:path}", + mode => ${3:mode}, +endsnippet + +snippet group "Group resource type" b +group { "${1:groupname}": + ensure => ${3:present}, + gid => ${2:gid}, +endsnippet + +snippet user "user resource type" b +group { "${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 exec "Exec resource type" b +exec { "${1:command}": + refreshonly => true, +} +endsnippet + +snippet cron "Cron resource type" b +cron { "${1:name}": + user => ${2:user}, + command => "${3:command}", + minute => ${3:minute}, + hour => ${4:hour}, +} +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 service "Service resource type" b +service { "${1:name}": + hasstatus => true, + enable => true, + ensure => running, +} +endsnippet + +# vim:ft=snippets: diff --git a/UltiSnips/python.snippets b/UltiSnips/python.snippets new file mode 100644 index 0000000..a770d2a --- /dev/null +++ b/UltiSnips/python.snippets @@ -0,0 +1,468 @@ +########################################################################### +# TEXTMATE SNIPPETS # +########################################################################### + +#! header +snippet #! "Shebang header for python scripts" b +#!/usr/bin/env python +# encoding: utf-8 +$0 +endsnippet + +snippet ifmain "ifmain" b +if __name__ == '__main__': + ${1:main()}$0 +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 + +def get_args(arglist): + args = [arg.split('=')[0].strip() for arg in arglist.split(',') if arg] + args = [arg for arg in args if arg and arg != "self"] + + return args + + +def get_style(snip): + style = snip.opt("g:ultisnips_python_style", "normal") + + if style == "doxygen": return DOXYGEN + elif style == "sphinx": return SPHINX + 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 + + +def format_return(style): + if style == DOXYGEN: + return "@return: @todo" + elif style in (NORMAL, SPHINX): + return ":returns: @todo" + + +def write_docstring_args(args, snip): + if not args: + snip.rv += ' """' + return + + snip.rv += '\n' + snip.mkline('', indent='') + + style = get_style(snip) + + for arg in args: + snip += format_arg(arg, style) + + +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) + +endglobal + +######################################## +# Class & Special Method Name Snippets # +######################################## + +snippet class "class with docstrings" b +class ${1:MyClass}(${2:object}): + """${3:Docstring for $1 }""" + + def __init__(self$4): + """${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 += '"""' + +write_init_body(args, t[2], snip) +` + $0 +endsnippet + + +snippet slotclass "class with slots and docstrings" b +class ${1:MyClass}(${2:object}): + """${3:Docstring for $1 }""" +`!p +snip >> 1 +args = get_args(t[4]) +write_slots_args(args, snip) +` + + def __init__(self$4): + """${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 += '"""' + +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}): + """${4:@todo: Docstring for $1}`!p +snip.rv = "" +snip >> 1 + +args = get_args(t[2]) +if args: + write_docstring_args(args, snip) + +style = get_style(snip) +snip += format_return(style) +snip.rv += '\n' + snip.mkline('', indent='') +snip += '"""' ` + ${0: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:property}(self): + ${2:return self._$1}$0 +endsnippet + +snippet rwprop "Read write property" b +def ${1:property}(): + ${2/.+/(?0:""")/}${2:The RW property $1}`!p if t[2]: + snip.rv += '"""' + snip >> 1 + snip += "" +else: + snip.rv = ""`def fget(self): + return self._$1$0 + def fset(self, value): + self._$1 = value + return locals() +$1 = property(**$1()) +endsnippet + + +########################## +# Try / Except / Finally # +########################## +snippet try "Try / Except" b +try: + ${1:pass} +except ${2:Exception}, ${3:e}: + ${4:raise $3} +endsnippet + +snippet try "Try / Except / Else" b +try: + ${1:pass} +except ${2:Exception}, ${3:e}: + ${4:raise $3} +else: + ${5:pass} +endsnippet + +snippet try "Try / Except / Finally" b +try: + ${1:pass} +except ${2:Exception}, ${3:e}: + ${4:raise $3} +finally: + ${5:pass} +endsnippet + +snippet try "Try / Except / Else / Finally" b +try: + ${1:pass} +except${2: ${3:Exception}, ${4:e}}: + ${5:raise} +else: + ${6:pass} +finally: + ${7:pass} +endsnippet + + +##################### +# Assertions & Tests # +##################### + +snippet pdb "Set PDB breakpoint" b +import pdb; pdb.set_trace() +endsnippet + +snippet ae "Assert equal" b +self.assertEqual(${1:first},${2:second}) +endsnippet + +snippet at "Assert True" b +self.assertTrue(${0:exp}) +endsnippet + +snippet af "Assert False" b +self.assertFalse(${1:expression}) +endsnippet + +snippet aae "Assert almost equal" b +self.assertAlmostEqual(${1:first},${2:second}) +endsnippet + +snippet ar "Assert raises" b +self.assertRaises(${1:exception}, ${2:func}${3/.+/, /}${3:arguments}) +endsnippet + + +snippet testcase "pyunit testcase" b +class Test${1:Class}(${2:unittest.TestCase}): + """${3:Test case docstring}""" + + def setUp(self): + ${4:pass} + + def tearDown(self): + ${5:pass} + + def test_${6:name}(self): + ${7:pass} +endsnippet + +# vim:ft=snippets: diff --git a/UltiSnips/rails.snippets b/UltiSnips/rails.snippets new file mode 100644 index 0000000..9e0e29f --- /dev/null +++ b/UltiSnips/rails.snippets @@ -0,0 +1,906 @@ +########################################################################### +# GENERATED FROM get_tm_snippets.py # +########################################################################### + +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 cla "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 cla "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_attributes(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 +endsnippet + +snippet aftd "after_destroy" +after_destroy +endsnippet + +snippet afts "after_save" +after_save +endsnippet + +snippet aftu "after_update" +after_update +endsnippet + +snippet aftv "after_validation" +after_validation +endsnippet + +snippet aftvoc "after_validation_on_create" +after_validation_on_create +endsnippet + +snippet aftvou "after_validation_on_update" +after_validation_on_update +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 +endsnippet + +snippet befd "before_destroy" +before_destroy +endsnippet + +snippet befs "before_save" +before_save +endsnippet + +snippet befu "before_update" +before_update +endsnippet + +snippet befv "before_validation" +before_validation +endsnippet + +snippet befvoc "before_validation_on_create" +before_validation_on_create +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 + +snippet resw "respond_with" +respond_with(${1:@${2:model}})${3: do |format| + format.${4:html} { $0 \} +end} +endsnippet + +# FIXME +snippet returning "returning do |variable| ... end" +returning ${1:variable} do${2/(^(?\s*[a-z_][a-zA-Z0-9_]*\s*)(,\g)*,?\s*$)|.*/(?1: |)/}${2:v}${2/(^(?\s*[a-z_][a-zA-Z0-9_]*\s*)(,\g)*,?\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 finl "find(:last)" +find(:last${1:, :conditions => ['${2:${3:field} = ?}', ${5:true}]}) +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/UltiSnips/rst.snippets b/UltiSnips/rst.snippets new file mode 100644 index 0000000..7174510 --- /dev/null +++ b/UltiSnips/rst.snippets @@ -0,0 +1,61 @@ + + +########################################################################### +# General Stuff # +########################################################################### +snippet part "Part" b +`!p snip.rv = len(t[1])*'#'` +${1:Part name} +`!p snip.rv = len(t[1])*'#'` + +$0 +endsnippet + +snippet sec "Section" b +${1:Section name} +`!p snip.rv = len(t[1])*'='` + +$0 +endsnippet + +snippet ssec "Subsection" b +${1:Section name} +`!p snip.rv = len(t[1])*'-'` + +$0 +endsnippet + +snippet sssec "Subsubsection" b +${1:Section name} +`!p snip.rv = len(t[1])*'^'` + +$0 +endsnippet + +snippet chap "Chapter" b +`!p snip.rv = len(t[1])*'*'` +${1:Chapter name} +`!p snip.rv = len(t[1])*'*'` + +$0 +endsnippet + +snippet para "Paragraph" b +${1:Paragraph name} +`!p snip.rv = len(t[1])*'"'` + +$0 +endsnippet + +########################################################################### +# More Specialized Stuff. # +########################################################################### +snippet cb "Code Block" b +.. code-block:: ${1:lua} + + ${2:code} + +$0 +endsnippet + +# vim:ft=snippets: diff --git a/UltiSnips/ruby.snippets b/UltiSnips/ruby.snippets new file mode 100644 index 0000000..6336589 --- /dev/null +++ b/UltiSnips/ruby.snippets @@ -0,0 +1,568 @@ +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 If " if " +${1:command} if ${0:expression} +endsnippet + + + +snippet Unless " unless " +${1:command} unless ${0:expression} +endsnippet + + + +snippet if "if ... end" +if ${1:condition} + ${2:# TODO} +end +endsnippet + + + +snippet ife "if ... else ... end" +if ${1:condition} + ${2:# TODO} +else + ${3:# TODO} +end +endsnippet + + + +snippet ifee "if ... elseif ... else ... end" +if ${1:condition} + ${2:# TODO} +elsif ${3:condition} + ${4:# TODO} +else + ${0:# TODO} +end +endsnippet + + + +snippet unless "unless ... end" +unless ${1:condition} + ${0:# TODO} +end +endsnippet + + + +snippet unlesse "unless ... else ... end" +unless ${1:condition} + ${2:# TODO} +else + ${0:# TODO} +end +endsnippet + + + +snippet unlesee "unless ... elseif ... else ... end" +unless ${1:condition} + ${2:# TODO} +elsif ${3:condition} + ${4:# TODO} +else + ${0:# TODO} +end +endsnippet + + + +snippet "\b(de)?f" "def ..." r +def ${1:function_name}${2: ${3:*args}} + ${0:# TODO} +end +endsnippet + + + +snippet defi "def initialize ..." +def initialize${1: ${2:*args}} + ${0:# TODO} +end +endsnippet + + + +snippet defr "def ... rescue ..." +def ${1:function_name}${2: ${3:*args}} + ${4:# TODO} +rescue + ${0:# TODO} +end +endsnippet + + + +snippet For "(..).each { || }" +(${1:from}..${2:to}).each { |${3:i}| ${4:# TODO} } +endsnippet + + + +snippet for "(..).each do || end" +(${1:from}..${2:to}).each do |${3:i}| + ${0:# TODO} +end +endsnippet + + + +snippet "(\S+)\.Merge!" ".merge!() { |,,| }" r +`!p snip.rv=match.group(1)`.merge!(${1:other_hash}) { |${2:key},${3:oldval},${4:newval}| ${5:block} } +endsnippet + + + +snippet "(\S+)\.merge!" ".merge!() do |,,| 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 { |,| }" r +`!p snip.rv=match.group(1)`.delete_if { |${1:key},${2:value}| ${3:# TODO} } +endsnippet + + + +snippet "(\S+)\.del(ete)?_?if" ".delete_if do |,| end" r +`!p snip.rv=match.group(1)`.delete_if do |${1:key},${2:value}| + ${0:# TODO} +end +endsnippet + + + +snippet "(\S+)\.Keep_?if" ".keep_if { |,| }" r +`!p snip.rv=match.group(1)`.keep_if { |${1:key},${2:value}| ${3:# TODO} } +endsnippet + + + +snippet "(\S+)\.keep_?if" ".keep_if do ,| end" r +`!p snip.rv=match.group(1)`.keep_if do |${1:key},${2:value}| + ${0:# TODO} +end +endsnippet + + + +snippet "(\S+)\.Reject" ".reject { |,| }" r +`!p snip.rv=match.group(1)`.reject { |${1:key},${2:value}| ${3:# TODO} } +endsnippet + + + +snippet "(\S+)\.reject" ".reject do ,| end" r +`!p snip.rv=match.group(1)`.reject do |${1:key},${2:value}| + ${0:# TODO} +end +endsnippet + + + +snippet "(\S+)\.Select" ".select { || }" r +`!p snip.rv=match.group(1)`.select { |${1:item}| ${2:block} } +endsnippet + + + +snippet "(\S+)\.select" ".select do || end" r +`!p snip.rv=match.group(1)`.select do |${1:item}| + ${0:block} +end +endsnippet + + + +snippet "(\S+)\.Sort" ".sort { |
    ,| }" r +`!p snip.rv=match.group(1)`.sort { |${1:a},${2:b}| ${3:# TODO} } +endsnippet + + + +snippet "(\S+)\.sort" ".sort do |,| end" r +`!p snip.rv=match.group(1)`.sort do |${1:a},${2:b}| + ${0:# TODO} +end +endsnippet + + + +snippet "(\S+)\.Each_?k(ey)?" ".each_key { || }" r +`!p snip.rv=match.group(1)`.each_key { |${1:key}| ${2:# TODO} } +endsnippet + + + +snippet "(\S+)\.each_?k(ey)?" ".each_key do |key| end" r +`!p snip.rv=match.group(1)`.each_key do |${1:key}| + ${0:# TODO} +end +endsnippet + + + +snippet "(\S+)\.Each_?val(ue)?" ".each_value { || }" r +`!p snip.rv=match.group(1)`.each_value { |${1:value}| ${2:# TODO} } +endsnippet + + + +snippet "(\S+)\.each_?val(ue)?" ".each_value do || end" r +`!p snip.rv=match.group(1)`.each_value do |${1:value}| + ${0:# TODO} +end +endsnippet + + + +snippet Each ".each { || }" +${1:elements}.each { |${2:${1/s$//}}| ${3:# TODO} } +endsnippet + + + +snippet each ".each do || end" +${1:elements}.each do |${2:${1/s$//}}| + ${0:# TODO} +end +endsnippet + + + +snippet each_?s(lice)? ".each_slice(n) do |slice| end" +each_slice(${1:2}) do |${2:slice}| + ${0:# TODO} +end +endsnippet + + + +snippet Each_?s(lice)? ".each_slice(n) { |slice| }" +each_slice(${1:2}) { |${2:slice}| ${3:# TODO} } +endsnippet + + + + +snippet "(\S+)\.Map" ".map { || }" 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' +`}| ${2:# TODO} } +endsnippet + + + +snippet "(\S+)\.map" ".map do || 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:# TODO} +end +endsnippet + + + +snippet "(\S+)\.Rev(erse)?_?each" ".reverse_each { || }" 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' +`}| ${2:# TODO} } +endsnippet + + + +snippet "(\S+)\.rev(erse)?_?each" ".reverse_each do || 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:# TODO} +end +endsnippet + + + +snippet "(\S+)\.Each" ".each { || }" 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' +`}| ${2:# TODO} } +endsnippet + + + +snippet "(\S+)\.each" ".each do || 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:# TODO} +end +endsnippet + + + + +snippet "(\S+)\.Each_w(ith)?_?i(ndex)?" ".each_with_index { |,| }" 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}| ${3:# TODO} }$0 +endsnippet + + + +snippet "(\S+)\.each_?w(ith)?_?i(ndex)?" ".each_with_index do |,| 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:# TODO} +end +endsnippet + + + + +snippet "(\S+)\.Each_?p(air)?" ".each_pair { |,| }" r +`!p snip.rv=match.group(1)`.each_pair { |${1:key},${2:value}| ${3:# TODO} } +endsnippet + + + +snippet "(\S+)\.each_?p(air)?" ".each_pair do |,| end" r +`!p snip.rv=match.group(1)`.each_pair do |${1:key},${2:value}| + ${0:# TODO} +end +endsnippet + + + +snippet "(\S+)\.sub" ".sub() { }" r +`!p snip.rv=match.group(1)`.sub(${1:expression}) { ${2:"replace_with"} } +endsnippet + + + +snippet "(\S+)\.gsub" ".gsub() { }" r +`!p snip.rv=match.group(1)`.gsub(${1:expression}) { ${2:"replace_with"} } +endsnippet + + + +snippet "(\S+)\.index" ".index { |item| }" 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 do "do || ... end" i +do ${1:|${2:key}|} + $0 +end +endsnippet + + + +snippet Do "do ... end" i +do + $0 +end +endsnippet + + +snippet until "until ... end" +until ${1:expression} + ${0:# TODO} +end +endsnippet + + + +snippet Until "begin ... end until " +begin + ${0:# TODO} +end until ${1:expression} +endsnippet + + + +snippet while "while ... end" +while ${1:expression} + ${0:# TODO} +end +endsnippet + + + +snippet While "begin ... end while " +begin + ${0:# TODO} +end while ${1:expression} +endsnippet + + + +snippet "\b(r|attr)" "attr_reader :" r +attr_reader :${0:attr_names} +endsnippet + + + +snippet "\b(w|attr)" "attr_writer :" r +attr_writer :${0:attr_names} +endsnippet + + + +snippet "\b(rw|attr)" "attr_accessor :" r +attr_accessor :${0:attr_names} +endsnippet + + + +snippet begin "begin ... rescue ... end" +begin + ${1:# TODO} +rescue + ${0:# TODO} +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 when ... end" r +case ${1:variable} +when ${2:expression} +$0 +end +endsnippet + + + +snippet alias "alias : :" +alias :${1:new_name} :${2:old_name} +endsnippet + + + +snippet class "class 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/UltiSnips/sh.snippets b/UltiSnips/sh.snippets new file mode 100644 index 0000000..915c0df --- /dev/null +++ b/UltiSnips/sh.snippets @@ -0,0 +1,88 @@ +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", "sh", "kornshell"]: + if testShell(scope, shell) == "1": + if shell == "kornshell": + return "ksh" + 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 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/UltiSnips/snippets.snippets b/UltiSnips/snippets.snippets new file mode 100644 index 0000000..414f350 --- /dev/null +++ b/UltiSnips/snippets.snippets @@ -0,0 +1,23 @@ +######################### +# SNIPPETS for SNIPPETS # +######################### + +# We use a little hack so that the snippet is expanded +# and parsed correctly +snippet snip "Snippet definition" ! +`!p snip.rv = "snippet"` ${1:Tab_trigger} "${2:Description}" ${3:!b} +$0 +`!p snip.rv = "endsnippet"` +endsnippet + +snippet global "Global snippet" ! +`!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/UltiSnips/tcl.snippets b/UltiSnips/tcl.snippets new file mode 100644 index 0000000..2cb1f34 --- /dev/null +++ b/UltiSnips/tcl.snippets @@ -0,0 +1,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/UltiSnips/tex.snippets b/UltiSnips/tex.snippets new file mode 100644 index 0000000..d6e62fc --- /dev/null +++ b/UltiSnips/tex.snippets @@ -0,0 +1,125 @@ +extends texmath + +########################################################################### +# LATEX SNIPPETS # +########################################################################### + +snippet r "\ref{}" w +\ref{$1} +endsnippet + +########################################################################### +# TEXTMATE SNIPPETS # +########################################################################### + +################# +# GENERAL STUFF # +################# +snippet "b(egin)?" "begin{} / end{}" br +\begin{${1:something}} + ${0:${VISUAL}} +\end{$1} +endsnippet + +#################### +# TABULARS, ARRAYS # +#################### + +snippet tab +\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 + +######################## +# ENUM, DESCR, ITEMIZE # +######################## +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 + +##################################### +# SECTIONS, CHAPTERS AND THERE LIKE # +##################################### + +snippet part "Part" b +\part{${1:part name}} +\label{prt:${2:${1/(\w+)|\W+/(?1:\L$0\E:_)/g}}} + +${0} + +% part $2 (end) +endsnippet + +snippet cha "Chapter" b +\chapter{${1:chapter name}} +\label{cha:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/g}}} + +${0} + +% chapter $2 (end) +endsnippet + +snippet sec "Section" b +\section{${1:section name}} +\label{sec:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/g}}} + +${0} + +% section $2 (end) +endsnippet + + +snippet sub "Subsection" b +\subsection{${1:subsection name}} +\label{sub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/g}}} + +${0} + +% subsection $2 (end) +endsnippet + +snippet ssub "Subsubsection" b +\subsubsection{${1:subsubsection name}} +\label{ssub:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/g}}} + +${0} + +% subsubsection $2 (end) + +endsnippet + +snippet par "Paragraph" b +\paragraph{${1:paragraph name}} +\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/g}}} + +${0} + +% paragraph $2 (end) +endsnippet + + +snippet subp "Subparagraph" b +\subparagraph{${1:subparagraph name}} +\label{par:${2:${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|([^\w\\]+)/(?4:_:\L$1$2$3\E)/g}}} + +${0} + +% subparagraph $2 (end) +endsnippet + +# vim:ft=snippets: diff --git a/UltiSnips/texmath.snippets b/UltiSnips/texmath.snippets new file mode 100644 index 0000000..03589f0 --- /dev/null +++ b/UltiSnips/texmath.snippets @@ -0,0 +1,54 @@ +############## +# 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/UltiSnips/vim.snippets b/UltiSnips/vim.snippets new file mode 100644 index 0000000..f4c37f0 --- /dev/null +++ b/UltiSnips/vim.snippets @@ -0,0 +1,58 @@ +########################################################################### +# SnipMate Snippets # +########################################################################### +snippet header +" File: ${1:`!v expand('%:t')`} +" Author: ${2:`!v g:snips_author`} +" Description: ${3} +${4:" Last Modified: `!v strftime("%B %d, %Y")`} + +$0 +endsnippet + +snippet gvar "Global / configuration variable" +if !exists("g:${1:MyUltraImportantVar}") + let g:$1 = ${2:"${3:}"} +endif +endsnippet + +snippet guard +if exists('${1:did_`!p snip.rv = snip.fn.replace('.','_')`}') || &cp${2: || version < 700} + finish +endif +let $1 = 1${3} +endsnippet + +snippet f +fun ${1:function_name}(${2}) + ${3:" code} +endf +endsnippet + +snippet for +for ${1:needle} in ${2:haystack} + ${3:" code} +endfor +endsnippet + +snippet wh +while ${1:condition} + ${2:" code} +endw +endsnippet + +snippet if +if ${1:condition} + ${2:" code} +endif +endsnippet + +snippet ife +if ${1:condition} + ${2} +else + ${3} +endif +endsnippet + +# vim:ft=snippets: diff --git a/UltiSnips/xhtml.snippets b/UltiSnips/xhtml.snippets new file mode 100644 index 0000000..cc31dbc --- /dev/null +++ b/UltiSnips/xhtml.snippets @@ -0,0 +1 @@ +extends html diff --git a/UltiSnips/zsh.snippets b/UltiSnips/zsh.snippets new file mode 100644 index 0000000..18a2989 --- /dev/null +++ b/UltiSnips/zsh.snippets @@ -0,0 +1,13 @@ +extends sh + +snippet #! "shebang" ! +#!/bin/zsh + +endsnippet + +snippet !env "#!/usr/bin/env (!env)" ! +#!/usr/bin/env zsh + +endsnippet + +# vim:ft=snippets: