annotate runtime/syntax/jproperties.vim @ 809:4f1b94b51e99 v7.0b02

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