All pastes #1030136 Raw Edit

Miscellany

public text v1 · immutable
#1030136 ·published 2008-05-26 17:07 UTC
rendered paste body
" Vim syntax file" Language:	XML" Maintainer:	Johannes Zellner <johannes@zellner.org>"		Author and previous maintainer:"		Paul Siegmann <pauls@euronet.nl>" Last Change:	Mi, 13 Apr 2005 22:40:09 CEST" Filenames:	*.xml" $Id: xml.vim,v 1.3 2006/04/11 21:32:00 vimboss Exp $" CONFIGURATION:"   syntax folding can be turned on by""      let g:xml_syntax_folding = 1""   before the syntax file gets loaded (e.g. in ~/.vimrc)."   This might slow down syntax highlighting significantly,"   especially for large files."" CREDITS:"   The original version was derived by Paul Siegmann from"   Claudio Fleiner's html.vim."" REFERENCES:"   [1] http://www.w3.org/TR/2000/REC-xml-20001006"   [2] http://www.w3.org/XML/1998/06/xmlspec-report-19980910.htm""   as <hirauchi@kiwi.ne.jp> pointed out according to reference [1]""   2.3 Common Syntactic Constructs"   [4]    NameChar    ::=    Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender"   [5]    Name        ::=    (Letter | '_' | ':') (NameChar)*"" NOTE:"   1) empty tag delimiters "/>" inside attribute values (strings)"      confuse syntax highlighting."   2) for large files, folding can be pretty slow, especially when"      loading a file the first time and viewoptions contains 'folds'"      so that folds of previous sessions are applied."      Don't use 'foldmethod=syntax' in this case." Quit when a syntax file was already loadedif exists("b:current_syntax")    finishendiflet s:xml_cpo_save = &cposet cpo&vimsyn case match" mark illegal characterssyn match xmlError "[<&]"" strings (inside tags) aka VALUES"" EXAMPLE:"" <tag foo.attribute = "value">"                      ^^^^^^^syn region  xmlString contained start=+"+ end=+"+ contains=xmlEntity,@Spell displaysyn region  xmlString contained start=+'+ end=+'+ contains=xmlEntity,@Spell display" punctuation (within attributes) e.g. <tag xml:foo.attribute ...>"                                              ^   ^" syn match   xmlAttribPunct +[-:._]+ contained displaysyn match   xmlAttribPunct +[:.]+ contained display" no highlighting for xmlEqual (xmlEqual has no highlighting group)syn match   xmlEqual +=+ display" attribute, everything before the '='"" PROVIDES: @xmlAttribHook"" EXAMPLE:"" <tag foo.attribute = "value">"      ^^^^^^^^^^^^^"syn match   xmlAttrib    \ +[-'"<]\@<!\<[a-zA-Z:_][-.0-9a-zA-Z0-9:_]*\>\(['">]\@!\|$\)+    \ contained    \ contains=xmlAttribPunct,@xmlAttribHook    \ display" namespace spec"" PROVIDES: @xmlNamespaceHook"" EXAMPLE:"" <xsl:for-each select = "lola">"  ^^^"if exists("g:xml_namespace_transparent")syn match   xmlNamespace    \ +\(<\|</\)\@<=[^ /!?<>"':]\+[:]\@=+    \ contained    \ contains=@xmlNamespaceHook    \ transparent    \ displayelsesyn match   xmlNamespace    \ +\(<\|</\)\@<=[^ /!?<>"':]\+[:]\@=+    \ contained    \ contains=@xmlNamespaceHook    \ displayendif" tag name"" PROVIDES: @xmlTagHook"" EXAMPLE:"" <tag foo.attribute = "value">"  ^^^"syn match   xmlTagName    \ +[<]\@<=[^ /!?<>"']\++    \ contained    \ contains=xmlNamespace,xmlAttribPunct,@xmlTagHook    \ displayif exists('g:xml_syntax_folding')    " start tag    " use matchgroup=xmlTag to skip over the leading '<'    "    " PROVIDES: @xmlStartTagHook    "    " EXAMPLE:    "    " <tag id="whoops">    " s^^^^^^^^^^^^^^^e    "    syn region   xmlTag	\ matchgroup=xmlTag start=+<[^ /!?<>"']\@=+	\ matchgroup=xmlTag end=+>+	\ contained	\ contains=xmlError,xmlTagName,xmlAttrib,xmlEqual,xmlString,@xmlStartTagHook    " highlight the end tag    "    " PROVIDES: @xmlTagHook    " (should we provide a separate @xmlEndTagHook ?)    "    " EXAMPLE:    "    " </tag>    " ^^^^^^    "    syn match   xmlEndTag	\ +</[^ /!?<>"']\+>+	\ contained	\ contains=xmlNamespace,xmlAttribPunct,@xmlTagHook    " tag elements with syntax-folding.    " NOTE: NO HIGHLIGHTING -- highlighting is done by contained elements    "    " PROVIDES: @xmlRegionHook    "    " EXAMPLE:    "    " <tag id="whoops">    "   <!-- comment -->    "   <another.tag></another.tag>    "   <empty.tag/>    "   some data    " </tag>    "    syn region   xmlRegion	\ start=+<\z([^ /!?<>"']\+\)+	\ skip=+<!--\_.\{-}-->+	\ end=+</\z1\_\s\{-}>+	\ matchgroup=xmlEndTag end=+/>+	\ fold	\ contains=xmlTag,xmlEndTag,xmlCdata,xmlRegion,xmlComment,xmlEntity,xmlProcessing,@xmlRegionHook,@Spell	\ keepend	\ extendelse    " no syntax folding:    " - contained attribute removed    " - xmlRegion not defined    "    syn region   xmlTag	\ matchgroup=xmlTag start=+<[^ /!?<>"']\@=+	\ matchgroup=xmlTag end=+>+	\ contains=xmlError,xmlTagName,xmlAttrib,xmlEqual,xmlString,@xmlStartTagHook    syn match   xmlEndTag	\ +</[^ /!?<>"']\+>+	\ contains=xmlNamespace,xmlAttribPunct,@xmlTagHookendif" &entities; compare with dtdsyn match   xmlEntity                 "&[^; \t]*;" contains=xmlEntityPunctsyn match   xmlEntityPunct  contained "[&.;]"if exists('g:xml_syntax_folding')    " The real comments (this implements the comments as defined by xml,    " but not all xml pages actually conform to it. Errors are flagged.    syn region  xmlComment	\ start=+<!+	\ end=+>+	\ contains=xmlCommentPart,xmlCommentError	\ extend	\ foldelse    " no syntax folding:    " - fold attribute removed    "    syn region  xmlComment	\ start=+<!+	\ end=+>+	\ contains=xmlCommentPart,xmlCommentError	\ extendendifsyn keyword xmlTodo         contained TODO FIXME XXXsyn match   xmlCommentError contained "[^><!]"syn region  xmlCommentPart    \ start=+--+    \ end=+--+    \ contained    \ contains=xmlTodo,@xmlCommentHook,@Spell" CData sections"" PROVIDES: @xmlCdataHook"syn region    xmlCdata    \ start=+<!\[CDATA\[+    \ end=+]]>+    \ contains=xmlCdataStart,xmlCdataEnd,@xmlCdataHook,@Spell    \ keepend    \ extend" using the following line instead leads to corrupt folding at CDATA regions" syn match    xmlCdata      +<!\[CDATA\[\_.\{-}]]>+  contains=xmlCdataStart,xmlCdataEnd,@xmlCdataHooksyn match    xmlCdataStart +<!\[CDATA\[+  contained contains=xmlCdataCdatasyn keyword  xmlCdataCdata CDATA          containedsyn match    xmlCdataEnd   +]]>+          contained" Processing instructions" This allows "?>" inside strings -- good idea?syn region  xmlProcessing matchgroup=xmlProcessingDelim start="<?" end="?>" contains=xmlAttrib,xmlEqual,xmlStringif exists('g:xml_syntax_folding')    " DTD -- we use dtd.vim here    syn region  xmlDocType matchgroup=xmlDocTypeDecl	\ start="<!DOCTYPE"he=s+2,rs=s+2 end=">"	\ fold	\ contains=xmlDocTypeKeyword,xmlInlineDTD,xmlStringelse    " no syntax folding:    " - fold attribute removed    "    syn region  xmlDocType matchgroup=xmlDocTypeDecl	\ start="<!DOCTYPE"he=s+2,rs=s+2 end=">"	\ contains=xmlDocTypeKeyword,xmlInlineDTD,xmlStringendifsyn keyword xmlDocTypeKeyword contained DOCTYPE PUBLIC SYSTEMsyn region  xmlInlineDTD contained matchgroup=xmlDocTypeDecl start="\[" end="]" contains=@xmlDTDsyn include @xmlDTD <sfile>:p:h/dtd.vimunlet b:current_syntax" synchronizing" TODO !!! to be improved !!!syn sync match xmlSyncDT grouphere  xmlDocType +\_.\(<!DOCTYPE\)\@=+" syn sync match xmlSyncDT groupthere  NONE       +]>+if exists('g:xml_syntax_folding')    syn sync match xmlSync grouphere   xmlRegion  +\_.\(<[^ /!?<>"']\+\)\@=+    " syn sync match xmlSync grouphere  xmlRegion "<[^ /!?<>"']*>"    syn sync match xmlSync groupthere  xmlRegion  +</[^ /!?<>"']\+>+endifsyn sync minlines=100" The default highlighting.hi def link xmlTodo		Todohi def link xmlTag		Functionhi def link xmlTagName		Functionhi def link xmlEndTag		Identifierif !exists("g:xml_namespace_transparent")    hi def link xmlNamespace	Tagendifhi def link xmlEntity		Statementhi def link xmlEntityPunct	Typehi def link xmlAttribPunct	Commenthi def link xmlAttrib		Typehi def link xmlString		Stringhi def link xmlComment		Commenthi def link xmlCommentPart	Commenthi def link xmlCommentError	Errorhi def link xmlError		Errorhi def link xmlProcessingDelim	Commenthi def link xmlProcessing	Typehi def link xmlCdata		Stringhi def link xmlCdataCdata	Statementhi def link xmlCdataStart	Typehi def link xmlCdataEnd		Typehi def link xmlDocTypeDecl	Functionhi def link xmlDocTypeKeyword	Statementhi def link xmlInlineDTD	Functionlet b:current_syntax = "xml"let &cpo = s:xml_cpo_saveunlet s:xml_cpo_save" vim: ts=8