Skip to content

Commit e3c6399

Browse files
committed
Add type completions
1 parent 280f775 commit e3c6399

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

UltiSnips/proto.snippets

+26-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
priority -50
22

3+
global !p
4+
5+
from vimsnippets import complete
6+
7+
FIELD_TYPES = [
8+
'double',
9+
'float',
10+
'int32',
11+
'int64',
12+
'uint32',
13+
'uint64',
14+
'sint32',
15+
'sint64',
16+
'fixed32',
17+
'fixed64',
18+
'sfixed32',
19+
'sfixed64',
20+
'bool',
21+
'string',
22+
'bytes']
23+
24+
endglobal
25+
326
snippet mess "Proto message" b
427
// ${2:TODO(`whoami`): Describe this message.}
528
message ${1:Name} {
@@ -10,17 +33,17 @@ endsnippet
1033

1134
snippet reqf "Required field" b
1235
// ${4:TODO(`whoami`): Describe this field.}
13-
optional ${1:type} ${2:name} = ${3:1}; // Required
36+
optional ${1:type}`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1}; // Required
1437
endsnippet
1538

1639
snippet optf "Optional field" b
1740
// ${4:TODO(`whoami`): Describe this field.}
18-
optional ${1:type} ${2:name} = ${3:1};
41+
optional ${1:type}`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1};
1942
endsnippet
2043

2144
snippet repf "Repeated field" b
2245
// ${4:TODO(`whoami`): Describe this field.}
23-
repeated ${1:type} ${2:name} = ${3:1};
46+
repeated ${1:type}`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1};
2447
endsnippet
2548

2649
snippet enum "Enumeration" b

0 commit comments

Comments
 (0)