Skip to content

Commit

Permalink
Updated ultisnips and fixed ruby folding
Browse files Browse the repository at this point in the history
  • Loading branch information
duckpuppy committed Jun 4, 2012
1 parent 87dec0c commit 0e136be
Show file tree
Hide file tree
Showing 62 changed files with 5,830 additions and 4,060 deletions.
137 changes: 76 additions & 61 deletions vim/bundle/ultisnips/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,75 +1,90 @@
- Support for ${VISUAL}. *UltiSnips-visual-placeholder*
version 2.1:
- Python interpolation access to text from visual selection via snip.v.
- Support for transformations of ${VISUAL} texts.
- New or improved snippets: python, tex, texmath, ruby, rails, html, django

version 2.0:
- Backwards incompatible change: Support for normal mode editing. Snippets
are no longer exited when leaving insert mode but only by leaving the
text span of the snippets. This allows usage of normal mode commands and
autoformatting. It also increases compatibility with other plugins.
- Backwards incompatible change: Changed glob patterns for snippets to
behave more like Vim *UltiSnips-adding-snippets*
- Backwards incompatible change: Zero Tabstop is no longer removed in
nested snippets
- Support for ${VISUAL:default text} placeholder. *UltiSnips-visual-placeholder*
- Improved handling of utf-8 characters in files and snippet definitions.
- Full support for :py3. UltiSnips now truly works with python >= 2.6.
- Full support for :py3. UltiSnips now works with python >= 2.6 or >= 3.2.
- New or improved snippets: python, all

version 1.6:
- Significant speed improvements and a few bugs fixed.
- Better handling of non ASCII chars in snippets by assuming UTF-8 encoding
when no other information is available.
- Contributions for UltiSnips are now also accepted on GitHub: https://github.com/SirVer/ultisnips/
- New or improved snippets: ruby, rails, xhtml
- Significant speed improvements and a few bugs fixed.
- Better handling of non ASCII chars in snippets by assuming UTF-8 encoding
when no other information is available.
- Contributions for UltiSnips are now also accepted on GitHub: https://github.com/SirVer/ultisnips/
- New or improved snippets: ruby, rails, xhtml

version 1.5:
- Some critical bug fixes for new vim versions.
- New or improved snippets: tex, texmath, python, jinja2, go, puppet, xhtml
- Configuration of search path for snippets *UltiSnips-snippet-search-path*
- New parser implementation: A little faster, more flexible and less bugged.
- Some critical bug fixes for new vim versions.
- New or improved snippets: tex, texmath, python, jinja2, go, puppet, xhtml
- Configuration of search path for snippets *UltiSnips-snippet-search-path*
- New parser implementation: A little faster, more flexible and less bugged.

version 1.4:
- New or improved snippets: php, html, djangohtml, mako, lua
- Snippets are now listed alphabetically by their trigger, no longer in
order of appearance
- Snippet files are now automatically reloaded when they change.
- Support for other directory names for snippets beside
"UltiSnips" *UltiSnips-snippet-search-path*
- Errors are now shown in a scratch window.
- Now fully supports Windows with python >= 2.6. UltiSnips should now work
on all systems that Vim runs on.
- a syntax file was added for snippets files with nice highlighting.
- snippets definition files now have the filetype 'snippets'. It used to be
'snippet'.
- New or improved snippets: php, html, djangohtml, mako, lua
- Snippets are now listed alphabetically by their trigger, no longer in
order of appearance
- Snippet files are now automatically reloaded when they change.
- Support for other directory names for snippets beside
"UltiSnips" *UltiSnips-snippet-search-path*
- Errors are now shown in a scratch window.
- Now fully supports Windows with python >= 2.6. UltiSnips should now work
on all systems that Vim runs on.
- a syntax file was added for snippets files with nice highlighting.
- snippets definition files now have the filetype 'snippets'. It used to be
'snippet'.

version 1.3:
- Erlang snippets (g0rdin)
- Other VimScripts can now define and immediately expand anonymous snippets
( *UltiSnips_Anon* ) (Ryan Wooden)
- Other VimScripts can now define new snippets via a function
( *UltiSnips_AddSnippet* ) (Ryan Wooden)
- New Snippets for eruby and rails (Ches Martin).
- A new Option 't' has been added to snippets that avoid expanding tabstops.
Be also more consistent with how indenting is handled. (Ryan Wooden)
- Added a ftplugin script for .snippets files. Syntax highlighting still
missing. (Rupa Deadwyler)
- Added UltiSnipsReset and UltiSnipsEdit (Idea by JCEB)
- Erlang snippets (g0rdin)
- Other VimScripts can now define and immediately expand anonymous snippets
( *UltiSnips_Anon* ) (Ryan Wooden)
- Other VimScripts can now define new snippets via a function
( *UltiSnips_AddSnippet* ) (Ryan Wooden)
- New Snippets for eruby and rails (Ches Martin).
- A new Option 't' has been added to snippets that avoid expanding tabstops.
Be also more consistent with how indenting is handled. (Ryan Wooden)
- Added a ftplugin script for .snippets files. Syntax highlighting still
missing. (Rupa Deadwyler)
- Added UltiSnipsReset and UltiSnipsEdit (Idea by JCEB)

