summaryrefslogtreecommitdiff
path: root/.vim/syntax
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2010-06-21 00:26:12 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2010-06-21 00:26:13 +0200
commit91a34032ca66181a8374daa419dce4d97537b5d5 (patch)
treed25de110ef23706804f484745a0b410328ceb7dc /.vim/syntax
parentd36eb0c0424d926f8b31acc55b10f95aac6f5ba3 (diff)
downloaddotfiles-91a34032ca66181a8374daa419dce4d97537b5d5.tar.gz
dotfiles-91a34032ca66181a8374daa419dce4d97537b5d5.tar.bz2
dotfiles-91a34032ca66181a8374daa419dce4d97537b5d5.zip
Fixed highlighting and xquery and xml syntax
Diffstat (limited to '.vim/syntax')
-rw-r--r--.vim/syntax/xml.vim344
-rw-r--r--.vim/syntax/xquery.vim85
2 files changed, 429 insertions, 0 deletions
diff --git a/.vim/syntax/xml.vim b/.vim/syntax/xml.vim
new file mode 100644
index 0000000..ee976ff
--- /dev/null
+++ b/.vim/syntax/xml.vim
@@ -0,0 +1,344 @@
+" 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 loaded
+if exists("b:current_syntax")
+ finish
+endif
+
+let s:xml_cpo_save = &cpo
+set cpo&vim
+
+syn case match
+
+" mark illegal characters
+syn match xmlError "[<&]"
+
+" strings (inside tags) aka VALUES
+"
+" EXAMPLE:
+"
+" <tag foo.attribute = "value">
+" ^^^^^^^
+syn region xmlString contained start=+"+ end=+"+ contains=xmlEntity,@Spell display
+syn region xmlString contained start=+'+ end=+'+ contains=xmlEntity,@Spell display
+
+
+" punctuation (within attributes) e.g. <tag xml:foo.attribute ...>
+" ^ ^
+" syn match xmlAttribPunct +[-:._]+ contained display
+syn 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
+ \ display
+else
+syn match xmlNamespace
+ \ +\(<\|</\)\@<=[^ /!?<>"':]\+[:]\@=+
+ \ contained
+ \ contains=@xmlNamespaceHook
+ \ display
+endif
+
+
+" tag name
+"
+" PROVIDES: @xmlTagHook
+"
+" EXAMPLE:
+"
+" <tag foo.attribute = "value">
+" ^^^
+"
+syn match xmlTagName
+ \ +[<]\@<=[^ /!?<>"']\++
+ \ contained
+ \ contains=xmlNamespace,xmlAttribPunct,@xmlTagHook
+ \ display
+
+
+if 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
+ \ extend
+
+else
+
+ " 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,@xmlTagHook
+
+endif
+
+
+" &entities; compare with dtd
+syn match xmlEntity "&[^; \t]*;" contains=xmlEntityPunct
+syn 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
+ \ fold
+
+else
+
+ " no syntax folding:
+ " - fold attribute removed
+ "
+ syn region xmlComment
+ \ start=+<!+
+ \ end=+>+
+ \ contains=xmlCommentPart,xmlCommentError
+ \ extend
+
+endif
+
+syn keyword xmlTodo contained TODO FIXME XXX
+syn 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,@xmlCdataHook
+syn match xmlCdataStart +<!\[CDATA\[+ contained contains=xmlCdataCdata
+syn keyword xmlCdataCdata CDATA contained
+syn match xmlCdataEnd +]]>+ contained
+
+
+" Processing instructions
+" This allows "?>" inside strings -- good idea?
+syn region xmlProcessing matchgroup=xmlProcessingDelim start="<?" end="?>" contains=xmlAttrib,xmlEqual,xmlString
+
+
+if 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,xmlString
+else
+
+ " no syntax folding:
+ " - fold attribute removed
+ "
+ syn region xmlDocType matchgroup=xmlDocTypeDecl
+ \ start="<!DOCTYPE"he=s+2,rs=s+2 end=">"
+ \ contains=xmlDocTypeKeyword,xmlInlineDTD,xmlString
+
+endif
+
+syn keyword xmlDocTypeKeyword contained DOCTYPE PUBLIC SYSTEM
+syn region xmlInlineDTD contained matchgroup=xmlDocTypeDecl start="\[" end="]" contains=@xmlDTD
+syn include @xmlDTD syntax/dtd.vim
+unlet 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 +</[^ /!?<>"']\+>+
+endif
+
+syn sync minlines=100
+
+
+" The default highlighting.
+hi def link xmlTodo Todo
+hi def link xmlTag Function
+hi def link xmlTagName Function
+hi def link xmlEndTag Function
+if !exists("g:xml_namespace_transparent")
+ hi def link xmlNamespace Tag
+endif
+hi def link xmlEntity Statement
+hi def link xmlEntityPunct Type
+
+hi def link xmlAttribPunct Comment
+hi def link xmlAttrib Type
+
+hi def link xmlString String
+hi def link xmlComment Comment
+hi def link xmlCommentPart Comment
+hi def link xmlCommentError Error
+hi def link xmlError Error
+
+hi def link xmlProcessingDelim Comment
+hi def link xmlProcessing Type
+
+hi def link xmlCdata String
+hi def link xmlCdataCdata Statement
+hi def link xmlCdataStart Type
+hi def link xmlCdataEnd Type
+
+hi def link xmlDocTypeDecl Function
+hi def link xmlDocTypeKeyword Statement
+hi def link xmlInlineDTD Function
+
+let b:current_syntax = "xml"
+
+let &cpo = s:xml_cpo_save
+unlet s:xml_cpo_save
+
+" vim: ts=8
diff --git a/.vim/syntax/xquery.vim b/.vim/syntax/xquery.vim
new file mode 100644
index 0000000..267f4f1
--- /dev/null
+++ b/.vim/syntax/xquery.vim
@@ -0,0 +1,85 @@
+" Vim syntax file
+" Language: XQuery
+" Author: Jean-Marc Vanel <http://jmvanel.free.fr/>
+" Last Change: mar jui 12 18:04:05 CEST 2005
+" Filenames: *.xq
+" URL: http://jmvanel.free.fr/vim/xquery.vim
+" $Id: xquery.vim,v 1.1 2005/07/18 21:44:56 vimboss Exp $
+
+" REFERENCES:
+" [1] http://www.w3.org/TR/xquery/
+
+" Quit when a syntax file was already loaded
+if exists("b:current_syntax")
+ finish
+endif
+
+" - is allowed in kewords
+setlocal iskeyword+=-
+
+runtime syntax/xml.vim
+
+syn case match
+
+" From XQuery grammar:
+syn keyword xqueryStatement ancestor ancestor-or-self and as ascending at attribute base-uri boundary-space by case cast castable child collation construction declare default descendant descendant-or-self descending div document element else empty encoding eq every except external following following-sibling for function ge greatest gt idiv if import in inherit-namespaces instance intersect is le least let lt mod module namespace ne no of or order ordered ordering parent preceding preceding-sibling preserve return satisfies schema self some stable strip then to treat typeswitch union unordered validate variable version where xmlspace xquery yes
+
+" TODO contains clashes with vim keyword
+syn keyword xqueryFunction abs adjust-date-to-timezone adjust-dateTime-to-timezone adjust-time-to-timezone avg base-uri boolean ceiling codepoint-equal codepoints-to-string collection compare concat count current-date current-dateTime current-time data dateTime day-from-date day-from-dateTime days-from-duration deep-equal default-collation distinct-values doc doc-available document-uri empty ends-with error escape-uri exactly-one exists false floor hours-from-dateTime hours-from-duration hours-from-time id idref implicit-timezone in-scope-prefixes index-of insert-before lang last local-name local-name-from-QName lower-case matches max min minutes-from-dateTime minutes-from-duration minutes-from-time month-from-date month-from-dateTime months-from-duration name namespace-uri namespace-uri-for-prefix namespace-uri-from-QName nilled node-name normalize-space normalize-unicode not number one-or-more position prefix-from-QName QName remove replace resolve-QName resolve-uri reverse root round round-half-to-even seconds-from-dateTime seconds-from-duration seconds-from-time starts-with static-base-uri string string-join string-length string-to-codepoints subsequence substring substring-after substring-before sum timezone-from-date timezone-from-dateTime timezone-from-time tokenize trace translate true unordered upper-case year-from-date year-from-dateTime years-from-duration zero-or-one
+
+syn keyword xqueryOperator add-dayTimeDuration-to-date add-dayTimeDuration-to-dateTime add-dayTimeDuration-to-time add-dayTimeDurations add-yearMonthDuration-to-date add-yearMonthDuration-to-dateTime add-yearMonthDurations base64Binary-equal boolean-equal boolean-greater-than boolean-less-than concatenate date-equal date-greater-than date-less-than dateTime-equal dateTime-greater-than dateTime-less-than dayTimeDuration-equal dayTimeDuration-greater-than dayTimeDuration-less-than divide-dayTimeDuration divide-dayTimeDuration-by-dayTimeDuration divide-yearMonthDuration divide-yearMonthDuration-by-yearMonthDuration except gDay-equal gMonth-equal gMonthDay-equal gYear-equal gYearMonth-equal hexBinary-equal intersect is-same-node multiply-dayTimeDuration multiply-yearMonthDuration node-after node-before NOTATION-equal numeric-add numeric-divide numeric-equal numeric-greater-than numeric-integer-divide numeric-less-than numeric-mod numeric-multiply numeric-subtract numeric-unary-minus numeric-unary-plus QName-equal subtract-dates-yielding-dayTimeDuration subtract-dateTimes-yielding-dayTimeDuration subtract-dayTimeDuration-from-date subtract-dayTimeDuration-from-dateTime subtract-dayTimeDuration-from-time subtract-dayTimeDurations subtract-times subtract-yearMonthDuration-from-date subtract-yearMonthDuration-from-dateTime subtract-yearMonthDurations time-equal time-greater-than time-less-than to union yearMonthDuration-equal yearMonthDuration-greater-than yearMonthDuration-less-than
+
+syn match xqueryType "xs:\(\|Datatype\|primitive\|string\|boolean\|float\|double\|decimal\|duration\|dateTime\|time\|date\|gYearMonth\|gYear\|gMonthDay\|gDay\|gMonth\|hexBinary\|base64Binary\|anyURI\|QName\|NOTATION\|\|normalizedString\|token\|language\|IDREFS\|ENTITIES\|NMTOKEN\|NMTOKENS\|Name\|NCName\|ID\|IDREF\|ENTITY\|integer\|nonPositiveInteger\|negativeInteger\|long\|int\|short\|byte\|nonNegativeInteger\|unsignedLong\|unsignedInt\|unsignedShort\|unsignedByte\|positiveInteger\)"
+
+" From XPath grammar:
+syn keyword xqueryXPath some every in in satisfies if then else to div idiv mod union intersect except instance of treat castable cast eq ne lt le gt ge is child descendant attribute self descendant-or-self following-sibling following namespace parent ancestor preceding-sibling preceding ancestor-or-self void item node document-node text comment processing-instruction attribute schema-attribute schema-element
+
+" eXist extensions
+syn match xqExist "&="
+
+" XQdoc
+syn match XQdoc contained "@\(param\|return\|author\)\>"
+
+highlight def link xqueryStatement Statement
+highlight def link xqueryFunction Function
+highlight def link xqueryOperator Operator
+highlight def link xqueryType Type
+highlight def link xqueryXPath Operator
+highlight def link XQdoc Special
+highlight def link xqExist Operator
+
+"floating point number, with dot, optional exponent
+syn match cFloat "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\="
+"floating point number, starting with a dot, optional exponent
+syn match cFloat "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
+"floating point number, without dot, with exponent
+syn match cFloat "\d\+e[-+]\=\d\+[fl]\=\>"
+syn match cNumber "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>"
+syn match cNumber "\<\d\+\>"
+highlight def link cNumber Number
+highlight def link cFloat Number
+
+syn region xqComment start='(:' excludenl end=':)' contains=XQdoc
+highlight def link xqComment Comment
+" syntax match xqVariable "$\w\+"
+syntax match xqVariable +$\<[a-zA-Z:_][-.0-9a-zA-Z0-9:_]*\>+
+highlight def link xqVariable Identifier
+
+" Redefine the default XML highlighting:
+highlight def link xmlTag Structure
+highlight def link xmlTagName Structure
+highlight def link xmlEndTag Structure
+
+syntax match xqSeparator ",\|;"
+highlight link xqSeparator Operator
+
+syn region xqString start=+"+ end=+"+
+highlight def link xqString String
+
+syn region xqCode transparent contained start='{' excludenl end='}' contains=xmlRegionBis,xqComment,xqueryStatement,xmlString,xqSeparator,cNumber,xqVariable,xqString keepend extend
+
+syn region xmlRegionBis start=+<\z([^ /!?<>"']\+\)+ skip=+<!--\_.\{-}-->+ end=+</\z1\_\s\{-}>+ end=+/>+ fold contains=xmlTag,xmlEndTag,xmlCdata,xmlRegionBis,xmlComment,xmlEntity,xmlProcessing,xqCode keepend extend
+
+syn region List transparent start='(' excludenl end=')' contains=xqCode,xmlRegion,xqComment,xqSeparator,xqueryStatement,xqVariable,xqueryType,xqString,xqueryFunction keepend extend
+
+