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" ============================================================================= 7 8" Optional and tuning variables: 9 10" jproperties_lines 11" ----------------- 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. 16if !exists("jproperties_lines") 17 let jproperties_lines = 256 18endif 19 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). 30if !exists("jproperties_strict_syntax") 31 let jproperties_strict_syntax = 0 32endif 33 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. 40if !exists("jproperties_show_messages") 41 let jproperties_show_messages = 0 42endif 43 44" ============================================================================= 45 46" For version 5.x: Clear all syntax items 47" For version 6.x: Quit when a syntax file was already loaded 48if version < 600 49 syntax clear 50elseif exists("b:current_syntax") 51 finish 52endif 53 54" switch case sensitivity off 55syn case ignore 56 57" set the block 58exec "syn sync lines=" . jproperties_lines 59 60" switch between 'normal' and 'strict' syntax 61if jproperties_strict_syntax != 0 62 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 66 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 70 71 " treat the delimiter specially to get colours right 72 syn match jpropertiesDelimiter "\s*[=:[:space:]]\s*" contained nextgroup=jpropertiesString 73 74 " catch the bizarre case of no identifier; a special case of delimiter 75 syn match jpropertiesEmptyIdentifier "^\s*[=:]\s*" nextgroup=jpropertiesString 76else 77 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 81 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 85 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 89endif 90 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) 94syn region jpropertiesString start="" skip="\\$" end="$" contained contains=jpropertiesSpecialChar,jpropertiesError,jpropertiesSpecial 95 96" {...} is a Java Message formatter - add a minimal recognition of these 97" if required 98if jproperties_show_messages != 0 99 syn match jpropertiesSpecial "{[^}]*}\{-1,\}" contained 100 syn match jpropertiesSpecial "'{" contained 101 syn match jpropertiesSpecial "''" contained 102endif 103 104" \uABCD are unicode special characters 105syn match jpropertiesSpecialChar "\\u\x\{1,4}" contained 106 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 109syn match jpropertiesError "\\u\X\{1,4}" contained 110syn match jpropertiesError "\\u$"me=e-1 contained 111 112" other things of note are the \t,r,n,\, and the \ preceding line end 113syn match jpropertiesSpecial "\\[trn\\]" contained 114syn match jpropertiesSpecial "\\\s" contained 115syn match jpropertiesSpecial "\\$" contained 116 117" comments begin with # or !, and persist to end of line; put here since 118" they may have been caught by patterns above us 119syn match jpropertiesComment "^\s*[#!].*$" contains=jpropertiesTODO 120syn keyword jpropertiesTodo TODO FIXME XXX contained 121 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 125if version >= 508 || !exists("did_jproperties_syntax_inits") 126 if version < 508 127 let did_jproperties_syntax_inits = 1 128 command -nargs=+ HiLink hi link <args> 129 else 130 command -nargs=+ HiLink hi def link <args> 131 endif 132 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 142 143 delcommand HiLink 144endif 145 146let b:current_syntax = "jproperties" 147 148" vim:ts=8 149