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