jproperties.vim 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. " Vim syntax file
  2. " Language: Java Properties resource file (*.properties[_*])
  3. " Maintainer: Simon Baldwin <simonb@sco.com>
  4. " Last change: 26th Mar 2000
  5. " =============================================================================
  6. " Optional and tuning variables:
  7. " jproperties_lines
  8. " -----------------
  9. " Set a value for the sync block that we use to find long continuation lines
  10. " in properties; the value is already large - if you have larger continuation
  11. " sets you may need to increase it further - if not, and you find editing is
  12. " slow, reduce the value of jproperties_lines.
  13. if !exists("jproperties_lines")
  14. let jproperties_lines = 256
  15. endif
  16. " jproperties_strict_syntax
  17. " -------------------------
  18. " Most properties files assign values with "id=value" or "id:value". But,
  19. " strictly, the Java properties parser also allows "id value", "id", and
  20. " even more bizarrely "=value", ":value", " value", and so on. These latter
  21. " ones, however, are rarely used, if ever, and handling them in the high-
  22. " lighting can obscure errors in the more normal forms. So, in practice
  23. " we take special efforts to pick out only "id=value" and "id:value" forms
  24. " by default. If you want strict compliance, set jproperties_strict_syntax
  25. " to non-zero (and good luck).
  26. if !exists("jproperties_strict_syntax")
  27. let jproperties_strict_syntax = 0
  28. endif
  29. " jproperties_show_messages
  30. " -------------------------
  31. " If this properties file contains messages for use with MessageFormat,
  32. " setting a non-zero value will highlight them. Messages are of the form
  33. " "{...}". Highlighting doesn't go to the pains of picking apart what is
  34. " in the format itself - just the basics for now.
  35. if !exists("jproperties_show_messages")
  36. let jproperties_show_messages = 0
  37. endif
  38. " =============================================================================
  39. " quit when a syntax file was already loaded
  40. if exists("b:current_syntax")
  41. finish
  42. endif
  43. " switch case sensitivity off
  44. syn case ignore
  45. " set the block
  46. exec "syn sync lines=" . jproperties_lines
  47. " switch between 'normal' and 'strict' syntax
  48. if jproperties_strict_syntax != 0
  49. " an assignment is pretty much any non-empty line at this point,
  50. " trying to not think about continuation lines
  51. syn match jpropertiesAssignment "^\s*[^[:space:]]\+.*$" contains=jpropertiesIdentifier
  52. " an identifier is anything not a space character, pretty much; it's
  53. " followed by = or :, or space or tab. Or end-of-line.
  54. syn match jpropertiesIdentifier "[^=:[:space:]]*" contained nextgroup=jpropertiesDelimiter
  55. " treat the delimiter specially to get colours right
  56. syn match jpropertiesDelimiter "\s*[=:[:space:]]\s*" contained nextgroup=jpropertiesString
  57. " catch the bizarre case of no identifier; a special case of delimiter
  58. syn match jpropertiesEmptyIdentifier "^\s*[=:]\s*" nextgroup=jpropertiesString
  59. else
  60. " here an assignment is id=value or id:value, and we conveniently
  61. " ignore continuation lines for the present
  62. syn match jpropertiesAssignment "^\s*[^=:[:space:]]\+\s*[=:].*$" contains=jpropertiesIdentifier
  63. " an identifier is anything not a space character, pretty much; it's
  64. " always followed by = or :, and we find it in an assignment
  65. syn match jpropertiesIdentifier "[^=:[:space:]]\+" contained nextgroup=jpropertiesDelimiter
  66. " treat the delimiter specially to get colours right; this time the
  67. " delimiter must contain = or :
  68. syn match jpropertiesDelimiter "\s*[=:]\s*" contained nextgroup=jpropertiesString
  69. endif
  70. " a definition is all up to the last non-\-terminated line; strictly, Java
  71. " properties tend to ignore leading whitespace on all lines of a multi-line
  72. " definition, but we don't look for that here (because it's a major hassle)
  73. syn region jpropertiesString start="" skip="\\$" end="$" contained contains=jpropertiesSpecialChar,jpropertiesError,jpropertiesSpecial
  74. " {...} is a Java Message formatter - add a minimal recognition of these
  75. " if required
  76. if jproperties_show_messages != 0
  77. syn match jpropertiesSpecial "{[^}]*}\{-1,\}" contained
  78. syn match jpropertiesSpecial "'{" contained
  79. syn match jpropertiesSpecial "''" contained
  80. endif
  81. " \uABCD are unicode special characters
  82. syn match jpropertiesSpecialChar "\\u\x\{1,4}" contained
  83. " ...and \u not followed by a hex digit is an error, though the properties
  84. " file parser won't issue an error on it, just set something wacky like zero
  85. syn match jpropertiesError "\\u\X\{1,4}" contained
  86. syn match jpropertiesError "\\u$"me=e-1 contained
  87. " other things of note are the \t,r,n,\, and the \ preceding line end
  88. syn match jpropertiesSpecial "\\[trn\\]" contained
  89. syn match jpropertiesSpecial "\\\s" contained
  90. syn match jpropertiesSpecial "\\$" contained
  91. " comments begin with # or !, and persist to end of line; put here since
  92. " they may have been caught by patterns above us
  93. syn match jpropertiesComment "^\s*[#!].*$" contains=jpropertiesTODO
  94. syn keyword jpropertiesTodo TODO FIXME XXX contained
  95. " Define the default highlighting.
  96. " Only when an item doesn't have highlighting yet
  97. hi def link jpropertiesComment Comment
  98. hi def link jpropertiesTodo Todo
  99. hi def link jpropertiesIdentifier Identifier
  100. hi def link jpropertiesString String
  101. hi def link jpropertiesExtendString String
  102. hi def link jpropertiesCharacter Character
  103. hi def link jpropertiesSpecial Special
  104. hi def link jpropertiesSpecialChar SpecialChar
  105. hi def link jpropertiesError Error
  106. let b:current_syntax = "jproperties"
  107. " vim:ts=8