Switch jsx provider to amadeus, closes #364
This commit is contained in:
parent
4f0bde6d67
commit
2c59360e01
@ -8,7 +8,7 @@ A collection of language packs for Vim.
|
||||
> One to rule them all, one to find them, one to bring them all and in the darkness bind them.
|
||||
|
||||
- It **won't affect your startup time**, as scripts are loaded only on demand\*.
|
||||
- It **installs and updates 100+ times faster** than the <!--Package Count-->125<!--/Package Count--> packages it consists of.
|
||||
- It **installs and updates 100+ times faster** than the <!--Package Count-->126<!--/Package Count--> packages it consists of.
|
||||
- Solid syntax and indentation support (other features skipped). Only the best language packs.
|
||||
- All unnecessary files are ignored (like enormous documentation from php support).
|
||||
- No support for esoteric languages, only most popular ones (modern too, like `slim`).
|
||||
@ -97,7 +97,7 @@ If you need full functionality of any plugin, please use it directly with your p
|
||||
- [json5](https://github.com/GutenYe/json5.vim) (syntax)
|
||||
- [json](https://github.com/elzr/vim-json) (syntax, indent, ftplugin)
|
||||
- [jst](https://github.com/briancollins/vim-jst) (syntax, indent)
|
||||
- [jsx](https://github.com/mxw/vim-jsx) (after)
|
||||
- [jsx](https://github.com/amadeus/vim-jsx) (syntax, indent, ftplugin)
|
||||
- [julia](https://github.com/JuliaEditorSupport/julia-vim) (syntax, indent, autoload, ftplugin)
|
||||
- [kotlin](https://github.com/udalov/kotlin-vim) (syntax, indent, ftplugin)
|
||||
- [latex](https://github.com/LaTeX-Box-Team/LaTeX-Box) (syntax, indent, ftplugin)
|
||||
@ -166,6 +166,7 @@ If you need full functionality of any plugin, please use it directly with your p
|
||||
- [vm](https://github.com/lepture/vim-velocity) (syntax, indent)
|
||||
- [vue](https://github.com/posva/vim-vue) (syntax, indent, ftplugin)
|
||||
- [xls](https://github.com/vim-scripts/XSLT-syntax) (syntax)
|
||||
- [xml](https://github.com/amadeus/vim-xml) (syntax)
|
||||
- [yaml](https://github.com/stephpy/vim-yaml) (syntax, ftplugin)
|
||||
- [yard](https://github.com/sheerun/vim-yardoc) (syntax)
|
||||
<!--/Language Packs-->
|
||||
|
@ -13,11 +13,19 @@ endif
|
||||
" modified from html.vim
|
||||
if exists("loaded_matchit")
|
||||
let b:match_ignorecase = 0
|
||||
let s:jsx_match_words = '(:),\[:\],{:},<:>,' .
|
||||
\ '<\@<=\([^/][^ \t>]*\)[^>]*\%(/\@<!>\|$\):<\@<=/\1>'
|
||||
let s:jsx_match_words = '<\([a-zA-Z0-9.]\+\)\(>\|$\|\s\):<\/\1>'
|
||||
|
||||
if !exists('b:loaded_jsx_match_words')
|
||||
let b:loaded_jsx_match_words = 0
|
||||
endif
|
||||
|
||||
if b:loaded_jsx_match_words == 0
|
||||
let b:match_words = exists('b:match_words')
|
||||
\ ? b:match_words . ',' . s:jsx_match_words
|
||||
\ : s:jsx_match_words
|
||||
endif
|
||||
|
||||
let b:loaded_jsx_match_words = 1
|
||||
endif
|
||||
|
||||
setlocal suffixesadd+=.jsx
|
||||
|
@ -62,6 +62,20 @@ syn region jsxRegion
|
||||
\ keepend
|
||||
\ extend
|
||||
|
||||
" Shorthand fragment support
|
||||
"
|
||||
" Note that since the main jsxRegion contains @XMLSyntax, we cannot simply
|
||||
" adjust the regex above since @XMLSyntax will highlight the opening `<` as an
|
||||
" XMLError. Instead we create a new group with the same name that does not
|
||||
" include @XMLSyntax and instead uses matchgroup to get the same highlighting.
|
||||
syn region jsxRegion
|
||||
\ contains=@Spell,jsxRegion,jsxChild,jsBlock,javascriptBlock
|
||||
\ matchgroup=xmlTag
|
||||
\ start=/<>/
|
||||
\ end=/<\/>/
|
||||
\ keepend
|
||||
\ extend
|
||||
|
||||
" Add jsxRegion to the lowest-level JS syntax cluster.
|
||||
syn cluster jsExpression add=jsxRegion
|
||||
|
||||
|
3
build
3
build
@ -205,7 +205,7 @@ PACKS="
|
||||
json5:GutenYe/json5.vim
|
||||
json:elzr/vim-json
|
||||
jst:briancollins/vim-jst
|
||||
jsx:mxw/vim-jsx:_ALL
|
||||
jsx:amadeus/vim-jsx
|
||||
julia:JuliaEditorSupport/julia-vim
|
||||
kotlin:udalov/kotlin-vim
|
||||
latex:LaTeX-Box-Team/LaTeX-Box
|
||||
@ -273,6 +273,7 @@ PACKS="
|
||||
vifm:vifm/vifm.vim
|
||||
vm:lepture/vim-velocity
|
||||
vue:posva/vim-vue
|
||||
xml:amadeus/vim-xml
|
||||
xls:vim-scripts/XSLT-syntax
|
||||
yaml:stephpy/vim-yaml
|
||||
yard:sheerun/vim-yardoc
|
||||
|
@ -568,7 +568,7 @@ endif
|
||||
|
||||
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jsx') == -1
|
||||
augroup filetypedetect
|
||||
" jsx, from javascript.vim in mxw/vim-jsx:_ALL
|
||||
" jsx, from javascript.vim in amadeus/vim-jsx
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Vim ftdetect file
|
||||
"
|
||||
@ -577,20 +577,27 @@ if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'jsx') == -1
|
||||
"
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
" Whether the .jsx extension is required.
|
||||
if !exists('g:jsx_ext_required')
|
||||
let g:jsx_ext_required = 0
|
||||
endif
|
||||
|
||||
" Whether the @jsx pragma is required.
|
||||
if !exists('g:jsx_pragma_required')
|
||||
let g:jsx_pragma_required = 0
|
||||
endif
|
||||
|
||||
let s:jsx_pragma_pattern = '\%^\_s*\/\*\*\%(\_.\%(\*\/\)\@!\)*@jsx\_.\{-}\*\/'
|
||||
|
||||
" if g:jsx_check_react_import == 1
|
||||
" parse the first line of js file (skipping comments). When it has a 'react'
|
||||
" importation, we guess the user writes jsx
|
||||
" endif
|
||||
let s:jsx_prevalent_pattern =
|
||||
\ '\v\C%^\_s*%(%(//.*\_$|/\*\_.{-}\*/)@>\_s*)*%(import\s+\k+\s+from\s+|%(\l+\s+)=\k+\s*\=\s*require\s*\(\s*)[`"'']react>'
|
||||
|
||||
" Whether to set the JSX filetype on *.js files.
|
||||
fu! <SID>EnableJSX()
|
||||
" Whether the .jsx extension is required.
|
||||
if !exists('g:jsx_ext_required')
|
||||
let g:jsx_ext_required = 0
|
||||
endif
|
||||
|
||||
" Whether the @jsx pragma is required.
|
||||
if !exists('g:jsx_pragma_required')
|
||||
let g:jsx_pragma_required = 0
|
||||
endif
|
||||
|
||||
if g:jsx_pragma_required && !exists('b:jsx_ext_found')
|
||||
" Look for the @jsx pragma. It must be included in a docblock comment
|
||||
" before anything else in the file (except whitespace).
|
||||
@ -598,7 +605,10 @@ fu! <SID>EnableJSX()
|
||||
endif
|
||||
|
||||
if g:jsx_pragma_required && !b:jsx_pragma_found | return 0 | endif
|
||||
if g:jsx_ext_required && !exists('b:jsx_ext_found') | return 0 | endif
|
||||
if g:jsx_ext_required && !exists('b:jsx_ext_found') &&
|
||||
\ !(get(g:,'jsx_check_react_import') && search(s:jsx_prevalent_pattern, 'nw'))
|
||||
return 0
|
||||
endif
|
||||
return 1
|
||||
endfu
|
||||
|
||||
|
352
syntax/xml.vim
Normal file
352
syntax/xml.vim
Normal file
@ -0,0 +1,352 @@
|
||||
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'xml') != -1
|
||||
finish
|
||||
endif
|
||||
|
||||
" Vim syntax file
|
||||
" Language: XML
|
||||
" Maintainer: Amadeus Demarzi http://github.com/amadeus
|
||||
" Author and previous maintainers:
|
||||
" Johannes Zellner <johannes@zellner.org>
|
||||
" Paul Siegmann <pauls@euronet.nl>
|
||||
" Last Change: 2017 May 17
|
||||
" License: MIT
|
||||
" Filenames: *.xml
|
||||
|
||||
" 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
|
||||
\ +[-'"<]\@1<!\<[a-zA-Z:_][-.0-9a-zA-Z:_]*\>\%(['"]\@!\|$\)+
|
||||
\ contained
|
||||
\ contains=xmlAttribPunct,@xmlAttribHook
|
||||
\ display
|
||||
|
||||
|
||||
" namespace spec
|
||||
"
|
||||
" PROVIDES: @xmlNamespaceHook
|
||||
"
|
||||
" EXAMPLE:
|
||||
"
|
||||
" <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<=[^ /!?<>"':]\+[:]\@=+
|
||||
\ contained
|
||||
\ contains=@xmlNamespaceHook
|
||||
\ display
|
||||
endif
|
||||
|
||||
|
||||
" tag name
|
||||
"
|
||||
" PROVIDES: @xmlTagHook
|
||||
"
|
||||
" EXAMPLE:
|
||||
"
|
||||
" <tag foo.attribute = "value">
|
||||
" ^^^
|
||||
"
|
||||
syn match xmlTagName
|
||||
\ +\%(<\|</\)\@2<=[^ /!?<>"']\++
|
||||
\ 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 region xmlEndTag
|
||||
\ matchgroup=xmlTag start=+</[^ /!?<>"']\@=+
|
||||
\ matchgroup=xmlTag end=+>+
|
||||
\ contained
|
||||
\ contains=xmlTagName,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\{-}>+
|
||||
\ 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 region xmlEndTag
|
||||
\ matchgroup=xmlTag start=+</[^ /!?<>"']\@=+
|
||||
\ matchgroup=xmlTag end=+>+
|
||||
\ contains=xmlTagName,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=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
|
||||
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 Identifier
|
||||
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 xmlCommentStart xmlComment
|
||||
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
|
Loading…
Reference in New Issue
Block a user