mirror of
https://github.com/leafOfTree/vim-vue-plugin.git
synced 2026-11-02 10:27:34 +08:00
Merge pull request #50 from leafOfTree/shared-tests
Add shared test cases with vim-svelte-plugin, fix indent after empty tag
This commit is contained in:
21 files changed
+90
-1
No files matched your search
@@ -26,3 +26,11 @@ jobs:
|
||||
run: ./test/run.sh
|
||||
env:
|
||||
VUE_TEST_EDITORS: ${{ matrix.neovim && 'nvim' || 'vim' }}
|
||||
|
||||
shared:
|
||||
name: shared cases with vim-svelte-plugin
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Check shared cases
|
||||
run: ./test/shared.sh
|
||||
@@ -3,3 +3,4 @@ test.vue
|
||||
.DS_STORE
|
||||
test/deps/
|
||||
doc/tags
|
||||
test/other/
|
||||
@@ -233,6 +233,8 @@ Each case is a `.vue` or `.wpy` file in [test/cases](test/cases), with an option
|
||||
|
||||
Tests also run on GitHub Actions for each push and pull request, with Vim 8.2.0000, the latest Vim, Neovim 0.9.5 and the latest Neovim.
|
||||
|
||||
Cases named `shared-*` are for scenarios also in [vim-svelte-plugin][9], which handles blocks in the same way. `./test/shared.sh` lists shared cases in only one of them, as a warning on GitHub Actions, so a fix in one plugin can be checked in the other.
|
||||
|
||||
## Acknowledgments & Refs
|
||||
|
||||
- [mxw/vim-jsx][1]
|
||||
|
||||
+4
-1
@@ -19,7 +19,10 @@ function! s:Init()
|
||||
" To adjust HTML
|
||||
let s:empty_tagname = '(area|base|br|col|embed|hr|input|img|'
|
||||
\.'keygen|link|meta|param|source|track|wbr)'
|
||||
let s:empty_tag = '\v\<'.s:empty_tagname.'.*(/)@<!\>'
|
||||
" Empty tag ending with '>' but not '/>'. '>' in quotes like
|
||||
" @input="(e) => update(e)" doesn't end the tag
|
||||
let s:empty_tag = '\v\<'.s:empty_tagname
|
||||
\ .'>("[^"]*"|''[^'']*''|[^\>"''/]|/(\>)@!)*\>'
|
||||
let s:empty_tag_start = '\v\<'.s:empty_tagname.'[^>]*$'
|
||||
let s:empty_tag_end = '\v^\s*[^<>/]*\/?\>\s*'
|
||||
let s:tag_start = '\v^\s*\<\w*' " <
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
" Empty tags like <input> with or without '/>', and '>' in attribute
|
||||
" expressions
|
||||
let g:test_flatten = 1
|
||||
|
||||
function! Check()
|
||||
call ExpectIndentEachLine()
|
||||
endfunction
|
||||
@@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<div>
|
||||
<input v-model="name" @input="(e) => update(e)" />
|
||||
<p>x</p>
|
||||
<input type="text">
|
||||
<p>y</p>
|
||||
<img src="a.png" alt="a" />
|
||||
<p>z</p>
|
||||
<input :class="a > b ? 'a' : 'b'">
|
||||
<p>w</p>
|
||||
</div>
|
||||
</template>
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,6 @@
|
||||
" Lines after a multiline start tag or empty tag ending with '>' or '/>'
|
||||
let g:test_flatten = 1
|
||||
|
||||
function! Check()
|
||||
call ExpectIndentEachLine()
|
||||
endfunction
|
||||
@@ -0,0 +1,20 @@
|
||||
<template>
|
||||
<div
|
||||
class="a"
|
||||
id="b"
|
||||
>
|
||||
text
|
||||
<input
|
||||
type="text"
|
||||
:value="name"
|
||||
>
|
||||
<img
|
||||
src="a.png"
|
||||
alt="a"
|
||||
/>
|
||||
<input type="checkbox"
|
||||
checked
|
||||
>
|
||||
<p>end</p>
|
||||
</div>
|
||||
</template>
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
# List shared-* test cases missing in either vim-svelte-plugin or
|
||||
# vim-vue-plugin. Both plugins work in the same way for blocks, so a case for
|
||||
# a scenario in one plugin should be in the other with the same name. Only
|
||||
# warn, as the other plugin may be updated later
|
||||
# ./test/shared.sh
|
||||
cd "$(dirname "$0")/.." || exit 1
|
||||
other=vim-svelte-plugin
|
||||
|
||||
dir=test/other/$other
|
||||
rm -rf "$dir"
|
||||
git clone -q --depth 1 "https://github.com/leafOfTree/$other" "$dir" || exit 0
|
||||
|
||||
list() {
|
||||
ls "$1"/test/cases/shared-*.vim 2>/dev/null | sed 's#.*/##; s#\.vim$##' | sort
|
||||
}
|
||||
list . > test/other/mine
|
||||
list "$dir" > test/other/theirs
|
||||
|
||||
missing=0
|
||||
for name in $(comm -23 test/other/mine test/other/theirs); do
|
||||
echo "::warning::$name is not in $other"
|
||||
missing=1
|
||||
done
|
||||
for name in $(comm -13 test/other/mine test/other/theirs); do
|
||||
echo "::warning::$name in $other is not here"
|
||||
missing=1
|
||||
done
|
||||
[ $missing -eq 0 ] && echo "Shared cases are the same as $other"
|
||||
exit 0
|
||||
Reference in new issue
Block a user