Test all features
test / test (push) Canceled after 0s

Add cases for attribute highlight on and off, block syntax by lang
and emmet-vim group names, OnChangeVueSyntax(), matchit, .wpy,
initial_indent as syntax and tag.syntax, and syntax after reloading.

Also check indenting a file after removing all indent with
g:test_flatten, which fails before the end tag fix as closing tags at
column 0 were taken as block end tags.
This commit is contained in:
leafOfTree committed 2026-10-20 01:21:17 +00:00
1 parent 2ed782e422
commit 68b866210b
23 files changed
+281 -15

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
" Without attribute and keyword highlight
let g:vim_vue_plugin_config = {'attribute': 0, 'keyword': 0}
let g:test_flatten = 1
function! Check()
call ExpectSyntax('@click', 'VueKey')
call ExpectSyntax('toggle', 'VueValue')
call ExpectNoSyntax('$t', 'VueInject')
call ExpectNoSyntax('1"', 'javaScriptNumber')
call ExpectSyntax('message', 'VueExpression')
call ExpectEqual(matchstr(execute('highlight VueKey'), 'links to \zs\S\+'),
\ 'htmlArg', 'VueKey link')
call ExpectNoSyntax('data', 'vueObjectFuncName')
endfunction
+13
View File
@@ -0,0 +1,13 @@
<template>
<div @click="toggle(item)" :title="$t('title')" v-if="count > 1">
<p>{{ message }}</p>
</div>
</template>
<script>
export default {
data() {
return {}
},
}
</script>
+26
View File
@@ -0,0 +1,26 @@
" Template syntax with attribute highlight
let g:vim_vue_plugin_config = {'attribute': 1}
let g:test_flatten = 1
function! Check()
" Directives
call ExpectSyntax(':class', 'VueKey')
call ExpectSyntax('@click', 'VueKey')
call ExpectSyntax('v-if', 'VueKey')
" Values as expressions
call ExpectSyntax('1"', 'javaScriptNumber')
call ExpectSyntax('$t', 'VueInject')
call ExpectSyntax("'title'", 'javaScriptStringS')
" Components and attributes
normal! gg
call ExpectSyntax('MyComponent', 'VueComponentName')
call ExpectSyntax('ref=', 'htmlArg')
call ExpectSyntax('data-id', 'htmlArg')
call ExpectSyntax('my-component', 'VueComponentName')
call ExpectSyntax('transition', 'VueComponentName')
" Interpolation
call ExpectSyntax('{{', 'VueBrace')
call ExpectSyntax('message', 'VueExpression')
call ExpectEqual(matchstr(execute('highlight VueKey'), 'links to \zs\S\+'),
\ 'Type', 'VueKey link')
endfunction
+19
View File
@@ -0,0 +1,19 @@
<template>
<div :class="{ active: isActive }" @click="toggle(item)" v-if="count > 1">
<MyComponent ref="comp" data-id="1" :title="$t('title')" />
<my-component v-model="text"></my-component>
<transition name="fade">
<p>{{ message.toUpperCase() }}</p>
</transition>
</div>
</template>
<script>
export default {
data() {
return {
count: 0,
}
},
}
</script>
+12
View File
@@ -5,3 +5,15 @@ let g:vim_vue_plugin_config = {
\ 'style': ['css'],
\},
\}
let g:test_flatten = 1
packadd matchit
" Jump between tags with % by matchit. Use :normal for its mapping
function! Check()
for [lnum, col, expected] in [[1, 2, [3, '/template']], [2, 4, [2, '/p']]]
call cursor(lnum, col)
normal %
call ExpectEqual([line('.'), matchstr(getline('.'), '\%'.col('.').'c/\w\+')],
\ expected, printf('after %% from line %d col %d', lnum, col))
endfor
endfunction
+27
View File
@@ -0,0 +1,27 @@
" OnChangeVueSyntax() is called when syntax under cursor changes. It's
" defined before the plugin is loaded
let g:vim_vue_plugin_config = {
\'syntax': {
\ 'template': ['html'],
\ 'script': ['javascript', 'typescript'],
\ 'style': ['css', 'scss'],
\},
\}
let g:test_changes = []
function! OnChangeVueSyntax(syntax)
call add(g:test_changes, a:syntax)
endfunction
function! Check()
for lnum in [2, 3, 6, 6, 10, 2]
call cursor(lnum, 1)
doautocmd CursorMoved
endfor
call ExpectEqual(g:test_changes, ['html', 'typescript', 'scss', 'html'],
\ 'syntax changes')
call ExpectEqual(GetVueSyntax(), 'html', 'GetVueSyntax()')
call ExpectTag(6, 'script')
call ExpectTag(10, 'style')
endfunction
let g:test_flatten = 1
+11
View File
@@ -0,0 +1,11 @@
<template>
<div></div>
</template>
<script lang="ts">
const a: number = 1
</script>
<style lang="scss">
$a: 1px;
</style>
+25
View File
@@ -13,3 +13,28 @@ let g:vim_vue_plugin_config = {
\'foldexpr': 1,
\'full_syntax': ['scss', 'less'],
\}
" Block tag, syntax by lang="..." or the first in config, and block group
" with css prefix for emmet-vim
function! Check()
call ExpectBlock('div.set', 'template', 'pug', 'pugTemplateBlock')
call ExpectBlock('<template></template>', 'template', 'html', 'htmlTemplateBlock')
call ExpectBlock('export default', 'script', 'javascript', 'javascriptScriptBlock')
call ExpectBlock('import Vue', 'script', 'typescript', 'typescriptScriptBlock')
call ExpectBlock('# Assignment', 'script', 'coffee', 'coffeeScriptBlock')
call ExpectBlock('p {', 'style', 'css', 'cssStyleBlock')
call ExpectBlock('$a: 100px', 'style', 'scss', 'cssScssStyleBlock')
call ExpectBlock('$w: 128px', 'style', 'sass', 'sassStyleBlock')
call ExpectBlock('@list: 10 12', 'style', 'less', 'cssLessStyleBlock')
call ExpectBlock("@import 'vendor'", 'style', 'stylus', 'cssStylusStyleBlock')
call ExpectBlock('"requiresAuth"', 'route', 'json', 'jsonRouteBlock')
call ExpectBlock('# This is', 'docs', 'markdown', 'markdownDocsBlock')
call ExpectBlock('en:', 'i18n', 'yaml', 'yamlI18nBlock')
call ExpectBlock('"en"', 'i18n', 'json', 'jsonI18nBlock')
" Syntax from a sync point, as after jumping to the end
silent edit!
normal! G
call search('"en"', 'bW')
call ExpectEqual(GetVueSyntax(), 'json', 'syntax at the end after reload')
endfunction
+1
View File
@@ -13,3 +13,4 @@ function! Check()
call ExpectFoldlevel(lnum, levels[lnum - 1])
endfor
endfunction
let g:test_flatten = 1
+1
View File
@@ -7,3 +7,4 @@ let g:vim_vue_plugin_config = {
\},
\'initial_indent': ['script', 'style', 'codepen-additional'],
\}
let g:test_flatten = 1
+10
View File
@@ -0,0 +1,10 @@
" initial_indent as `syntax` and `tag.syntax`
let g:vim_vue_plugin_config = {
\'syntax': {
\ 'script': ['javascript'],
\ 'style': ['css', 'scss'],
\ 'i18n': ['json', 'yaml'],
\},
\'initial_indent': ['scss', 'i18n.json'],
\}
let g:test_flatten = 1
+28
View File
@@ -0,0 +1,28 @@
<script>
export default {}
</script>
<style lang="scss">
.a {
color: red;
}
</style>
<style>
.b {
color: blue;
}
</style>
<i18n>
{
"en": {
"hello": "Hello"
}
}
</i18n>
<i18n lang="yaml">
en:
hello: Hello
</i18n>
+1
View File
@@ -14,3 +14,4 @@ function! Check()
call ExpectSyntax('computed', 'vueObjectKey')
call ExpectSyntax('mounted', 'vueObjectFuncName')
endfunction
let g:test_flatten = 1
+9
View File
@@ -0,0 +1,9 @@
" .wpy for miniprogram, with initial indent for script and style by default
let g:test_flatten = 1
function! Check()
call ExpectSyntax('view', 'VueCustomTag')
call ExpectSyntax('wx:if', 'VueKey')
call ExpectSyntax('show', 'VueExpression')
call ExpectSyntax('text', 'VueCustomTag')
endfunction
+21
View File
@@ -0,0 +1,21 @@
<template>
<view wx:if="{{ show }}" class="greeting">
<text>{{ greeting }}</text>
</view>
</template>
<script>
export default {
data: function () {
return {
greeting: 'Hello'
};
},
};
</script>
<style scoped>
.greeting {
font-size: 2em;
}
</style>
+1
View File
@@ -20,3 +20,4 @@ function! CheckSync()
\.string(SyntaxList()))
endif
endfunction
let g:test_flatten = 1
+1
View File
@@ -8,3 +8,4 @@ let g:vim_vue_plugin_config = {
\'keyword': 1,
\'foldexpr': 1,
\}
let g:test_flatten = 1
+1
View File
@@ -16,3 +16,4 @@ function! Check()
call ExpectNoSyntax('value < 3', 'vue3Keyword')
call ExpectSyntax('defineExpose', 'vue3Keyword')
endfunction
let g:test_flatten = 1
+1
View File
@@ -16,3 +16,4 @@ function! Check()
call ExpectNoSyntax('/docs', 'markdownDocsBlock')
call ExpectSyntax('/docs', 'markdownDocsBlock')
endfunction
let g:test_flatten = 1
+1
View File
@@ -13,3 +13,4 @@ function! Check()
call ExpectSyntax('global', 'cssPseudoClassId')
call ExpectSyntax('deep', 'cssPseudoClassId')
endfunction
let g:test_flatten = 1