blob: ea010480e1075a88bbfb5ad0b8d87e755429a505 [file] [log] [blame]
temporal40ee5512008-07-10 02:12:20 +00001" Protocol Buffers - Google's data interchange format
2" Copyright 2008 Google Inc.
3"
4" Licensed under the Apache License, Version 2.0 (the "License");
5" you may not use this file except in compliance with the License.
6" You may obtain a copy of the License at
7"
8" http:"www.apache.org/licenses/LICENSE-2.0
9"
10" Unless required by applicable law or agreed to in writing, software
11" distributed under the License is distributed on an "AS IS" BASIS,
12" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13" See the License for the specific language governing permissions and
14" limitations under the License.
15
16" This is the Vim syntax file for Google Protocol Buffers.
17"
18" Usage:
19"
20" 1. cp proto.vim ~/.vim/syntax/
21" 2. Add the following to ~/.vimrc:
22"
23" augroup filetype
24" au! BufRead,BufNewFile *.proto setfiletype proto
25" augroup end
26
27if version < 600
28 syntax clear
29elseif exists("b:current_syntax")
30 finish
31endif
32
33syn case match
34
35syn keyword pbSyntax syntax import option
36syn keyword pbStructure package message group
37syn keyword pbRepeat optional required repeated
38syn keyword pbDefault default
39syn keyword pbExtend extend extensions to max
40syn keyword pbRPC service rpc returns
41
42syn keyword pbType int32 int64 uint32 uint64 sint32 sint64
43syn keyword pbType fixed32 fixed64 sfixed32 sfixed64
44syn keyword pbType float double bool string bytes
45syn keyword pbTypedef enum
46syn keyword pbBool true false
47
48syn match pbInt /-\?\<\d\+\>/
49syn match pbInt /\<0[xX]\x+\>/
50syn match pbFloat /\<-\?\d*\(\.\d*\)\?/
51" TODO: .proto also supports C-style block comments;
52" see /usr/share/vim/vim70/syntax/c.vim for how it's done.
53syn match pbComment /\/\/.*$/
54syn region pbString start=/"/ skip=/\\"/ end=/"/
55syn region pbString start=/'/ skip=/\\'/ end=/'/
56
57if version >= 508 || !exists("did_proto_syn_inits")
58 if version < 508
59 let did_proto_syn_inits = 1
60 command -nargs=+ HiLink hi link <args>
61 else
62 command -nargs=+ HiLink hi def link <args>
63 endif
64
65 HiLink pbSyntax Include
66 HiLink pbStructure Structure
67 HiLink pbRepeat Repeat
68 HiLink pbDefault Keyword
69 HiLink pbExtend Keyword
70 HiLink pbRPC Keyword
71 HiLink pbType Type
72 HiLink pbTypedef Typedef
73 HiLink pbBool Boolean
74
75 HiLink pbInt Number
76 HiLink pbFloat Float
77 HiLink pbComment Comment
78 HiLink pbString String
79
80 delcommand HiLink
81endif
82
83let b:current_syntax = "proto"