-
Notifications
You must be signed in to change notification settings - Fork 3
/
cpp.snippets
184 lines (141 loc) · 2.32 KB
/
cpp.snippets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
global !p
from snippets import *
import px
for full_name, name in px.libs().items():
exec("import " + full_name)
endglobal
snippet n "function" w
${1:int} ${2:main}($3) {
$4
}
endsnippet
snippet i "if" b
if ($1) {
$2
}$0
endsnippet
snippet }e "else" wA
} else {
$1
}
endsnippet
context "px.snippets.make_context(snip)"
pre_expand "px.common.get_active_completer().reset()"
snippet pr "fmt printf xxx debug" bwe
`!p
try:
once
except:
once = True
cursor = px.cursor.get()
func = 'printf'
left = '"'
right = ')'
if t[1] != '':
left = ' ' + t[1] + ': %s\\n", '
right = ')'
if " " in t[1]:
left = ' '
right = '\\n")'
left = " " + os.path.basename(px.buffer.get().name) + ":" + str(cursor[0]) + left
``!p snip.rv = func`("XXXXXX`!p snip.rv=left`${1}`!p snip.rv=right`;fflush(NULL);
endsnippet
snippet df "" w
debugf("$1: ${3:%s}", $2);
endsnippet
snippet dd "debugf" w
debug("$1");
endsnippet
snippet fi "for" w
for ($1 = 0; $1 < $2; $1++) {
$3
}
endsnippet
snippet f "for empty" w
for ($1) {
$2
}
$0
endsnippet
snippet r "" w
return $0;
endsnippet
snippet # "#include" b
`!p
lparen = '<'
rparen = '>'
if os.path.exists(t[1]):
lparen = '"'
rparen = '"'
`#include `!p snip.rv = lparen`$1`!p snip.rv = rparen`
endsnippet
snippet #d "#define" wA
`!p
parts = t[1].split(' ')
t[1] = ' '.join(parts)
`#define $1
endsnippet
snippet t "struct" b
struct $1 {
$0
};
endsnippet
snippet s "std::" w
std::$0
endsnippet
priority 10
snippet std::s "std::string" w
std::string $0
endsnippet
snippet t "" w
try {
$1
} catch ($2) {
$3
}
endsnippet
snippet tp "" w
tuple<${1:${VISUAL:std::string}}>$0
endsnippet
snippet ie "" w
if (!$1.err.empty()) {
$2
}
endsnippet
snippet ier "" w
if (!$1.err.empty()) {
result.err = $1.err;
return result;
}
endsnippet
snippet ir "" w
if (!$1.err.empty()) {
return $1.err;
}
endsnippet
snippet rr "" w
return result;
endsnippet
snippet r: "" w
ret:
endsnippet
snippet rv "" w
result.value = $1;
endsnippet
snippet tr "" w
tuple<${1:std::string}> result;
endsnippet
snippet ss "" w
std::string $0
endsnippet
snippet vr "" w
$1 = $2.value;
endsnippet
snippet dh "" w
`!p
file = os.path.basename(px.buffer.get().name).replace('.hpp', '').replace('.h', '').upper()
`#ifndef _${1:`!p snip.rv=file`}_HEADER
#define _$1_HEADER
${VISUAL}
#endif // _$1_HEADER
endsnippet