proto.vim 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. " This is the Vim syntax file for Google Protocol Buffers.
  16. "
  17. " Usage:
  18. "
  19. " 1. cp proto.vim ~/.vim/syntax/
  20. " 2. Add the following to ~/.vimrc:
  21. "
  22. " augroup filetype
  23. " au! BufRead,BufNewFile *.proto setfiletype proto
  24. " augroup end
  25. if version < 600
  26. syntax clear
  27. elseif exists("b:current_syntax")
  28. finish
  29. endif
  30. syn case match
  31. syn keyword pbSyntax syntax import option
  32. syn keyword pbStructure package message group
  33. syn keyword pbRepeat optional required repeated
  34. syn keyword pbDefault default
  35. syn keyword pbExtend extend extensions to max
  36. syn keyword pbRPC service rpc returns
  37. syn keyword pbType int32 int64 uint32 uint64 sint32 sint64
  38. syn keyword pbType fixed32 fixed64 sfixed32 sfixed64
  39. syn keyword pbType float double bool string bytes
  40. syn keyword pbTypedef enum
  41. syn keyword pbBool true false
  42. syn match pbInt /-\?\<\d\+\>/
  43. syn match pbInt /\<0[xX]\x+\>/
  44. syn match pbFloat /\<-\?\d*\(\.\d*\)\?/
  45. " TODO: .proto also supports C-style block comments;
  46. " see /usr/share/vim/vim70/syntax/c.vim for how it's done.
  47. syn match pbComment /\/\/.*$/
  48. syn region pbString start=/"/ skip=/\\"/ end=/"/
  49. syn region pbString start=/'/ skip=/\\'/ end=/'/
  50. if version >= 508 || !exists("did_proto_syn_inits")
  51. if version < 508
  52. let did_proto_syn_inits = 1
  53. command -nargs=+ HiLink hi link <args>
  54. else
  55. command -nargs=+ HiLink hi def link <args>
  56. endif
  57. HiLink pbSyntax Include
  58. HiLink pbStructure Structure
  59. HiLink pbRepeat Repeat
  60. HiLink pbDefault Keyword
  61. HiLink pbExtend Keyword
  62. HiLink pbRPC Keyword
  63. HiLink pbType Type
  64. HiLink pbTypedef Typedef
  65. HiLink pbBool Boolean
  66. HiLink pbInt Number
  67. HiLink pbFloat Float
  68. HiLink pbComment Comment
  69. HiLink pbString String
  70. delcommand HiLink
  71. endif
  72. let b:current_syntax = "proto"