mirror of
https://github.com/leafOfTree/vim-vue-plugin.git
synced 2025-12-15 00:47:05 +08:00
feat: improve Vue tag syntax highlight
This commit is contained in:
@@ -38,37 +38,52 @@ else
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Load vim-pug syntax if pug support is enabled
|
" If pug is enabled, load vim-pug syntax
|
||||||
if exists("g:vim_vue_plugin_use_pug")
|
if exists("g:vim_vue_plugin_use_pug")
|
||||||
\ && g:vim_vue_plugin_use_pug == 1
|
\ && g:vim_vue_plugin_use_pug == 1
|
||||||
call s:LoadFullSyntax('@PugSyntax', 'pug')
|
call s:LoadFullSyntax('@PugSyntax', 'pug')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" If less is enabled, load vim-pug syntax
|
||||||
|
if exists("g:vim_vue_plugin_use_less")
|
||||||
|
\ && g:vim_vue_plugin_use_less == 1
|
||||||
|
call s:LoadFullSyntax('@LessSyntax', 'less')
|
||||||
|
endif
|
||||||
|
|
||||||
let b:current_syntax = 'vue'
|
let b:current_syntax = 'vue'
|
||||||
|
|
||||||
" Find tag <template> / <script> / <style> and enable currespond syntax
|
" Find tag <template> / <script> / <style> and enable currespond syntax
|
||||||
syn region vueTemplate
|
syn region vueTemplate
|
||||||
\ start=+<template\(\s.\{-}\)\?>+
|
\ start=+<template\(\s.\{-}\)\?>+
|
||||||
\ end=+</template>+
|
\ end=+^</template>+
|
||||||
\ keepend contains=vueTemplatePug,@HTMLSyntax,vueTag
|
\ keepend contains=@HTMLSyntax
|
||||||
syn region vueTemplatePug
|
syn region vueTemplatePug
|
||||||
\ start=+<template lang="pug"\(\s.\{-}\)\?>+
|
\ start=+<template lang="pug"\(\s.\{-}\)\?>+
|
||||||
\ end=+</template>+
|
\ end=+</template>+
|
||||||
\ contained contains=@PugSyntax,vueTag
|
\ keepend contains=@PugSyntax,vueTag
|
||||||
|
|
||||||
syn region vueScript
|
syn region vueScript
|
||||||
\ start=+<script\(\s.\{-}\)\?>+
|
\ start=+<script\(\s.\{-}\)\?>+
|
||||||
\ end=+</script>+
|
\ end=+</script>+
|
||||||
\ keepend contains=@jsAll,jsImport,jsExport,vueTag
|
\ keepend contains=@jsAll,jsImport,jsExport,vueTag
|
||||||
|
|
||||||
syn region vueStyle
|
syn region vueStyle
|
||||||
\ start=+<style\(\s.\{-}\)\?>+
|
\ start=+<style\(\s.\{-}\)\?>+
|
||||||
\ end=+</style>+
|
\ end=+</style>+
|
||||||
\ keepend contains=@CSSSyntax,@HTMLSyntax,vueTag
|
\ keepend contains=@CSSSyntax,vueTag
|
||||||
|
syn region vueStyleLESS
|
||||||
|
\ start=+<style lang="less"\(\s.\{-}\)\?>+
|
||||||
|
\ end=+</style>+
|
||||||
|
\ keepend contains=@LessSyntax,vueTag
|
||||||
|
|
||||||
hi def link vueTag htmlTagName
|
syn region vueTag contained start=+<[^/]+ end=+>+ contains=htmlTagN,htmlString,htmlArg
|
||||||
syn match vueTag contained /\v(template|script|style)/
|
syn region vueTag contained start=+</+ end=+>+ contains=htmlTagN,htmlString,htmlArg
|
||||||
|
" syn keyword vueTagName containedin=htmlTagN template script style
|
||||||
|
|
||||||
" Vue attributes should color as JS. Note the trivial end pattern; we let
|
" Vue attributes should color as JS. Note the trivial end pattern; we let
|
||||||
" jsBlock take care of ending the region.
|
" jsBlock take care of ending the region.
|
||||||
syn region xmlString
|
syn region xmlString
|
||||||
\ start=+{+ end=++
|
\ start=+{+ end=++
|
||||||
\ contained contains=jsBlock,javascriptBlock
|
\ contained contains=jsBlock,javascriptBlock
|
||||||
|
|
||||||
|
hi def link vueTag htmlTag
|
||||||
|
|||||||
Reference in New Issue
Block a user