2019-03-04 03:28:35 -05:00
|
|
|
if exists('g:polyglot_disabled') && index(g:polyglot_disabled, 'vue') != -1
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
|
2017-02-02 15:49:51 -05:00
|
|
|
" Vim syntax file
|
|
|
|
" Language: Vue.js
|
|
|
|
" Maintainer: Eduardo San Martin Morote
|
|
|
|
|
|
|
|
if exists("b:current_syntax")
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
|
2017-05-17 05:07:28 -04:00
|
|
|
runtime! syntax/html.vim
|
2018-04-30 15:00:42 -04:00
|
|
|
syntax clear htmlTagName
|
|
|
|
syntax match htmlTagName contained "\<[a-zA-Z0-9:-]*\>"
|
2017-03-23 06:28:19 -04:00
|
|
|
unlet! b:current_syntax
|
2017-02-02 15:49:51 -05:00
|
|
|
|
2017-05-17 05:07:28 -04:00
|
|
|
""
|
|
|
|
" Get the pattern for a HTML {name} attribute with {value}.
|
|
|
|
function! s:attr(name, value)
|
|
|
|
return a:name . '=\("\|''\)[^\1]*' . a:value . '[^\1]*\1'
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
""
|
|
|
|
" Check whether a syntax file for a given {language} exists.
|
|
|
|
function! s:syntax_available(language)
|
|
|
|
return !empty(globpath(&runtimepath, 'syntax/' . a:language . '.vim'))
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
""
|
|
|
|
" Register {language} for a given {tag}. If [attr_override] is given and not
|
|
|
|
" empty, it will be used for the attribute pattern.
|
|
|
|
function! s:register_language(language, tag, ...)
|
|
|
|
let attr_override = a:0 ? a:1 : ''
|
|
|
|
let attr = !empty(attr_override) ? attr_override : s:attr('lang', a:language)
|
|
|
|
|
|
|
|
if s:syntax_available(a:language)
|
|
|
|
execute 'syntax include @' . a:language . ' syntax/' . a:language . '.vim'
|
|
|
|
unlet! b:current_syntax
|
|
|
|
execute 'syntax region vue_' . a:language
|
|
|
|
\ 'keepend'
|
2018-06-05 16:50:18 -04:00
|
|
|
\ 'start=/<' . a:tag . '\>\_[^>]*' . attr . '\_[^>]*>/'
|
2017-05-17 05:07:28 -04:00
|
|
|
\ 'end="</' . a:tag . '>"me=s-1'
|
|
|
|
\ 'contains=@' . a:language . ',vueSurroundingTag'
|
|
|
|
\ 'fold'
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
2017-09-27 13:57:29 -04:00
|
|
|
if !exists("g:vue_disable_pre_processors") || !g:vue_disable_pre_processors
|
2018-04-30 15:00:42 -04:00
|
|
|
call s:register_language('less', 'style')
|
2017-09-27 13:57:29 -04:00
|
|
|
call s:register_language('pug', 'template', s:attr('lang', '\%(pug\|jade\)'))
|
|
|
|
call s:register_language('slm', 'template')
|
|
|
|
call s:register_language('handlebars', 'template')
|
|
|
|
call s:register_language('haml', 'template')
|
|
|
|
call s:register_language('typescript', 'script', '\%(lang=\("\|''\)[^\1]*\(ts\|typescript\)[^\1]*\1\|ts\)')
|
|
|
|
call s:register_language('coffee', 'script')
|
|
|
|
call s:register_language('stylus', 'style')
|
|
|
|
call s:register_language('sass', 'style')
|
|
|
|
call s:register_language('scss', 'style')
|
|
|
|
endif
|
2017-05-17 05:07:28 -04:00
|
|
|
|
|
|
|
syn region vueSurroundingTag contained start=+<\(script\|style\|template\)+ end=+>+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent
|
|
|
|
syn keyword htmlSpecialTagName contained template
|
|
|
|
syn keyword htmlArg contained scoped ts
|
|
|
|
syn match htmlArg "[@v:][-:.0-9_a-z]*\>" contained
|
2017-02-02 15:49:51 -05:00
|
|
|
|
|
|
|
let b:current_syntax = "vue"
|