Skip to content

Commit 59dcc2b

Browse files
SirVerMarcWeber
authored andcommitted
Brings current UltiSnips snippets into the repository.
1 parent 3f7061a commit 59dcc2b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2349
-1028
lines changed

UltiSnips/README

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
This directory contains the main scripts that come bundled with UltiSnips.
1+
This directory contains the snippets for UltiSnips.
2+
https://github.com/sirver/ultisnips
23

34
Standing On The Shoulders of Giants
45
===================================
@@ -10,12 +11,7 @@ two projects:
1011
TextMate: http://svn.textmate.org/trunk/Bundles/
1112
SnipMate: http://code.google.com/p/snipmate/
1213

13-
All snippets from those sources were copied and cleaned up, so that they are
14-
- not using shell script, only python (so they are cross platform compatible)
15-
- not using any feature that UltiSnips doesn't offer
16-
17-
UltiSnips has seen contributions by various individuals. Those contributions
18-
have been merged into this collection seamlessly and without further comments.
14+
UltiSnips has seen contributions by many individuals. Those contributions have
15+
been merged into this collection seamlessly and without further comments.
1916

2017
-- vim:ft=rst:nospell:
21-

UltiSnips/all.snippets

Lines changed: 70 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# This file contains snippets that are always defined. I personally
22
# have snippets for signatures and often needed texts
33

4+
priority -50
5+
46
##############
57
# NICE BOXES #
68
##############
@@ -12,71 +14,62 @@ Automatically filled during usage"""
1214
_commentDict = { }
1315
1416
def _parse_comments(s):
15-
""" Parses vim's comments option to extract comment format """
16-
i = iter(s.split(","))
17-
18-
rv = []
19-
try:
20-
while True:
21-
# get the flags and text of a comment part
22-
flags,text = i.next().split(':', 1)
23-
24-
if len(flags) == 0:
25-
if len(text) == 1:
26-
rv.append((text,text,text, ""))
27-
# parse 3-part comment, but ignore those with O flag
28-
elif flags[0] == 's' and 'O' not in flags:
29-
ctriple = []
30-
indent = ""
31-
32-
if flags[-1] in string.digits:
33-
indent = " " * int(flags[-1])
34-
ctriple.append(text)
17+
""" Parses vim's comments option to extract comment format """
18+
i = iter(s.split(","))
19+
20+
rv = []
21+
try:
22+
while True:
23+
# get the flags and text of a comment part
24+
flags, text = next(i).split(':', 1)
25+
26+
if len(flags) == 0:
27+
rv.append((text, text, text, ""))
28+
# parse 3-part comment, but ignore those with O flag
29+
elif flags[0] == 's' and 'O' not in flags:
30+
ctriple = []
31+
indent = ""
32+
33+
if flags[-1] in string.digits:
34+
indent = " " * int(flags[-1])
35+
ctriple.append(text)
36+
37+
flags,text = next(i).split(':', 1)
38+
assert(flags[0] == 'm')
39+
ctriple.append(text)
40+
41+
flags,text = next(i).split(':', 1)
42+
assert(flags[0] == 'e')
43+
ctriple.append(text)
44+
ctriple.append(indent)
45+
46+
rv.append(ctriple)
47+
elif flags[0] == 'b':
48+
if len(text) == 1:
49+
rv.insert(0, (text,text,text, ""))
50+
except StopIteration:
51+
return rv
3552
36-
flags,text = i.next().split(':', 1)
37-
assert(flags[0] == 'm')
38-
ctriple.append(text)
39-
40-
flags,text = i.next().split(':', 1)
41-
assert(flags[0] == 'e')
42-
ctriple.append(text)
43-
ctriple.append(indent)
53+
def _get_comment_format():
54+
""" Returns a 4-element tuple representing the comment format for
55+
the current file. """
56+
return _parse_comments(vim.eval("&comments"))[0]
4457
45-
rv.append(ctriple)
4658
47-
elif flags[0] == 'b':
48-
if len(text) == 1:
49-
rv.insert(0, (text,text,text, ""))
59+
def make_box(twidth, bwidth=None):
60+
b, m, e, i = _get_comment_format()
61+
bwidth_inner = bwidth - 3 - max(len(b), len(i + e)) if bwidth else twidth + 2
62+
sline = b + m + bwidth_inner * m[0] + 2 * m[0]
63+
nspaces = (bwidth_inner - twidth) // 2
64+
mlines = i + m + " " + " " * nspaces
65+
mlinee = " " + " "*(bwidth_inner - twidth - nspaces) + m
66+
eline = i + m + bwidth_inner * m[0] + 2 * m[0] + e
67+
return sline, mlines, mlinee, eline
5068
51-
except StopIteration:
52-
return rv
69+
def foldmarker():
70+
"Return a tuple of (open fold marker, close fold marker)"
71+
return vim.eval("&foldmarker").split(",")
5372
54-
def _get_comment_format():
55-
""" Returns a 4-element tuple representing the comment format for
56-
the current file. """
57-
58-
ft = vim.eval("&filetype")
59-
# check if the comment dict has the format for the current file
60-
if _commentDict.has_key(ft):
61-
return _commentDict[ft]
62-
63-
# otherwise parse vim's comments and add it for later use
64-
commentformat = _parse_comments(vim.eval("&comments"))[0]
65-
_commentDict[ft] = commentformat
66-
67-
return commentformat
68-
69-
70-
def make_box(twidth, bwidth = None):
71-
if bwidth is None:
72-
bwidth = twidth + 2
73-
b,m,e,i = _get_comment_format()
74-
sline = b + m + bwidth*m + 2*m
75-
nspaces = (bwidth - twidth)//2
76-
mlines = i + m + " " + " "*nspaces
77-
mlinee = " " + " "*(bwidth-twidth-nspaces) + m
78-
eline = i + 2*m + bwidth*m + m + e
79-
return sline, mlines, mlinee, eline
8073
endglobal
8174

