diff options
-rw-r--r-- | after/syntax/proto.vim | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/after/syntax/proto.vim b/after/syntax/proto.vim new file mode 100644 index 0000000..ea026df --- /dev/null +++ b/after/syntax/proto.vim @@ -0,0 +1,83 @@ +" syn clear pbType +" syn clear pbRepeat +" syn clear pbMessage +" syn clear pbTypedef + +syn keyword pbEnumTypedef enum nextgroup=pbEnumTypeName skipwhite skipempty + +syn keyword pbRepeat required optional repeated nextgroup=protoFieldType skipempty skipwhite + +syn cluster top contains= + \pbRepeat, + \protoComment, + \protoInt, + \protoFloat, + \protoString, + \pbEnumTypedef, + \pbMessage2 + \protoSyntax, + \protoStructure, + \protoRepeat, + \protoDefault, + \protoExtend, + \protoRPC, + \pbAnnotation, + \pbOneofKeyword, + \pbOptionKeyword, + \pbMessageKeyword + +syn cluster oneofContains contains=protoFieldType,pbOptionKeyword,protoComment,pbAnnotation + +syn keyword pbOneofKeyword oneof nextgroup=pbOneofName skipwhite +syn match pbOneofName +\<\w\+\>+ nextgroup=pbOneofBody contained skipwhite +syn region pbOneofBody start=+{+ end=+}+ contains=@oneofContains contained + +syn match protoFieldType "\<[A-Za-z]\%(\w\|\.\)\+\>" nextgroup=protoFieldName skipempty skipwhite +syn match protoFieldName "\<\w\+\>" nextgroup=protoFieldEquals contained skipwhite +syn match protoFieldEquals +=+ contained nextgroup=protoFieldNumber,protoFieldNumberBad contained skipwhite +syn match protoFieldNumber +[1-9][0-9]*+ contained +syn match protoFieldNumberBad +0[0-9]*+ contained + +hi! link protoFieldNumber Number +hi! link protoFieldEquals Operator +hi! link protoFieldNumberBad Error + +syn match pbEnumTypeName "\<\w\+\>" nextgroup=enumBody skipempty skipwhite contained +syn region enumBody start=+{+ end=+}+ contains=enumValue,protoComment,protoInt,pbAnnotation fold contained +syn match enumValue "\zs\w\+\ze\s*=" contained + +syn keyword pbMessageKeyword message nextgroup=pbMessage2 skipwhite +syn match pbMessage2 "\<\w\+\>" nextgroup=pbMessageBody skipempty skipwhite +syn region pbMessageBody start=+{+ end=+}+ contains=@top fold contained + + +syn region protoAnnotString start=/"/ skip=/\\./ end=/"/ contained +syn region protoAnnotString start=/'/ skip=/\\./ end=/'/ contained +syn region pbAnnotation start=+\[+ end=+\]+ contains=protoAnnotString,pbAnnotationType fold + +syn keyword pbOptionKeyword option nextgroup=pbAnnotationType skipwhite +syn match pbAnnotationType +([a-z._]\+)+ nextgroup=annotationEquals contained skipwhite +syn match annotationEquals +=+ nextgroup=annotationValue contained skipwhite +syn match annotationValue +\w\++ contained + +hi link annotationEquals Operator +hi link annotationValue Constant +hi link pbAnnotationType Identifier + +hi link protoAnnotString String +hi link protoFieldType Type +hi link pbEnumTypeName Type +hi link pbMessage2 Type + +hi link protoFieldName Identifier +hi link enumValue Constant + +hi link pbAnnotation PreProc +hi! link pbOneofKeyword protoStructure +hi! link pbOneofName Identifier + +hi! link pbEnumTypedef StorageClass +hi! link pbRepeat StorageClass + +hi! link pbOptionKeyword protoSyntax +hi! link pbMessageKeyword protoStructure |