proto.vim 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. " Protocol Buffers - Google's data interchange format
  2. " Copyright 2008 Google Inc. All rights reserved.
  3. " https://developers.google.com/protocol-buffers/
  4. "
  5. " Redistribution and use in source and binary forms, with or without
  6. " modification, are permitted provided that the following conditions are
  7. " met:
  8. "
  9. " * Redistributions of source code must retain the above copyright
  10. " notice, this list of conditions and the following disclaimer.
  11. " * Redistributions in binary form must reproduce the above
  12. " copyright notice, this list of conditions and the following disclaimer
  13. " in the documentation and/or other materials provided with the
  14. " distribution.
  15. " * Neither the name of Google Inc. nor the names of its
  16. " contributors may be used to endorse or promote products derived from
  17. " this software without specific prior written permission.
  18. "
  19. " THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. " "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. " LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. " A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. " OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. " SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. " LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. " DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. " THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. " (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. " OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. " This is the Vim syntax file for Google Protocol Buffers.
  31. "
  32. " Usage:
  33. "
  34. " 1. cp proto.vim ~/.vim/syntax/
  35. " 2. Add the following to ~/.vimrc:
  36. "
  37. " augroup filetype
  38. " au! BufRead,BufNewFile *.proto setfiletype proto
  39. " augroup end
  40. "
  41. " Or just create a new file called ~/.vim/ftdetect/proto.vim with the
  42. " previous lines on it.
  43. if version < 600
  44. syntax clear
  45. elseif exists("b:current_syntax")
  46. finish
  47. endif
  48. syn case match
  49. syn keyword pbTodo contained TODO FIXME XXX
  50. syn cluster pbCommentGrp contains=pbTodo
  51. syn keyword pbSyntax syntax import option
  52. syn keyword pbStructure package message group oneof
  53. syn keyword pbRepeat optional required repeated
  54. syn keyword pbDefault default
  55. syn keyword pbExtend extend extensions to max reserved
  56. syn keyword pbRPC service rpc returns
  57. syn keyword pbType int32 int64 uint32 uint64 sint32 sint64
  58. syn keyword pbType fixed32 fixed64 sfixed32 sfixed64
  59. syn keyword pbType float double bool string bytes
  60. syn keyword pbTypedef enum
  61. syn keyword pbBool true false
  62. syn match pbInt /-\?\<\d\+\>/
  63. syn match pbInt /\<0[xX]\x+\>/
  64. syn match pbFloat /\<-\?\d*\(\.\d*\)\?/
  65. syn region pbComment start="\/\*" end="\*\/" contains=@pbCommentGrp,@Spell
  66. syn region pbComment start="//" skip="\\$" end="$" keepend contains=@pbCommentGrp,@Spell
  67. syn region pbString start=/"/ skip=/\\./ end=/"/ contains=@Spell
  68. syn region pbString start=/'/ skip=/\\./ end=/'/ contains=@Spell
  69. if version >= 508 || !exists("did_proto_syn_inits")
  70. if version < 508
  71. let did_proto_syn_inits = 1
  72. command -nargs=+ HiLink hi link <args>
  73. else
  74. command -nargs=+ HiLink hi def link <args>
  75. endif
  76. HiLink pbTodo Todo
  77. HiLink pbSyntax Include
  78. HiLink pbStructure Structure
  79. HiLink pbRepeat Repeat
  80. HiLink pbDefault Keyword
  81. HiLink pbExtend Keyword
  82. HiLink pbRPC Keyword
  83. HiLink pbType Type
  84. HiLink pbTypedef Typedef
  85. HiLink pbBool Boolean
  86. HiLink pbInt Number
  87. HiLink pbFloat Float
  88. HiLink pbComment Comment
  89. HiLink pbString String
  90. delcommand HiLink
  91. endif
  92. let b:current_syntax = "proto"