mirror of
https://github.com/leafOfTree/vim-vue-plugin.git
synced 2025-12-11 23:21:55 +08:00
Fix vue3 keyword syntax for pangloss/vim-javascript
This commit is contained in:
@@ -21,12 +21,18 @@ let s:indent = &sw * (1 + s:has_init_indent)
|
|||||||
let s:keywords_regexp = '\v^\s{'.s:indent.'}(async )?<('
|
let s:keywords_regexp = '\v^\s{'.s:indent.'}(async )?<('
|
||||||
\.join(split(s:vue_keywords, ' '), '|')
|
\.join(split(s:vue_keywords, ' '), '|')
|
||||||
\.')\ze'
|
\.')\ze'
|
||||||
let contains = hlexists('jsAsyncKeyword')
|
|
||||||
|
" Currently support https://github.com/pangloss/vim-javascript
|
||||||
|
let s:useJavaScriptPlugin = hlexists('jsAsyncKeyword')
|
||||||
|
let s:containedin = s:useJavaScriptPlugin
|
||||||
|
\? 'jsObject,jsFuncBlock,@jsExpression'
|
||||||
|
\: 'javascriptVueScript'
|
||||||
|
let s:contains = s:useJavaScriptPlugin
|
||||||
\? 'jsAsyncKeyword'
|
\? 'jsAsyncKeyword'
|
||||||
\: 'javaScriptReserved'
|
\: 'javaScriptReserved'
|
||||||
let s:match_option =
|
let s:match_option =
|
||||||
\' containedin=jsObject,javascriptVueScript'
|
\' containedin='.s:containedin
|
||||||
\.' contains='.contains
|
\.' contains='.s:contains
|
||||||
\.' skipwhite skipempty'
|
\.' skipwhite skipempty'
|
||||||
|
|
||||||
execute 'syntax match vueObjectKey /'
|
execute 'syntax match vueObjectKey /'
|
||||||
@@ -47,20 +53,22 @@ execute 'syntax match vueObjectFuncKey /'
|
|||||||
\.s:match_option
|
\.s:match_option
|
||||||
\.' nextgroup=jsFuncArgs'
|
\.' nextgroup=jsFuncArgs'
|
||||||
|
|
||||||
let s:vue3_keywords = 'ref reactive toRefs watch computed getCurrentInstance'.
|
let s:vue3_keywords = 'ref reactive toRefs watch computed'.
|
||||||
\' onBeforeMount onMounted onBeforeUpdate onUpdated onBeforeUnmount onUnmounted onErrorCaptured onRenderTracked onRenderTriggered'
|
\' onBeforeMount onMounted onBeforeUpdate onUpdated onBeforeUnmount'.
|
||||||
|
\' onUnmounted onErrorCaptured onRenderTracked onRenderTriggered'.
|
||||||
|
\' getCurrentInstance'
|
||||||
let s:vue3_keywords_regexp = '\v<('
|
let s:vue3_keywords_regexp = '\v<('
|
||||||
\.join(split(s:vue3_keywords, ' '), '|')
|
\.join(split(s:vue3_keywords, ' '), '|')
|
||||||
\.')\ze'
|
\.')\ze'
|
||||||
|
|
||||||
execute 'syntax match vueObjectFuncName /'
|
execute 'syntax match vue3Keyword /'
|
||||||
\.s:vue3_keywords_regexp
|
\.s:vue3_keywords_regexp
|
||||||
\.'\_s*\(/'
|
\.'\_s*\(/'
|
||||||
\.s:match_option
|
\.s:match_option
|
||||||
\.' nextgroup=jsFuncArgs'
|
|
||||||
|
|
||||||
highlight default link vueObjectKey vueObjectKeyword
|
highlight default link vueObjectKey vueObjectKeyword
|
||||||
highlight default link vueObjectFuncName vueObjectKeyword
|
highlight default link vueObjectFuncName vueObjectKeyword
|
||||||
|
highlight default link vue3Keyword vueObjectKeyword
|
||||||
highlight default link vueObjectFuncKey vueObjectKeyword
|
highlight default link vueObjectFuncKey vueObjectKeyword
|
||||||
highlight default link vueObjectKeyword Type
|
highlight default link vueObjectKeyword Type
|
||||||
"}}}
|
"}}}
|
||||||
|
|||||||
@@ -77,12 +77,10 @@ endfunction
|
|||||||
" Load main syntax {{{
|
" Load main syntax {{{
|
||||||
"
|
"
|
||||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
" Load syntax/html.vim to syntax group, which loads full JavaScript and CSS
|
|
||||||
" syntax. It defines group htmlJavaScript and htmlCss.
|
|
||||||
call s:LoadSyntax('@HTMLSyntax', 'html')
|
|
||||||
|
|
||||||
" Load vue-html syntax
|
" Load syntax/html.vim to syntax group, which loads full JavaScript and CSS
|
||||||
runtime syntax/vue-html.vim
|
" syntax. It defines group @html, @htmlJavaScript, and @htmlCss.
|
||||||
|
call s:LoadSyntax('@html', 'html')
|
||||||
|
|
||||||
" Avoid overload
|
" Avoid overload
|
||||||
if !hlexists('cssTagName')
|
if !hlexists('cssTagName')
|
||||||
@@ -95,6 +93,9 @@ if !hlexists('javaScriptComment')
|
|||||||
call s:LoadSyntax('@htmlJavaScript', 'javascript')
|
call s:LoadSyntax('@htmlJavaScript', 'javascript')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" Load vue-html syntax
|
||||||
|
runtime syntax/vue-html.vim
|
||||||
|
|
||||||
" Load vue-javascript syntax
|
" Load vue-javascript syntax
|
||||||
runtime syntax/vue-javascript.vim
|
runtime syntax/vue-javascript.vim
|
||||||
"}}}
|
"}}}
|
||||||
@@ -155,12 +156,12 @@ endif
|
|||||||
syntax region htmlVueTemplate fold
|
syntax region htmlVueTemplate fold
|
||||||
\ start=+<template[^>]*>+
|
\ start=+<template[^>]*>+
|
||||||
\ end=+^</template>+
|
\ end=+^</template>+
|
||||||
\ keepend contains=@HTMLSyntax
|
\ keepend contains=@html
|
||||||
" When template code is not well indented
|
" When template code is not well indented
|
||||||
syntax region htmlVueTemplate fold
|
syntax region htmlVueTemplate fold
|
||||||
\ start=+<template[^>]*>+
|
\ start=+<template[^>]*>+
|
||||||
\ end=+</template>\ze\n\(^$\n\)*<\(script\|style\)+
|
\ end=+</template>\ze\n\(^$\n\)*<\(script\|style\)+
|
||||||
\ keepend contains=@HTMLSyntax
|
\ keepend contains=@html
|
||||||
|
|
||||||
syntax region javascriptVueScript fold
|
syntax region javascriptVueScript fold
|
||||||
\ start=+<script[^>]*>+
|
\ start=+<script[^>]*>+
|
||||||
@@ -316,7 +317,7 @@ syntax match javaScriptNumber '\v<-?\d+L?>|0[xX][0-9a-fA-F]+>'
|
|||||||
silent! syntax clear htmlHead
|
silent! syntax clear htmlHead
|
||||||
|
|
||||||
" html5 data-*
|
" html5 data-*
|
||||||
syntax match htmlArg '\v<data(-[.a-z0-9]+)+>' containedin=@HTMLSyntax
|
syntax match htmlArg '\v<data(-[.a-z0-9]+)+>' containedin=@html
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
|||||||
Reference in New Issue
Block a user