feat: modify to fix vue syntax and indent

This commit is contained in:
yemai
2018-09-28 12:24:29 +08:00
parent 86026411e5
commit 65548cf7fb
4 changed files with 55 additions and 126 deletions

View File

@@ -1,4 +1,3 @@
echom 'vim for vue'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vim syntax file
"
@@ -9,40 +8,19 @@ echom 'vim for vue'
" CREDITS: Inspired by mxw/vim-jsx.
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
unlet b:current_syntax
" runtime! syntax/html.vim
syn include @HTMLSyntax syntax/html.vim
" load in XML syntax.
if exists('b:current_syntax')
let s:current_syntax=b:current_syntax
unlet b:current_syntax
endif
syn include @XMLSyntax syntax/xml.vim
if exists('s:current_syntax')
let b:current_syntax=s:current_syntax
endif
unlet! b:current_syntax
syn include @CSSSyntax syntax/css.vim
" load in HTML syntax
if exists('b:current_syntax')
let s:current_syntax=b:current_syntax
unlet b:current_syntax
endif
syn include @HTMLSyntax syntax/css.vim
if exists('s:current_syntax')
let b:current_syntax=s:current_syntax
endif
" load in CSS syntax
if exists('b:current_syntax')
let s:current_syntax=b:current_syntax
unlet b:current_syntax
endif
syn include @CSSSyntax syntax/javascript.vim
if exists('s:current_syntax')
let b:current_syntax=s:current_syntax
endif
let b:current_syntax='vue'
" Find tag <script> / <style> and enable javascript / css syntax
syn region vueScript contained start=+<script\(\s.\{-}\)\?>+ end=+</script>+ keepend contains=@jsAll,jsImport,jsExport,@XMLSyntax
syn region vueStyle contained start=+<style\(\s.\{-}\)\?>+ end=+</style>+ keepend contains=@CSSSyntax
syn region vueTemplate start=+<template\(\s.\{-}\)\?>+ end=+</template>+ keepend contains=@HTMLSyntax
syn region vueScript start=+<script\(\s.\{-}\)\?>+ end=+</script>+ keepend contains=@jsAll,jsImport,jsExport
syn region vueStyle start=+<style\(\s.\{-}\)\?>+ end=+</style>+ keepend contains=@CSSSyntax
" Officially, vim-jsx depends on the pangloss/vim-javascript syntax package
" (and is tested against it exclusively). However, in practice, we make some
@@ -58,21 +36,3 @@ syn region vueStyle contained start=+<style\(\s.\{-}\)\?>+ end=+</style>+ keepen
" Vue attributes should color as JS. Note the trivial end pattern; we let
" jsBlock take care of ending the region.
syn region xmlString contained start=+{+ end=++ contains=jsBlock,javascriptBlock
" Note that we prohibit Vue tags from having a < or word character immediately
" preceding it, to avoid conflicts with, respectively, the left shift operator
" and generic Flow type annotations (http://flowtype.org/).
syn region vueRegion
\ contains=@Spell,@XMLSyntax,jsBlock,javascriptBlock,vueScript,vueStyle
\ start=+\%(<\|\w\)\@<!<\z([a-zA-Z][a-zA-Z0-9:\-.]*\>[:,]\@!\)\([^>]*>(\)\@!+
\ skip=+<!--\_.\{-}-->+
\ end=+</\z1\_\s\{-}>+
\ end=+/>+
\ keepend
\ extend
"
" Add vueRegion to the lowest-level JS syntax cluster.
syn cluster jsExpression add=vueRegion
" Allow vueRegion to contain reserved words.
syn cluster javascriptNoReserved add=vueRegion