gotexttmpl.vim 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. " Copyright 2011 The Go Authors. All rights reserved.
  2. " Use of this source code is governed by a BSD-style
  3. " license that can be found in the LICENSE file.
  4. "
  5. " gotexttmpl.vim: Vim syntax file for Go templates.
  6. " Quit when a (custom) syntax file was already loaded
  7. if exists("b:current_syntax")
  8. finish
  9. endif
  10. syn case match
  11. " Go escapes
  12. syn match goEscapeOctal display contained "\\[0-7]\{3}"
  13. syn match goEscapeC display contained +\\[abfnrtv\\'"]+
  14. syn match goEscapeX display contained "\\x\x\{2}"
  15. syn match goEscapeU display contained "\\u\x\{4}"
  16. syn match goEscapeBigU display contained "\\U\x\{8}"
  17. syn match goEscapeError display contained +\\[^0-7xuUabfnrtv\\'"]+
  18. hi def link goEscapeOctal goSpecialString
  19. hi def link goEscapeC goSpecialString
  20. hi def link goEscapeX goSpecialString
  21. hi def link goEscapeU goSpecialString
  22. hi def link goEscapeBigU goSpecialString
  23. hi def link goSpecialString Special
  24. hi def link goEscapeError Error
  25. " Strings and their contents
  26. syn cluster goStringGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU,goEscapeError
  27. syn region goString contained start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@goStringGroup
  28. syn region goRawString contained start=+`+ end=+`+
  29. hi def link goString String
  30. hi def link goRawString String
  31. " Characters; their contents
  32. syn cluster goCharacterGroup contains=goEscapeOctal,goEscapeC,goEscapeX,goEscapeU,goEscapeBigU
  33. syn region goCharacter contained start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=@goCharacterGroup
  34. hi def link goCharacter Character
  35. " Integers
  36. syn match goDecimalInt contained "\<\d\+\([Ee]\d\+\)\?\>"
  37. syn match goHexadecimalInt contained "\<0x\x\+\>"
  38. syn match goOctalInt contained "\<0\o\+\>"
  39. syn match goOctalError contained "\<0\o*[89]\d*\>"
  40. syn cluster goInt contains=goDecimalInt,goHexadecimalInt,goOctalInt
  41. " Floating point
  42. syn match goFloat contained "\<\d\+\.\d*\([Ee][-+]\d\+\)\?\>"
  43. syn match goFloat contained "\<\.\d\+\([Ee][-+]\d\+\)\?\>"
  44. syn match goFloat contained "\<\d\+[Ee][-+]\d\+\>"
  45. " Imaginary literals
  46. syn match goImaginary contained "\<\d\+i\>"
  47. syn match goImaginary contained "\<\d\+\.\d*\([Ee][-+]\d\+\)\?i\>"
  48. syn match goImaginary contained "\<\.\d\+\([Ee][-+]\d\+\)\?i\>"
  49. syn match goImaginary contained "\<\d\+[Ee][-+]\d\+i\>"
  50. hi def link goInt Number
  51. hi def link goFloat Number
  52. hi def link goImaginary Number
  53. " Token groups
  54. syn cluster gotplLiteral contains=goString,goRawString,goCharacter,@goInt,goFloat,goImaginary
  55. syn keyword gotplControl contained if else end range with template
  56. syn keyword gotplFunctions contained and html index js len not or print printf println urlquery eq ne lt le gt ge
  57. syn match gotplVariable contained /\$[a-zA-Z0-9_]*\>/
  58. syn match goTplIdentifier contained /\.[^\s}]+\>/
  59. hi def link gotplControl Keyword
  60. hi def link gotplFunctions Function
  61. hi def link goTplVariable Special
  62. syn region gotplAction start="{{" end="}}" contains=@gotplLiteral,gotplControl,gotplFunctions,gotplVariable,goTplIdentifier display
  63. syn region gotplAction start="\[\[" end="\]\]" contains=@gotplLiteral,gotplControl,gotplFunctions,gotplVariable display
  64. syn region goTplComment start="{{\(- \)\?/\*" end="\*/\( -\)\?}}" display
  65. syn region goTplComment start="\[\[\(- \)\?/\*" end="\*/\( -\)\?\]\]" display
  66. hi def link gotplAction PreProc
  67. hi def link goTplComment Comment
  68. let b:current_syntax = "gotexttmpl"
  69. " vim: sw=2 ts=2 et