From 76a4d7eae9c60b091a59aa85c7a2fc3a4fcfbe59 Mon Sep 17 00:00:00 2001 From: David Barnett Date: Fri, 11 Apr 2014 21:49:14 -0700 Subject: [PATCH 1/4] Add message and field snippets for proto filetype --- UltiSnips/proto.snippets | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 UltiSnips/proto.snippets diff --git a/UltiSnips/proto.snippets b/UltiSnips/proto.snippets new file mode 100644 index 0000000..079fbb4 --- /dev/null +++ b/UltiSnips/proto.snippets @@ -0,0 +1,30 @@ +priority -50 + +snippet mess "Proto message" b +// ${2:TODO(`whoami`): Describe this message.} +message ${1:Name} { + + // Next available id: 1 +} +endsnippet + +snippet reqf "Required field" b +// ${4:TODO(`whoami`): Describe this field.} +optional ${1:type} ${2:name} = ${3:1}; // Required +endsnippet + +snippet optf "Optional field" b +// ${4:TODO(`whoami`): Describe this field.} +optional ${1:type} ${2:name} = ${3:1}; +endsnippet + +snippet repf "Repeated field" b +// ${4:TODO(`whoami`): Describe this field.} +repeated ${1:type} ${2:name} = ${3:1}; +endsnippet + +snippet enum "Enumeration" b +// ${2:TODO(`whoami`): Describe this enum.} +enum ${1:Name} { +} +endsnippet From e3c6399f8c4406105ce2d70641b111f99c16e5a1 Mon Sep 17 00:00:00 2001 From: David Barnett Date: Sun, 13 Apr 2014 09:11:58 -0700 Subject: [PATCH 2/4] Add type completions --- UltiSnips/proto.snippets | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/UltiSnips/proto.snippets b/UltiSnips/proto.snippets index 079fbb4..973e911 100644 --- a/UltiSnips/proto.snippets +++ b/UltiSnips/proto.snippets @@ -1,5 +1,28 @@ priority -50 +global !p + +from vimsnippets import complete + +FIELD_TYPES = [ + 'double', + 'float', + 'int32', + 'int64', + 'uint32', + 'uint64', + 'sint32', + 'sint64', + 'fixed32', + 'fixed64', + 'sfixed32', + 'sfixed64', + 'bool', + 'string', + 'bytes'] + +endglobal + snippet mess "Proto message" b // ${2:TODO(`whoami`): Describe this message.} message ${1:Name} { @@ -10,17 +33,17 @@ endsnippet snippet reqf "Required field" b // ${4:TODO(`whoami`): Describe this field.} -optional ${1:type} ${2:name} = ${3:1}; // Required +optional ${1:type}`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1}; // Required endsnippet snippet optf "Optional field" b // ${4:TODO(`whoami`): Describe this field.} -optional ${1:type} ${2:name} = ${3:1}; +optional ${1:type}`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1}; endsnippet snippet repf "Repeated field" b // ${4:TODO(`whoami`): Describe this field.} -repeated ${1:type} ${2:name} = ${3:1}; +repeated ${1:type}`!p snip.rv = complete(t[1], FIELD_TYPES)` ${2:name} = ${3:1}; endsnippet snippet enum "Enumeration" b From 3f3b2d561c87fc7db388270b3831853d43922998 Mon Sep 17 00:00:00 2001 From: David Barnett Date: Sun, 13 Apr 2014 09:17:57 -0700 Subject: [PATCH 3/4] Add tabstop for message body --- UltiSnips/proto.snippets | 1 + 1 file changed, 1 insertion(+) diff --git a/UltiSnips/proto.snippets b/UltiSnips/proto.snippets index 973e911..b09c4e6 100644 --- a/UltiSnips/proto.snippets +++ b/UltiSnips/proto.snippets @@ -26,6 +26,7 @@ endglobal snippet mess "Proto message" b // ${2:TODO(`whoami`): Describe this message.} message ${1:Name} { + $0 // Next available id: 1 } From cf39d41acc6bb2fae78d03d8cdc502256a2ca6ae Mon Sep 17 00:00:00 2001 From: David Barnett Date: Sun, 13 Apr 2014 22:58:20 -0700 Subject: [PATCH 4/4] rm unnecessary empty lines --- UltiSnips/proto.snippets | 2 -- 1 file changed, 2 deletions(-) diff --git a/UltiSnips/proto.snippets b/UltiSnips/proto.snippets index b09c4e6..adc5310 100644 --- a/UltiSnips/proto.snippets +++ b/UltiSnips/proto.snippets @@ -1,7 +1,6 @@ priority -50 global !p - from vimsnippets import complete FIELD_TYPES = [ @@ -20,7 +19,6 @@ FIELD_TYPES = [ 'bool', 'string', 'bytes'] - endglobal snippet mess "Proto message" b