version 1.2:
- many bugs were fixed
- smode mappings for printable characters are now removed before expanding a
snippet. This is configurable. *UltiSnips-warning-smappings*
- all shipped snippets are now fully compatible with UltiSnips
- added support for global snippets which enhance python interpolation even
more *UltiSnips-globals*
- added support for multi word and regular expression triggers. Very
powerful in combination with python interpolation.
- Python interpolation became much more powerful *UltiSnips-python*
- added support for clearsnippets command *UltiSnips-clearing-snippets*
- added support for option w which is a little more strict than i.
- added support for listing of valid triggers. Defaults to <c-tab>.
- added support for option i (inword expansion)
- extends keyword is now supported on the first line of snippet files. This makes it easy to
define special cases, for example cpp extends c: a cpp trigger is useless
in c, but a c trigger is valuable for cpp.
- UltiSnips now adheres to expandtab and tabstop options of vim
- many bugs were fixed
- smode mappings for printable characters are now removed before expanding a
snippet. This is configurable. *UltiSnips-warning-smappings*
- all shipped snippets are now fully compatible with UltiSnips
- added support for global snippets which enhance python interpolation even
more *UltiSnips-globals*
- added support for multi word and regular expression triggers. Very
powerful in combination with python interpolation.
- Python interpolation became much more powerful *UltiSnips-python*
- added support for clearsnippets command *UltiSnips-clearing-snippets*
- added support for option w which is a little more strict than i.
- added support for listing of valid triggers. Defaults to <c-tab>.
- added support for option i (inword expansion)
- extends keyword is now supported on the first line of snippet files. This makes it easy to
define special cases, for example cpp extends c: a cpp trigger is useless
in c, but a c trigger is valuable for cpp.
- UltiSnips now adheres to expandtab and tabstop options of vim

version 1.1:
- Made triggers configurable. You can also use the same trigger for
expanding and tabbing. The TextMate configuration <tab> and <s-tab> is now
possible.
- Conditional Inserts can now be nested
- Added support for b option. This only considers a snippet at the beginning
of a line ( *UltiSnips-adding-snippets* )
- Added support for ! option. This overwrites previously defined snippets
with the same tab trigger ( *UltiSnips-adding-snippets* )
- Support for dotted filetype syntax. Now snippets for more than one filetype
can be active ( *UltiSnips-adding-snippets* )
- Made triggers configurable. You can also use the same trigger for
expanding and tabbing. The TextMate configuration <tab> and <s-tab> is now
possible.
- Conditional Inserts can now be nested
- Added support for b option. This only considers a snippet at the beginning
of a line ( *UltiSnips-adding-snippets* )
- Added support for ! option. This overwrites previously defined snippets
with the same tab trigger ( *UltiSnips-adding-snippets* )
- Support for dotted filetype syntax. Now snippets for more than one filetype
can be active ( *UltiSnips-adding-snippets* )

4 changes: 4 additions & 0 deletions vim/bundle/ultisnips/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ discussed in the video.

* `Episode 1: What are snippets and do I need them?`__
* `Episode 2: Creating Basic Snippets`__
* `Episode 3: What's new in version 2.0`__
* `Episode 4: Python Interpolation`__

__ http://www.sirver.net/blog/2011/12/30/first-episode-of-ultisnips-screencast/
__ http://www.sirver.net/blog/2012/01/08/second-episode-of-ultisnips-screencast/
__ http://www.sirver.net/blog/2012/02/05/third-episode-of-ultisnips-screencast/
__ http://www.sirver.net/blog/2012/03/31/fourth-episode-of-ultisnips-screencast/


78 changes: 53 additions & 25 deletions vim/bundle/ultisnips/UltiSnips/all.snippets
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,75 @@
# NICE BOXES #
##############
global !p
def cs(snip):
c = '#'
cs = snip.opt("&commentstring")
if len(cs) == 3:
c = cs[0]
return c
import string, vim
def _parse_comments(s):
i = iter(s.split(","))
rv = []
try:
while True:
n = i.next()
if n[0] == 's':
ctriple = []
indent = ""
if n[1] in string.digits:
indent = " " * int(n[1])
ctriple.append(n.split(":",1)[1])
n = i.next()
assert(n[0] == 'm')
ctriple.append(n.split(":",1)[1])
n = i.next()
assert(n[0] == 'e')
ctriple.append(n.split(":",1)[1])
ctriple.append(indent)
rv.append(ctriple)
elif n[0] == 'b':
cm = n.split(":", 1)[1]
if len(cm) == 1:
rv.insert(0, (cm,cm,cm, ""))
except StopIteration:
return rv
def make_box(twidth, bwidth = None):
if bwidth is None:
bwidth = twidth + 2
b,m,e,i = _parse_comments(vim.eval("&comments"))[0]
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
c = cs(snip)
snip.rv = (len(t[1])+4)*c
bar = snip.rv
snip += c + ' '`${1:content}`!p
snip.rv = ' ' + c
snip += bar`
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
c = cs(snip)
bar = 75*c
snip.rv = bar
snip += c + " " + (71-len(t[1]))/2*' '
box = make_box(len(t[1]), 71)
snip.rv = box[0] + '\n' + box[1]
`${1:content}`!p
a = 71-len(t[1])
snip.rv = (a/2 + a%2) * " " + " " + c
snip += bar`
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" fb
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.
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:
27 changes: 27 additions & 0 deletions vim/bundle/ultisnips/UltiSnips/bindzone.snippets
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions vim/bundle/ultisnips/UltiSnips/c.snippets
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ snippet def "#ifndef ... #define ... #endif"
#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
Expand Down
90 changes: 90 additions & 0 deletions vim/bundle/ultisnips/UltiSnips/coffee.snippets
Original file line number Diff line number Diff line change
@@ -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

Loading

0 comments on commit 0e136be

Please sign in to comment.