mirror of
https://github.com/neovim/neovim.git
synced 2026-07-09 02:49:37 +00:00
vim-patch:d859e12: runtime(xml): Update xml syntax file
Improve performance
related: chrisbra/vim-xml-runtime#36
d859e128a8
Co-authored-by: Christian Brabandt <cb@256bit.org>
Co-Authored-by: Dmytro Meleshko <dmytro.meleshko@gmail.com>
This commit is contained in:
@@ -4,13 +4,14 @@
|
||||
" Repository: https://github.com/chrisbra/vim-xml-ftplugin
|
||||
" Previous Maintainer: Johannes Zellner <johannes@zellner.org>
|
||||
" Author: Paul Siegmann <pauls@euronet.nl>
|
||||
" Last Changed: Nov 03, 2019
|
||||
" Last Changed: 30 Jun 2026
|
||||
" Filenames: *.xml
|
||||
" Last Change:
|
||||
" 20190923 - Fix xmlEndTag to match xmlTag (vim/vim#884)
|
||||
" 20190924 - Fix xmlAttribute property (amadeus/vim-xml@d8ce1c946)
|
||||
" 20191103 - Enable spell checking globally
|
||||
" 20210428 - Improve syntax synchronizing
|
||||
" 20260630 - Improve performance
|
||||
|
||||
" CONFIGURATION:
|
||||
" syntax folding can be turned on by
|
||||
@@ -61,7 +62,8 @@ syn case match
|
||||
syn spell toplevel
|
||||
|
||||
" mark illegal characters
|
||||
syn match xmlError "[<&]"
|
||||
syn match xmlError "<"
|
||||
syn match xmlError "&"
|
||||
|
||||
" strings (inside tags) aka VALUES
|
||||
"
|
||||
@@ -92,12 +94,18 @@ syn match xmlEqual +=+ display
|
||||
" ^^^^^^^^^^^^^
|
||||
"
|
||||
syn match xmlAttrib
|
||||
\ +[-'"<]\@1<!\<[a-zA-Z:_][-.0-9a-zA-Z:_]*\>\%(['"]\@!\|$\)+
|
||||
\ +\%#=1[-/!?<>"']\@1<!\<[a-zA-Z:_][-.0-9a-zA-Z:_]*\>['"]\@!+
|
||||
\ contained
|
||||
\ contains=xmlAttribPunct,@xmlAttribHook
|
||||
\ display
|
||||
|
||||
|
||||
if exists("g:xml_namespace_transparent")
|
||||
command! -nargs=+ XmlTransparent <args> transparent
|
||||
else
|
||||
command! -nargs=+ XmlTransparent <args>
|
||||
endif
|
||||
|
||||
" namespace spec
|
||||
"
|
||||
" PROVIDES: @xmlNamespaceHook
|
||||
@@ -107,20 +115,18 @@ syn match xmlAttrib
|
||||
" <xsl:for-each select = "lola">
|
||||
" ^^^
|
||||
"
|
||||
if exists("g:xml_namespace_transparent")
|
||||
syn match xmlNamespace
|
||||
\ +\(<\|</\)\@2<=[^ /!?<>"':]\+[:]\@=+
|
||||
\ contained
|
||||
\ contains=@xmlNamespaceHook
|
||||
\ transparent
|
||||
\ display
|
||||
else
|
||||
syn match xmlNamespace
|
||||
\ +\(<\|</\)\@2<=[^ /!?<>"':]\+[:]\@=+
|
||||
XmlTransparent syn match xmlNamespace
|
||||
\ +<[^ /!?<>"':]\+\ze:+lc=1
|
||||
\ contained
|
||||
\ contains=@xmlNamespaceHook
|
||||
\ display
|
||||
endif
|
||||
XmlTransparent syn match xmlNamespace
|
||||
\ +</[^ /!?<>"':]\+\ze:+lc=2
|
||||
\ contained
|
||||
\ contains=@xmlNamespaceHook
|
||||
\ display
|
||||
|
||||
delcommand XmlTransparent
|
||||
|
||||
|
||||
" tag name
|
||||
@@ -133,47 +139,60 @@ endif
|
||||
" ^^^
|
||||
"
|
||||
syn match xmlTagName
|
||||
\ +\%(<\|</\)\@2<=[^ /!?<>"']\++
|
||||
\ +<[^ /!?<>"']\++lc=1
|
||||
\ contained
|
||||
\ contains=xmlNamespace,xmlAttribPunct,@xmlTagHook
|
||||
\ display
|
||||
syn match xmlTagName
|
||||
\ +</[^ /!?<>"']\++lc=2
|
||||
\ contained
|
||||
\ contains=xmlNamespace,xmlAttribPunct,@xmlTagHook
|
||||
\ display
|
||||
|
||||
|
||||
if exists('g:xml_syntax_folding')
|
||||
command! -nargs=+ XmlContained <args> contained
|
||||
command! -nargs=+ XmlFold <args> fold
|
||||
else
|
||||
command! -nargs=+ XmlContained <args>
|
||||
command! -nargs=+ XmlFold <args>
|
||||
endif
|
||||
|
||||
" start tag
|
||||
" use matchgroup=xmlTag to skip over the leading '<'
|
||||
"
|
||||
" PROVIDES: @xmlStartTagHook
|
||||
"
|
||||
" EXAMPLE:
|
||||
"
|
||||
" <tag id="whoops">
|
||||
" s^^^^^^^^^^^^^^^e
|
||||
"
|
||||
syn region xmlTag
|
||||
\ matchgroup=xmlTag start=+<[^ /!?<>"']\@=+
|
||||
" start tag
|
||||
" use matchgroup=xmlTag to skip over the leading '<'
|
||||
"
|
||||
" PROVIDES: @xmlStartTagHook
|
||||
"
|
||||
" EXAMPLE:
|
||||
"
|
||||
" <tag id="whoops">
|
||||
" s^^^^^^^^^^^^^^^e
|
||||
"
|
||||
XmlContained syn region xmlTag
|
||||
\ matchgroup=xmlTag start=+<\ze[^ /!?<>"']+
|
||||
\ 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 region xmlEndTag
|
||||
\ matchgroup=xmlTag start=+</[^ /!?<>"']\@=+
|
||||
" highlight the end tag
|
||||
"
|
||||
" PROVIDES: @xmlTagHook
|
||||
" (should we provide a separate @xmlEndTagHook ?)
|
||||
"
|
||||
" EXAMPLE:
|
||||
"
|
||||
" </tag>
|
||||
" ^^^^^^
|
||||
"
|
||||
XmlContained syn region xmlEndTag
|
||||
\ matchgroup=xmlTag start=+</\ze[^ /!?<>"']+
|
||||
\ matchgroup=xmlTag end=+>+
|
||||
\ contained
|
||||
\ contains=xmlTagName,xmlNamespace,xmlAttribPunct,@xmlTagHook
|
||||
|
||||
delcommand XmlContained
|
||||
|
||||
|
||||
if exists('g:xml_syntax_folding')
|
||||
" tag elements with syntax-folding.
|
||||
" NOTE: NO HIGHLIGHTING -- highlighting is done by contained elements
|
||||
"
|
||||
@@ -197,23 +216,6 @@ if exists('g:xml_syntax_folding')
|
||||
\ 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 region xmlEndTag
|
||||
\ matchgroup=xmlTag start=+</[^ /!?<>"']\@=+
|
||||
\ matchgroup=xmlTag end=+>+
|
||||
\ contains=xmlTagName,xmlNamespace,xmlAttribPunct,@xmlTagHook
|
||||
|
||||
endif
|
||||
|
||||
|
||||
@@ -221,29 +223,13 @@ endif
|
||||
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
|
||||
" The real comments (this implements the comments as defined by xml,
|
||||
" but not all xml pages actually conform to it. Errors are flagged.
|
||||
XmlFold syn region xmlComment
|
||||
\ start=+<!+
|
||||
\ end=+>+
|
||||
\ contains=xmlCommentStart,xmlCommentError
|
||||
\ extend
|
||||
\ fold
|
||||
|
||||
else
|
||||
|
||||
" no syntax folding:
|
||||
" - fold attribute removed
|
||||
"
|
||||
syn region xmlComment
|
||||
\ start=+<!+
|
||||
\ end=+>+
|
||||
\ contains=xmlCommentStart,xmlCommentError
|
||||
\ extend
|
||||
|
||||
endif
|
||||
|
||||
syn match xmlCommentStart contained "<!" nextgroup=xmlCommentPart
|
||||
syn keyword xmlTodo contained TODO FIXME XXX
|
||||
@@ -278,23 +264,12 @@ syn match xmlCdataEnd +]]>+ contained
|
||||
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
|
||||
" DTD -- we use dtd.vim here
|
||||
XmlFold syn region xmlDocType matchgroup=xmlDocTypeDecl
|
||||
\ start="<!DOCTYPE"he=s+2,rs=s+2 end=">"
|
||||
\ contains=xmlDocTypeKeyword,xmlInlineDTD,xmlString
|
||||
|
||||
endif
|
||||
delcommand XmlFold
|
||||
|
||||
syn keyword xmlDocTypeKeyword contained DOCTYPE PUBLIC SYSTEM
|
||||
syn region xmlInlineDTD contained matchgroup=xmlDocTypeDecl start="\[" end="]" contains=@xmlDTD
|
||||
|
||||
Reference in New Issue
Block a user