8275
snippet box "A nice box with the current comment symbol" b
@@ -91,14 +84,29 @@ endsnippet
9184

9285
snippet bbox "A nice box over the full width" b
9386
`!p
94-
box = make_box(len(t[1]), 71)
87+
width = int(vim.eval("&textwidth")) or 71
88+
box = make_box(len(t[1]), width)
9589
snip.rv = box[0] + '\n' + box[1]
9690
`${1:content}`!p
97-
box = make_box(len(t[1]), 71)
91+
box = make_box(len(t[1]), width)
9892
snip.rv = box[2] + '\n' + box[3]`
9993
$0
10094
endsnippet
10195

96+
snippet fold "Insert a vim fold marker" b
97+
`!p snip.rv = _get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]`${2:1} `!p snip.rv = _get_comment_format()[2]`
98+
endsnippet
99+
100+
snippet foldc "Insert a vim fold close marker" b
101+
`!p snip.rv = _get_comment_format()[0]` ${2:1}`!p snip.rv = foldmarker()[1]` `!p snip.rv = _get_comment_format()[2]`
102+
endsnippet
103+
104+
snippet foldp "Insert a vim fold marker pair" b
105+
`!p snip.rv = _get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]` `!p snip.rv = _get_comment_format()[2]`
106+
${2:${VISUAL:Content}}
107+
`!p snip.rv = _get_comment_format()[0]` `!p snip.rv = foldmarker()[1]` $1 `!p snip.rv = _get_comment_format()[2]`
108+
endsnippet
109+
102110
##########################
103111
# LOREM IPSUM GENERATORS #
104112
##########################

UltiSnips/bib.snippets

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
priority -50
2+
3+
snippet online "Online resource" b
4+
@online{${1:name},
5+
author={${2:author}},
6+
title={${3:title}},
7+
date={${4:date}},
8+
url={${5:url}}
9+
}
10+
$0
11+
endsnippet
12+
13+
snippet article "Article reference" b
14+
@article{${1:name},
15+
author={${2:author}},
16+
title={${3:title}},
17+
journaltitle={${4:journal}},
18+
volume={${5:NN}},
19+
number={${6:NN}},
20+
year={${7:YYYY}},
21+
pages={${8:NN}--${9:NN}}
22+
}
23+
$0
24+
endsnippet
25+
26+
snippet book "Book reference" b
27+
@book{${1:name},
28+
author={${2:author}},
29+
title={${3:title}},
30+
subtitle={${4:subtitle}},
31+
year={${5:YYYY}},
32+
location={${6:somewhere}},
33+
publisher={${7:publisher}},
34+
pages={${8:NN}--${9:NN}}
35+
}
36+
$0
37+
endsnippet
38+
39+
snippet inb "In Book reference" b
40+
@inbook{${1:name},
41+
author={${2:author}},
42+
title={${3:title}},
43+
subtitle={${4:subtitle}},
44+
booktitle={${5:book}},
45+
editor={${6:editor}},
46+
year={${7:YYYY}},
47+
location={${8:somewhere}},
48+
publisher={${9:publisher}},
49+
pages={${10:NN}--${11:NN}}
50+
}
51+
$0
52+
endsnippet

UltiSnips/bindzone.snippets

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
1+
priority -50
2+
13
global !p
24
def newsoa():
3-
import datetime
4-
now = datetime.datetime.now()
5-
# return standard SOA formatted serial for today
6-
return now.strftime("%Y%m%d00")
5+
import datetime
6+
now = datetime.datetime.now()
7+
# return standard SOA formatted serial for today
8+
return now.strftime("%Y%m%d00")
79
endglobal
810

911
snippet zone "Bootstrap a new Bind zonefile" b
1012
$TTL 86400
11-
@ IN SOA ${1:example.net}. ${2:hostmaster.$1}.(
12-
`!p snip.rv = newsoa()`; serial
13-
21600; refresh every 6 hours
14-
3600; retry after one hour
15-
604800; expire after a week
16-
86400 ); minimum TTL of 1 day
13+
@ IN SOA ${1:example.net}. ${2:hostmaster.$1}.(
14+
`!p snip.rv = newsoa()`; serial
15+
21600; refresh every 6 hours
16+
3600; retry after one hour
17+
604800; expire after a week
18+
86400 ); minimum TTL of 1 day
1719

18-
IN NS ns01.$1.
19-
IN MX 10 mail.$1.
20+
IN NS ns01.$1.
21+
IN MX 10 mail.$1.
2022

21-
ns01.$1 IN A
22-
mail.$1 IN A
23+
ns01.$1 IN A
24+
mail.$1 IN A
2325
endsnippet
2426

2527
snippet A "Insert A Record" b
26-
${1:hostname} IN A ${2:ip}
28+
${1:hostname} IN A ${2:ip}
2729
endsnippet

0 commit comments

Comments
 (0)