7
|
1 " Vim syntax file
|
|
2 " Language: Cascading Style Sheets
|
|
3 " Maintainer: Claudio Fleiner <claudio@fleiner.com>
|
|
4 " URL: http://www.fleiner.com/vim/syntax/css.vim
|
36
|
5 " Last Change: 2004 Mar 30
|
7
|
6 " CSS2 by Nikolai Weibull
|
|
7 " Full CSS2, HTML4 support by Yeti
|
|
8
|
|
9 " For version 5.x: Clear all syntax items
|
|
10 " For version 6.x: Quit when a syntax file was already loaded
|
|
11 if !exists("main_syntax")
|
|
12 if version < 600
|
|
13 syntax clear
|
|
14 elseif exists("b:current_syntax")
|
|
15 finish
|
|
16 endif
|
|
17 let main_syntax = 'css'
|
|
18 endif
|
|
19
|
|
20 syn case ignore
|
|
21
|
|
22 syn keyword cssTagName abbr acronym address applet area a b base
|
|
23 syn keyword cssTagName basefont bdo big blockquote body br button
|
|
24 syn keyword cssTagName caption center cite code col colgroup dd del
|
|
25 syn keyword cssTagName dfn dir div dl dt em fieldset font form frame
|
|
26 syn keyword cssTagName frameset h1 h2 h3 h4 h5 h6 head hr html img i
|
|
27 syn keyword cssTagName iframe img input ins isindex kbd label legend li
|
|
28 syn keyword cssTagName link map menu meta noframes noscript ol optgroup
|
|
29 syn keyword cssTagName option p param pre q s samp script select small
|
|
30 syn keyword cssTagName span strike strong style sub sup tbody td
|
|
31 syn keyword cssTagName textarea tfoot th thead title tr tt ul u var
|
|
32 syn match cssTagName "\<table\>"
|
|
33 syn match cssTagName "\*"
|
|
34
|
|
35 syn match cssTagName "@page\>" nextgroup=cssDefinition
|
|
36
|
|
37 syn match cssSelectorOp "[+>.]"
|
|
38 syn match cssSelectorOp2 "[~|]\?=" contained
|
|
39 syn region cssAttributeSelector matchgroup=cssSelectorOp start="\[" end="]" transparent contains=cssUnicodeEscape,cssSelectorOp2,cssStringQ,cssStringQQ
|
|
40
|
36
|
41 syn match cssIdentifier "#[A-Za-zĄ-’_@][A-Za-zĄ-’0-9_@-]*"
|
7
|
42
|
|
43 syn match cssMedia "@media\>" nextgroup=cssMediaType skipwhite skipnl
|
|
44 syn keyword cssMediaType contained screen print aural braile embosed handheld projection ty tv all nextgroup=cssMediaComma,cssMediaBlock skipwhite skipnl
|
|
45 syn match cssMediaComma "," nextgroup=cssMediaType skipwhite skipnl
|
|
46 syn region cssMediaBlock transparent matchgroup=cssBraces start='{' end='}' contains=cssTagName,cssError,cssComment,cssDefinition,cssURL,cssUnicodeEscape,cssIdentifier
|
|
47
|
|
48 syn match cssValueInteger contained "[-+]\=\d\+"
|
|
49 syn match cssValueNumber contained "[-+]\=\d\+\(\.\d*\)\="
|
|
50 syn match cssValueLength contained "[-+]\=\d\+\(\.\d*\)\=\(%\|mm\|cm\|in\|pt\|pc\|em\|ex\|px\)"
|
|
51 syn match cssValueAngle contained "[-+]\=\d\+\(\.\d*\)\=\(deg\|grad\|rad\)"
|
|
52 syn match cssValueTime contained "+\=\d\+\(\.\d*\)\=\(ms\|s\)"
|
|
53 syn match cssValueFrequency contained "+\=\d\+\(\.\d*\)\=\(Hz\|kHz\)"
|
|
54
|
|
55 syn match cssFontDescriptor "@font-face\>" nextgroup=cssFontDescriptorBlock skipwhite skipnl
|
|
56 syn region cssFontDescriptorBlock contained transparent matchgroup=cssBraces start="{" end="}" contains=cssComment,cssError,cssUnicodeEscape,cssFontProp,cssFontAttr,cssCommonAttr,cssStringQ,cssStringQQ,cssFontDescriptorProp,cssValue.*,cssFontDescriptorFunction,cssUnicodeRange,cssFontDescriptorAttr
|
|
57 syn match cssFontDescriptorProp contained "\<\(unicode-range\|unit-per-em\|panose-1\|cap-height\|x-height\|definition-src\)\>"
|
|
58 syn keyword cssFontDescriptorProp contained src stemv stemh slope ascent descent widths bbox baseline centerline mathline topline
|
|
59 syn keyword cssFontDescriptorAttr contained all
|
|
60 syn region cssFontDescriptorFunction contained matchgroup=cssFunctionName start="\<\(uri\|url\|local\|format\)\s*(" end=")" contains=cssStringQ,cssStringQQ oneline keepend
|
|
61 syn match cssUnicodeRange contained "U+[0-9A-Fa-f?]\+"
|
|
62 syn match cssUnicodeRange contained "U+\x\+-\x\+"
|
|
63
|
|
64 syn keyword cssColor contained aqua black blue fuchsia gray green lime maroon navy olive purple red silver teal yellow
|
|
65 " FIXME: These are actually case-insentivie too, but (a) specs recommend using
|
|
66 " mixed-case (b) it's hard to highlight the word `Background' correctly in
|
|
67 " all situations
|
|
68 syn case match
|
|
69 syn keyword cssColor contained ActiveBorder ActiveCaption AppWorkspace ButtonFace ButtonHighlight ButtonShadow ButtonText CaptionText GrayText Highlight HighlightText InactiveBorder InactiveCaption InactiveCaptionText InfoBackground InfoText Menu MenuText Scrollbar ThreeDDarkShadow ThreeDFace ThreeDHighlight ThreeDLightShadow ThreeDShadow Window WindowFrame WindowText Background
|
|
70 syn case ignore
|
|
71 syn match cssColor contained "\<transparent\>"
|
|
72 syn match cssColor contained "\<white\>"
|
|
73 syn match cssColor contained "#[0-9A-Fa-f]\{3\}\>"
|
|
74 syn match cssColor contained "#[0-9A-Fa-f]\{6\}\>"
|
|
75 "syn match cssColor contained "\<rgb\s*(\s*\d\+\(\.\d*\)\=%\=\s*,\s*\d\+\(\.\d*\)\=%\=\s*,\s*\d\+\(\.\d*\)\=%\=\s*)"
|
|
76 syn region cssURL contained matchgroup=cssFunctionName start="\<url\s*(" end=")" oneline keepend
|
|
77 syn region cssFunction contained matchgroup=cssFunctionName start="\<\(rgb\|clip\|attr\|counter\|rect\)\s*(" end=")" oneline keepend
|
|
78
|
|
79 syn match cssImportant contained "!\s*important\>"
|
|
80
|
|
81 syn keyword cssCommonAttr contained auto none inherit
|
|
82 syn keyword cssCommonAttr contained top bottom
|
|
83 syn keyword cssCommonAttr contained medium normal
|
|
84
|
|
85 syn match cssFontProp contained "\<font\>\(-\(family\|style\|variant\|weight\|size\(-adjust\)\=\|stretch\)\>\)\="
|
|
86 syn match cssFontAttr contained "\<\(sans-\)\=\<serif\>"
|
|
87 syn match cssFontAttr contained "\<small\>\(-\(caps\|caption\)\>\)\="
|
|
88 syn match cssFontAttr contained "\<x\{1,2\}-\(large\|small\)\>"
|
|
89 syn match cssFontAttr contained "\<message-box\>"
|
|
90 syn match cssFontAttr contained "\<status-bar\>"
|
|
91 syn match cssFontAttr contained "\<\(\(ultra\|extra\|semi\|status-bar\)-\)\=\(condensed\|expanded\)\>"
|
|
92 syn keyword cssFontAttr contained cursive fantasy monospace italic oblique
|
|
93 syn keyword cssFontAttr contained bold bolder lighter larger smaller
|
|
94 syn keyword cssFontAttr contained icon menu
|
|
95 syn match cssFontAttr contained "\<caption\>"
|
|
96 syn keyword cssFontAttr contained large smaller larger
|
|
97 syn keyword cssFontAttr contained narrower wider
|
|
98
|
|
99 syn keyword cssColorProp contained color
|
|
100 syn match cssColorProp contained "\<background\(-\(color\|image\|attachment\|position\)\)\="
|
|
101 syn keyword cssColorAttr contained center scroll fixed
|
|
102 syn match cssColorAttr contained "\<repeat\(-[xy]\)\=\>"
|
|
103 syn match cssColorAttr contained "\<no-repeat\>"
|
|
104
|
|
105 syn match cssTextProp "\<\(\(word\|letter\)-spacing\|text\(-\(decoration\|transform\|align\|index\|shadow\)\)\=\|vertical-align\|unicode-bidi\|line-height\)\>"
|
|
106 syn match cssTextAttr contained "\<line-through\>"
|
|
107 syn match cssTextAttr contained "\<text-indent\>"
|
|
108 syn match cssTextAttr contained "\<\(text-\)\=\(top\|bottom\)\>"
|
|
109 syn keyword cssTextAttr contained underline overline blink sub super middle
|
|
110 syn keyword cssTextAttr contained capitalize uppercase lowercase center justify baseline sub super
|
|
111
|
|
112 syn match cssBoxProp contained "\<\(margin\|padding\|border\)\(-\(top\|right\|bottom\|left\)\)\=\>"
|
|
113 syn match cssBoxProp contained "\<border-\(\(\(top\|right\|bottom\|left\)-\)\=\(width\|color\|style\)\)\=\>"
|
|
114 syn match cssBoxProp contained "\<\(width\|z-index\)\>"
|
|
115 syn match cssBoxProp contained "\<\(min\|max\)-\(width\|height\)\>"
|
|
116 syn keyword cssBoxProp contained width height float clear overflow clip visibility
|
|
117 syn keyword cssBoxAttr contained thin thick both
|
|
118 syn keyword cssBoxAttr contained dotted dashed solid double groove ridge inset outset
|
|
119 syn keyword cssBoxAttr contained hidden visible scroll collapse
|
|
120
|
|
121 syn keyword cssGeneratedContentProp contained content quotes
|
|
122 syn match cssGeneratedContentProp contained "\<counter-\(reset\|increment\)\>"
|
|
123 syn match cssGeneratedContentProp contained "\<list-style\(-\(type\|position\|image\)\)\=\>"
|
|
124 syn match cssGeneratedContentAttr contained "\<\(no-\)\=\(open\|close\)-quote\>"
|
|
125 syn match cssAuralAttr contained "\<lower\>"
|
|
126 syn match cssGeneratedContentAttr contained "\<\(lower\|upper\)-\(roman\|alpha\|greek\|latin\)\>"
|
|
127 syn match cssGeneratedContentAttr contained "\<\(hiragana\|katakana\)\(-iroha\)\=\>"
|
|
128 syn match cssGeneratedContentAttr contained "\<\(decimal\(-leading-zero\)\=\|cjk-ideographic\)\>"
|
|
129 syn keyword cssGeneratedContentAttr contained disc circle square hebrew armenian georgian
|
|
130 syn keyword cssGeneratedContentAttr contained inside outside
|
|
131
|
|
132 syn match cssPagingProp contained "\<page\(-break-\(before\|after\|inside\)\)\=\>"
|
|
133 syn keyword cssPagingProp contained size marks inside orphans widows
|
|
134 syn keyword cssPagingAttr contained landscape portrait crop cross always avoid
|
|
135
|
|
136 syn keyword cssUIProp contained cursor
|
|
137 syn match cssUIProp contained "\<outline\(-\(width\|style\|color\)\)\=\>"
|
|
138 syn match cssUIAttr contained "\<[ns]\=[ew]\=-resize\>"
|
|
139 syn keyword cssUIAttr contained default crosshair pointer move wait help
|
|
140 syn keyword cssUIAttr contained thin thick
|
|
141 syn keyword cssUIAttr contained dotted dashed solid double groove ridge inset outset
|
|
142 syn keyword cssUIAttr contained invert
|
|
143
|
|
144 syn match cssRenderAttr contained "\<marker\>"
|
|
145 syn match cssRenderProp contained "\<\(display\|marker-offset\|unicode-bidi\|white-space\|list-item\|run-in\|inline-table\)\>"
|
|
146 syn keyword cssRenderProp contained position top bottom direction
|
|
147 syn match cssRenderProp contained "\<\(left\|right\)\>"
|
|
148 syn keyword cssRenderAttr contained block inline compact
|
|
149 syn match cssRenderAttr contained "\<table\(-\(row-gorup\|\(header\|footer\)-group\|row\|column\(-group\)\=\|cell\|caption\)\)\=\>"
|
|
150 syn keyword cssRenderAttr contained static relative absolute fixed
|
|
151 syn keyword cssRenderAttr contained ltr rtl embed bidi-override pre nowrap
|
|
152 syn match cssRenderAttr contained "\<bidi-override\>"
|
|
153
|
|
154
|
|
155 syn match cssAuralProp contained "\<\(pause\|cue\)\(-\(before\|after\)\)\=\>"
|
|
156 syn match cssAuralProp contained "\<\(play-during\|speech-rate\|voice-family\|pitch\(-range\)\=\|speak\(-\(punctuation\|numerals\)\)\=\)\>"
|
|
157 syn keyword cssAuralProp contained volume during azimuth elevation stress richness
|
|
158 syn match cssAuralAttr contained "\<\(x-\)\=\(soft\|loud\)\>"
|
|
159 syn keyword cssAuralAttr contained silent
|
|
160 syn match cssAuralAttr contained "\<spell-out\>"
|
|
161 syn keyword cssAuralAttr contained non mix
|
|
162 syn match cssAuralAttr contained "\<\(left\|right\)-side\>"
|
|
163 syn match cssAuralAttr contained "\<\(far\|center\)-\(left\|center\|right\)\>"
|
|
164 syn keyword cssAuralAttr contained leftwards rightwards behind
|
|
165 syn keyword cssAuralAttr contained below level above higher
|
|
166 syn match cssAuralAttr contained "\<\(x-\)\=\(slow\|fast\)\>"
|
|
167 syn keyword cssAuralAttr contained faster slower
|
|
168 syn keyword cssAuralAttr contained male female child code digits continuous
|
|
169
|
|
170 syn match cssTableProp contained "\<\(caption-side\|table-layout\|border-collapse\|border-spacing\|empty-cells\|speak-header\)\>"
|
|
171 syn keyword cssTableAttr contained fixed collapse separate show hide once always
|
|
172
|
|
173 " FIXME: This allows cssMediaBlock before the semicolon, which is wrong.
|
|
174 syn region cssInclude start="@import" end=";" contains=cssComment,cssURL,cssUnicodeEscape,cssMediaType
|
|
175 syn match cssBraces contained "[{}]"
|
|
176 syn match cssError contained "{@<>"
|
|
177 syn region cssDefinition transparent matchgroup=cssBraces start='{' end='}' contains=css.*Attr,css.*Prop,cssComment,cssValue.*,cssColor,cssURL,cssImportant,cssError,cssStringQ,cssStringQQ,cssFunction,cssUnicodeEscape
|
|
178 syn match cssBraceError "}"
|
|
179
|
|
180 syn match cssPseudoClass ":\S*" contains=cssPseudoClassId,cssUnicodeEscape
|
|
181 syn keyword cssPseudoClassId contained link visited active hover focus before after left right
|
|
182 syn match cssPseudoClassId contained "\<first\(-\(line\|letter\|child\)\)\=\>"
|
|
183 syn region cssPseudoClassLang matchgroup=cssPseudoClassId start=":lang(" end=")" oneline
|
|
184
|
|
185 syn region cssComment start="/\*" end="\*/"
|
|
186
|
|
187 syn match cssUnicodeEscape "\\\x\{1,6}\s\?"
|
|
188 syn match cssSpecialCharQQ +\\"+ contained
|
|
189 syn match cssSpecialCharQ +\\'+ contained
|
|
190 syn region cssStringQQ start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=cssUnicodeEscape,cssSpecialCharQQ
|
|
191 syn region cssStringQ start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=cssUnicodeEscape,cssSpecialCharQ
|
|
192
|
|
193 if main_syntax == "css"
|
|
194 syn sync minlines=10
|
|
195 endif
|
|
196
|
|
197 " Define the default highlighting.
|
|
198 " For version 5.7 and earlier: only when not done already
|
|
199 " For version 5.8 and later: only when an item doesn't have highlighting yet
|
|
200 if version >= 508 || !exists("did_css_syn_inits")
|
|
201 if version < 508
|
|
202 let did_css_syn_inits = 1
|
|
203 command -nargs=+ HiLink hi link <args>
|
|
204 else
|
|
205 command -nargs=+ HiLink hi def link <args>
|
|
206 endif
|
|
207
|
|
208 HiLink cssComment Comment
|
|
209 HiLink cssTagName Statement
|
|
210 HiLink cssSelectorOp Special
|
|
211 HiLink cssSelectorOp2 Special
|
|
212 HiLink cssFontProp StorageClass
|
|
213 HiLink cssColorProp StorageClass
|
|
214 HiLink cssTextProp StorageClass
|
|
215 HiLink cssBoxProp StorageClass
|
|
216 HiLink cssRenderProp StorageClass
|
|
217 HiLink cssAuralProp StorageClass
|
|
218 HiLink cssRenderProp StorageClass
|
|
219 HiLink cssGeneratedContentProp StorageClass
|
|
220 HiLink cssPagingProp StorageClass
|
|
221 HiLink cssTableProp StorageClass
|
|
222 HiLink cssUIProp StorageClass
|
|
223 HiLink cssFontAttr Type
|
|
224 HiLink cssColorAttr Type
|
|
225 HiLink cssTextAttr Type
|
|
226 HiLink cssBoxAttr Type
|
|
227 HiLink cssRenderAttr Type
|
|
228 HiLink cssAuralAttr Type
|
|
229 HiLink cssGeneratedContentAttr Type
|
|
230 HiLink cssPagingAttr Type
|
|
231 HiLink cssTableAttr Type
|
|
232 HiLink cssUIAttr Type
|
|
233 HiLink cssCommonAttr Type
|
|
234 HiLink cssPseudoClassId PreProc
|
|
235 HiLink cssPseudoClassLang Constant
|
|
236 HiLink cssValueLength Number
|
|
237 HiLink cssValueInteger Number
|
|
238 HiLink cssValueNumber Number
|
|
239 HiLink cssValueAngle Number
|
|
240 HiLink cssValueTime Number
|
|
241 HiLink cssValueFrequency Number
|
|
242 HiLink cssFunction Constant
|
|
243 HiLink cssURL String
|
|
244 HiLink cssFunctionName Function
|
|
245 HiLink cssColor Constant
|
|
246 HiLink cssIdentifier Function
|
|
247 HiLink cssInclude Include
|
|
248 HiLink cssImportant Special
|
|
249 HiLink cssBraces Function
|
|
250 HiLink cssBraceError Error
|
|
251 HiLink cssError Error
|
|
252 HiLink cssInclude Include
|
|
253 HiLink cssUnicodeEscape Special
|
|
254 HiLink cssStringQQ String
|
|
255 HiLink cssStringQ String
|
|
256 HiLink cssMedia Special
|
|
257 HiLink cssMediaType Special
|
|
258 HiLink cssMediaComma Normal
|
|
259 HiLink cssFontDescriptor Special
|
|
260 HiLink cssFontDescriptorFunction Constant
|
|
261 HiLink cssFontDescriptorProp StorageClass
|
|
262 HiLink cssFontDescriptorAttr Type
|
|
263 HiLink cssUnicodeRange Constant
|
|
264 delcommand HiLink
|
|
265 endif
|
|
266
|
|
267 let b:current_syntax = "css"
|
|
268
|
|
269 if main_syntax == 'css'
|
|
270 unlet main_syntax
|
|
271 endif
|
|
272
|
|
273 " vim: ts=8
|
|
274
|