mirror of
https://github.com/posva/vim-vue.git
synced 2025-12-08 10:24:45 +08:00
Include syntax file only if it exists
This commit is contained in:
@@ -6,37 +6,70 @@ if exists("b:current_syntax")
|
|||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if !exists("s:syntaxes")
|
||||||
|
" Search available syntax files.
|
||||||
|
function s:search_syntaxes(...)
|
||||||
|
let syntaxes = {}
|
||||||
|
let names = a:000
|
||||||
|
for name in names
|
||||||
|
let syntaxes[name] = 0
|
||||||
|
endfor
|
||||||
|
|
||||||
|
for path in split(&runtimepath, ',')
|
||||||
|
if isdirectory(path . '/syntax')
|
||||||
|
for name in names
|
||||||
|
let syntaxes[name] = syntaxes[name] || filereadable(path . '/syntax/' . name . '.vim')
|
||||||
|
endfor
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
return syntaxes
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
let s:syntaxes = s:search_syntaxes('jade', 'coffee', 'stylus', 'sass', 'less')
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
syntax include @HTML syntax/html.vim
|
syntax include @HTML syntax/html.vim
|
||||||
unlet b:current_syntax
|
unlet b:current_syntax
|
||||||
syntax region template keepend start=/<template>/ end="</template>" contains=@HTML fold
|
syntax region template keepend start=/<template>/ end="</template>" contains=@HTML fold
|
||||||
|
|
||||||
syntax include @JADE syntax/jade.vim
|
if s:syntaxes.jade
|
||||||
unlet b:current_syntax
|
syntax include @JADE syntax/jade.vim
|
||||||
syntax region jade keepend start=/<template lang="[^"]*jade[^"]*">/ end="</template>" contains=@JADE fold
|
unlet b:current_syntax
|
||||||
|
syntax region jade keepend start=/<template lang="[^"]*jade[^"]*">/ end="</template>" contains=@JADE fold
|
||||||
|
endif
|
||||||
|
|
||||||
syntax include @JS syntax/javascript.vim
|
syntax include @JS syntax/javascript.vim
|
||||||
unlet b:current_syntax
|
unlet b:current_syntax
|
||||||
syntax region script keepend start=/<script>/ end="</script>" contains=@JS fold
|
syntax region script keepend start=/<script>/ end="</script>" contains=@JS fold
|
||||||
|
|
||||||
syntax include @COFFEE syntax/coffee.vim
|
if s:syntaxes.coffee
|
||||||
unlet b:current_syntax
|
syntax include @COFFEE syntax/coffee.vim
|
||||||
" Matchgroup seems to be necessary for coffee
|
unlet b:current_syntax
|
||||||
syntax region coffee keepend matchgroup=Delimiter start="<script lang=\"coffee\">" end="</script>" contains=@COFFEE fold
|
" Matchgroup seems to be necessary for coffee
|
||||||
|
syntax region coffee keepend matchgroup=Delimiter start="<script lang=\"coffee\">" end="</script>" contains=@COFFEE fold
|
||||||
|
endif
|
||||||
|
|
||||||
syntax include @CSS syntax/css.vim
|
syntax include @CSS syntax/css.vim
|
||||||
unlet b:current_syntax
|
unlet b:current_syntax
|
||||||
syntax region style keepend start=/<style\( \+scoped\)\?>/ end="</style>" contains=@CSS fold
|
syntax region style keepend start=/<style\( \+scoped\)\?>/ end="</style>" contains=@CSS fold
|
||||||
|
|
||||||
syntax include @stylus syntax/stylus.vim
|
if s:syntaxes.stylus
|
||||||
unlet b:current_syntax
|
syntax include @stylus syntax/stylus.vim
|
||||||
syntax region stylus keepend start=/<style lang="[^"]*stylus[^"]*"\( \+scoped\)\?>/ end="</style>" contains=@stylus fold
|
unlet b:current_syntax
|
||||||
|
syntax region stylus keepend start=/<style lang="[^"]*stylus[^"]*"\( \+scoped\)\?>/ end="</style>" contains=@stylus fold
|
||||||
|
endif
|
||||||
|
|
||||||
syntax include @sass syntax/sass.vim
|
if s:syntaxes.sass
|
||||||
unlet b:current_syntax
|
syntax include @sass syntax/sass.vim
|
||||||
syntax region sass keepend start=/<style\( \+scoped\)\? lang="sass"\( \+scoped\)\?>/ end="</style>" contains=@sass fold
|
unlet b:current_syntax
|
||||||
|
syntax region sass keepend start=/<style\( \+scoped\)\? lang="sass"\( \+scoped\)\?>/ end="</style>" contains=@sass fold
|
||||||
|
endif
|
||||||
|
|
||||||
syntax include @less syntax/less.vim
|
if s:syntaxes.less
|
||||||
unlet b:current_syntax
|
syntax include @less syntax/less.vim
|
||||||
syntax region less keepend matchgroup=PreProc start=/<style\%( \+scoped\)\? lang="less"\%( \+scoped\)\?>/ end="</style>" contains=@less fold
|
unlet b:current_syntax
|
||||||
|
syntax region less keepend matchgroup=PreProc start=/<style\%( \+scoped\)\? lang="less"\%( \+scoped\)\?>/ end="</style>" contains=@less fold
|
||||||
|
endif
|
||||||
|
|
||||||
let b:current_syntax = "vue"
|
let b:current_syntax = "vue"
|
||||||
|
|||||||
Reference in New Issue
Block a user