proto.vim 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. "
  26. " Or just create a new file called ~/.vim/ftdetect/proto.vim with the
  27. " previous lines on it.
  28. if version < 600
  29. syntax clear
  30. elseif exists("b:current_syntax")
  31. finish
  32. endif
  33. syn case match
  34. syn keyword pbTodo contained TODO FIXME XXX
  35. syn cluster pbCommentGrp contains=pbTodo
  36. syn keyword pbSyntax syntax import option
  37. syn keyword pbStructure package message group
  38. syn keyword pbRepeat optional required repeated
  39. syn keyword pbDefault default
  40. syn keyword pbExtend extend extensions to max
  41. syn keyword pbRPC service rpc returns
  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. syn match pbInt /-\?\<\d\+\>/
  48. syn match pbInt /\<0[xX]\x+\>/
  49. syn match pbFloat /\<-\?\d*\(\.\d*\)\?/
  50. " TODO: .proto also supports C-style block comments;
  51. " see /usr/share/vim/vim70/syntax/c.vim for how it's done.
  52. syn region pbComment start="//" skip="\\$" end="$" keepend contains=@pbCommentGrp
  53. syn region pbString start=/"/ skip=/\\"/ end=/"/
  54. syn region pbString start=/'/ skip=/\\'/ end=/'/
  55. if version >= 508 || !exists("did_proto_syn_inits")
  56. if version < 508
  57. let did_proto_syn_inits = 1
  58. command -nargs=+ HiLink hi link <args>
  59. else
  60. command -nargs=+ HiLink hi def link <args>
  61. endif
  62. HiLink pbTodo Todo
  63. HiLink pbSyntax Include
  64. HiLink pbStructure Structure
  65. HiLink pbRepeat Repeat
  66. HiLink pbDefault Keyword
  67. HiLink pbExtend Keyword
  68. HiLink pbRPC Keyword
  69. HiLink pbType Type
  70. HiLink pbTypedef Typedef
  71. HiLink pbBool Boolean
  72. HiLink pbInt Number
  73. HiLink pbFloat Float
  74. HiLink pbComment Comment
  75. HiLink pbString String
  76. delcommand HiLink
  77. endif
  78. let b:current_syntax = "proto"