Add support for :winpos
[MacVim.git] / runtime / syntax / sgml.vim
blobc0c3643dd29d5f3f9e7bde47781c9e127ee843a6
1 " Vim syntax file
2 " Language:     SGML
3 " Maintainer:   Johannes Zellner <johannes@zellner.org>
4 " Last Change:  Tue, 27 Apr 2004 15:05:21 CEST
5 " Filenames:    *.sgml,*.sgm
6 " $Id: sgml.vim,v 1.1 2004/06/13 17:52:57 vimboss Exp $
8 " For version 5.x: Clear all syntax items
9 " For version 6.x: Quit when a syntax file was already loaded
10 if version < 600
11   syntax clear
12 elseif exists("b:current_syntax")
13   finish
14 endif
16 let s:sgml_cpo_save = &cpo
17 set cpo&vim
19 syn case match
21 " mark illegal characters
22 syn match sgmlError "[<&]"
25 " unicode numbers:
26 " provide different highlithing for unicode characters
27 " inside strings and in plain text (character data).
29 " EXAMPLE:
31 " \u4e88
33 syn match   sgmlUnicodeNumberAttr    +\\u\x\{4}+ contained contains=sgmlUnicodeSpecifierAttr
34 syn match   sgmlUnicodeSpecifierAttr +\\u+ contained
35 syn match   sgmlUnicodeNumberData    +\\u\x\{4}+ contained contains=sgmlUnicodeSpecifierData
36 syn match   sgmlUnicodeSpecifierData +\\u+ contained
39 " strings inside character data or comments
41 syn region  sgmlString contained start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=sgmlEntity,sgmlUnicodeNumberAttr display
42 syn region  sgmlString contained start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=sgmlEntity,sgmlUnicodeNumberAttr display
44 " punctuation (within attributes) e.g. <tag sgml:foo.attribute ...>
45 "                                               ^   ^
46 syn match   sgmlAttribPunct +[:.]+ contained display
49 " no highlighting for sgmlEqual (sgmlEqual has no highlighting group)
50 syn match   sgmlEqual +=+
53 " attribute, everything before the '='
55 " PROVIDES: @sgmlAttribHook
57 " EXAMPLE:
59 " <tag foo.attribute = "value">
60 "      ^^^^^^^^^^^^^
62 syn match   sgmlAttrib
63     \ +[^-'"<]\@<=\<[a-zA-Z0-9.:]\+\>\([^'">]\@=\|$\)+
64     \ contained
65     \ contains=sgmlAttribPunct,@sgmlAttribHook
66     \ display
69 " UNQUOTED value (not including the '=' -- sgmlEqual)
71 " PROVIDES: @sgmlValueHook
73 " EXAMPLE:
75 " <tag foo.attribute = value>
76 "                      ^^^^^
78 syn match   sgmlValue
79     \ +[^"' =/!?<>][^ =/!?<>]*+
80     \ contained
81     \ contains=sgmlEntity,sgmlUnicodeNumberAttr,@sgmlValueHook
82     \ display
85 " QUOTED value (not including the '=' -- sgmlEqual)
87 " PROVIDES: @sgmlValueHook
89 " EXAMPLE:
91 " <tag foo.attribute = "value">
92 "                      ^^^^^^^
93 " <tag foo.attribute = 'value'>
94 "                      ^^^^^^^
96 syn region  sgmlValue contained start=+"+ skip=+\\\\\|\\"+ end=+"+
97             \ contains=sgmlEntity,sgmlUnicodeNumberAttr,@sgmlValueHook
98 syn region  sgmlValue contained start=+'+ skip=+\\\\\|\\'+ end=+'+
99             \ contains=sgmlEntity,sgmlUnicodeNumberAttr,@sgmlValueHook
102 " value, everything after (and including) the '='
103 " no highlighting!
105 " EXAMPLE:
107 " <tag foo.attribute = "value">
108 "                    ^^^^^^^^^
109 " <tag foo.attribute = value>
110 "                    ^^^^^^^
112 syn match   sgmlEqualValue
113     \ +=\s*[^ =/!?<>]\++
114     \ contained
115     \ contains=sgmlEqual,sgmlString,sgmlValue
116     \ display
119 " start tag
120 " use matchgroup=sgmlTag to skip over the leading '<'
121 " see also sgmlEmptyTag below.
123 " PROVIDES: @sgmlTagHook
125 syn region   sgmlTag
126     \ matchgroup=sgmlTag start=+<[^ /!?"']\@=+
127     \ matchgroup=sgmlTag end=+>+
128     \ contained
129     \ contains=sgmlError,sgmlAttrib,sgmlEqualValue,@sgmlTagHook
132 " tag content for empty tags. This is the same as sgmlTag
133 " above, except the `matchgroup=sgmlEndTag for highlighting
134 " the end '/>' differently.
136 " PROVIDES: @sgmlTagHook
138 syn region   sgmlEmptyTag
139     \ matchgroup=sgmlTag start=+<[^ /!?"']\@=+
140     \ matchgroup=sgmlEndTag end=+/>+
141     \ contained
142     \ contains=sgmlError,sgmlAttrib,sgmlEqualValue,@sgmlTagHook
145 " end tag
146 " highlight everything but not the trailing '>' which
147 " was already highlighted by the containing sgmlRegion.
149 " PROVIDES: @sgmlTagHook
150 " (should we provide a separate @sgmlEndTagHook ?)
152 syn match   sgmlEndTag
153     \ +</[^ /!?>"']\+>+
154     \ contained
155     \ contains=@sgmlTagHook
158 " [-- SGML SPECIFIC --]
160 " SGML specific
161 " tag content for abbreviated regions
163 " PROVIDES: @sgmlTagHook
165 syn region   sgmlAbbrTag
166     \ matchgroup=sgmlTag start=+<[^ /!?"']\@=+
167     \ matchgroup=sgmlTag end=+/+
168     \ contained
169     \ contains=sgmlError,sgmlAttrib,sgmlEqualValue,@sgmlTagHook
172 " SGML specific
173 " just highlight the trailing '/'
174 syn match   sgmlAbbrEndTag +/+
177 " SGML specific
178 " abbreviated regions
180 " No highlighing, highlighing is done by contained elements.
182 " PROVIDES: @sgmlRegionHook
184 " EXAMPLE:
186 " <bold/Im Anfang war das Wort/
188 syn match   sgmlAbbrRegion
189     \ +<[^/!?>"']\+/\_[^/]\+/+
190     \ contains=sgmlAbbrTag,sgmlAbbrEndTag,sgmlCdata,sgmlComment,sgmlEntity,sgmlUnicodeNumberData,@sgmlRegionHook
192 " [-- END OF SGML SPECIFIC --]
195 " real (non-empty) elements. We cannot do syntax folding
196 " as in xml, because end tags may be optional in sgml depending
197 " on the dtd.
198 " No highlighing, highlighing is done by contained elements.
200 " PROVIDES: @sgmlRegionHook
202 " EXAMPLE:
204 " <tag id="whoops">
205 "   <!-- comment -->
206 "   <another.tag></another.tag>
207 "   <another.tag/>
208 "   some data
209 " </tag>
211 " SGML specific:
212 " compared to xmlRegion:
213 "   - removed folding
214 "   - added a single '/'in the start pattern
216 syn region   sgmlRegion
217     \ start=+<\z([^ /!?>"']\+\)\(\(\_[^/>]*[^/!?]>\)\|>\)+
218     \ end=+</\z1>+
219     \ contains=sgmlTag,sgmlEndTag,sgmlCdata,@sgmlRegionCluster,sgmlComment,sgmlEntity,sgmlUnicodeNumberData,@sgmlRegionHook
220     \ keepend
221     \ extend
224 " empty tags. Just a container, no highlighting.
225 " Compare this with sgmlTag.
227 " EXAMPLE:
229 " <tag id="lola"/>
231 " TODO use sgmlEmptyTag intead of sgmlTag
232 syn match    sgmlEmptyRegion
233     \ +<[^ /!?>"']\(\_[^"'<>]\|"\_[^"]*"\|'\_[^']*'\)*/>+
234     \ contains=sgmlEmptyTag
237 " cluster which contains the above two elements
238 syn cluster sgmlRegionCluster contains=sgmlRegion,sgmlEmptyRegion,sgmlAbbrRegion
241 " &entities; compare with dtd
242 syn match   sgmlEntity                 "&[^; \t]*;" contains=sgmlEntityPunct
243 syn match   sgmlEntityPunct  contained "[&.;]"
246 " The real comments (this implements the comments as defined by sgml,
247 " but not all sgml pages actually conform to it. Errors are flagged.
248 syn region  sgmlComment                start=+<!+        end=+>+ contains=sgmlCommentPart,sgmlString,sgmlCommentError,sgmlTodo
249 syn keyword sgmlTodo         contained TODO FIXME XXX display
250 syn match   sgmlCommentError contained "[^><!]"
251 syn region  sgmlCommentPart  contained start=+--+        end=+--+
254 " CData sections
256 " PROVIDES: @sgmlCdataHook
258 syn region    sgmlCdata
259     \ start=+<!\[CDATA\[+
260     \ end=+]]>+
261     \ contains=sgmlCdataStart,sgmlCdataEnd,@sgmlCdataHook
262     \ keepend
263     \ extend
264 " using the following line instead leads to corrupt folding at CDATA regions
265 " syn match    sgmlCdata      +<!\[CDATA\[\_.\{-}]]>+  contains=sgmlCdataStart,sgmlCdataEnd,@sgmlCdataHook
266 syn match    sgmlCdataStart +<!\[CDATA\[+  contained contains=sgmlCdataCdata
267 syn keyword  sgmlCdataCdata CDATA          contained
268 syn match    sgmlCdataEnd   +]]>+          contained
271 " Processing instructions
272 " This allows "?>" inside strings -- good idea?
273 syn region  sgmlProcessing matchgroup=sgmlProcessingDelim start="<?" end="?>" contains=sgmlAttrib,sgmlEqualValue
276 " DTD -- we use dtd.vim here
277 syn region  sgmlDocType matchgroup=sgmlDocTypeDecl start="\c<!DOCTYPE"he=s+2,rs=s+2 end=">" contains=sgmlDocTypeKeyword,sgmlInlineDTD,sgmlString
278 syn keyword sgmlDocTypeKeyword contained DOCTYPE PUBLIC SYSTEM
279 syn region  sgmlInlineDTD contained start="\[" end="]" contains=@sgmlDTD
280 syn include @sgmlDTD <sfile>:p:h/dtd.vim
283 " synchronizing
284 " TODO !!! to be improved !!!
286 syn sync match sgmlSyncDT grouphere  sgmlDocType +\_.\(<!DOCTYPE\)\@=+
287 " syn sync match sgmlSyncDT groupthere  NONE       +]>+
289 syn sync match sgmlSync grouphere   sgmlRegion  +\_.\(<[^ /!?>"']\+\)\@=+
290 " syn sync match sgmlSync grouphere  sgmlRegion "<[^ /!?>"']*>"
291 syn sync match sgmlSync groupthere  sgmlRegion  +</[^ /!?>"']\+>+
293 syn sync minlines=100
296 " The default highlighting.
297 hi def link sgmlTodo                    Todo
298 hi def link sgmlTag                     Function
299 hi def link sgmlEndTag                  Identifier
300 " SGML specifig
301 hi def link sgmlAbbrEndTag              Identifier
302 hi def link sgmlEmptyTag                Function
303 hi def link sgmlEntity                  Statement
304 hi def link sgmlEntityPunct             Type
306 hi def link sgmlAttribPunct             Comment
307 hi def link sgmlAttrib                  Type
309 hi def link sgmlValue                   String
310 hi def link sgmlString                  String
311 hi def link sgmlComment                 Comment
312 hi def link sgmlCommentPart             Comment
313 hi def link sgmlCommentError            Error
314 hi def link sgmlError                   Error
316 hi def link sgmlProcessingDelim         Comment
317 hi def link sgmlProcessing              Type
319 hi def link sgmlCdata                   String
320 hi def link sgmlCdataCdata              Statement
321 hi def link sgmlCdataStart              Type
322 hi def link sgmlCdataEnd                Type
324 hi def link sgmlDocTypeDecl             Function
325 hi def link sgmlDocTypeKeyword          Statement
326 hi def link sgmlInlineDTD               Function
327 hi def link sgmlUnicodeNumberAttr       Number
328 hi def link sgmlUnicodeSpecifierAttr    SpecialChar
329 hi def link sgmlUnicodeNumberData       Number
330 hi def link sgmlUnicodeSpecifierData    SpecialChar
332 let b:current_syntax = "sgml"
334 let &cpo = s:sgml_cpo_save
335 unlet s:sgml_cpo_save
337 " vim: ts=8