temporal | 40ee551 | 2008-07-10 02:12:20 +0000 | [diff] [blame^] | 1 | " 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 | |
| 27 | if version < 600 |
| 28 | syntax clear |
| 29 | elseif exists("b:current_syntax") |
| 30 | finish |
| 31 | endif |
| 32 | |
| 33 | syn case match |
| 34 | |
| 35 | syn keyword pbSyntax syntax import option |
| 36 | syn keyword pbStructure package message group |
| 37 | syn keyword pbRepeat optional required repeated |
| 38 | syn keyword pbDefault default |
| 39 | syn keyword pbExtend extend extensions to max |
| 40 | syn keyword pbRPC service rpc returns |
| 41 | |
| 42 | syn keyword pbType int32 int64 uint32 uint64 sint32 sint64 |
| 43 | syn keyword pbType fixed32 fixed64 sfixed32 sfixed64 |
| 44 | syn keyword pbType float double bool string bytes |
| 45 | syn keyword pbTypedef enum |
| 46 | syn keyword pbBool true false |
| 47 | |
| 48 | syn match pbInt /-\?\<\d\+\>/ |
| 49 | syn match pbInt /\<0[xX]\x+\>/ |
| 50 | syn 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. |
| 53 | syn match pbComment /\/\/.*$/ |
| 54 | syn region pbString start=/"/ skip=/\\"/ end=/"/ |
| 55 | syn region pbString start=/'/ skip=/\\'/ end=/'/ |
| 56 | |
| 57 | if 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 |
| 81 | endif |
| 82 | |
| 83 | let b:current_syntax = "proto" |