- Add tested Vim and Neovim versions and the lnum argument of GetVueTag()
- Remove the tip to edit $VIMRUNTIME/syntax/vue.vim, which isn't loaded
as this plugin is added to the start of runtimepath
- Add ./test/shared.sh to test commands
Name cases for scenarios also in vim-svelte-plugin as shared-*, adding
one for multiline tags. test/shared.sh lists shared cases in only one
of the plugins, as a warning in a separate job on GitHub Actions.
A line like <input @input="(e) => update(e)" /> was taken as an empty
tag without '/>', as '>' in '=>' matched its end, so the next line was
indented one level less. Skip '>' in quotes, and don't take '/>' as the
end of an empty tag.
syntax in g:vim_vue_plugin_config replaced the whole default, so
{'syntax': {'script': ['javascript', 'typescript']}} removed template
and style, which then had no highlight or indent. Replace the default
of each key separately, like vim-svelte-plugin. A block can be removed
by setting it to [].
A syntax in the config without a syntax file, like postcss, showed
E484 on opening a file. Skip loading it, with a warning in debug.
A syntax without an indent file used cindent, which broke indent of
languages like pug, stylus without their plugins, or toml. Keep the
indent instead. Lines outside blocks still use cindent.
Run tests on GitHub Actions with Vim 8.2.0000, the latest Vim, Neovim
0.9.5 and the latest Neovim by rhysd/action-setup-vim. test/run.sh only
uses the editors in $VUE_TEST_EDITORS if set, and fails if none runs.
Clone the syntax plugins for tests at fixed commits, so changes there
don't break tests unexpectedly.
<script lang=ts> and <style lang=sass> without quotes weren't
recognized, so they used the first syntax in the config. For sass, it
also flattened the nesting when indenting. lang="typescript" wasn't
recognized either.
Languages not in the config still use the first syntax as before.
Set b:undo_ftplugin for matchpairs, matchit variables, b:syng_str and
the foldexpr settings, and b:undo_indent for indent settings, instead of
relying on whichever indent file was loaded last.
The v-bind() region in style contains cssValue.* groups, which don't
exist without css syntax, like when syntax in the config has only
script. Opening a file then showed E409 and E475. Add the style
highlights only if css syntax is loaded.
With shiftwidth=0, Vim uses the value of tabstop, but &sw is 0. So
multiline tags and brackets got wrong indent, and fold levels were wrong
as indent was divided by 0. Use shiftwidth() instead, which is the same
as &sw when it isn't 0.
s:AdjustBlockIndent() had `let block = a:block` without such an argument,
so GetVueIndent() hit E121 for every line in template, script and style.
It was hidden as errors in 'indentexpr' are silent and the function goes
on, but showed up when calling GetVueIndent() directly.
Also return [0, 0] in s:PrevMultilineEmptyTag() when no tag start is
found, instead of no value.
Add ExpectIndentEachLine() for tests to call GetVueIndent() for each
line and check the result.
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.
Syncing by block start patterns didn't restore states inside the
block, so syntax computed before a line was displayed, e.g. by
GetVueTag() or indent after jumping in a file, missed regions like a
multi-line css rule. This replaces the one-line block fix in the
previous commit.
Parsing from start takes ~190ms once for jumping to the end of a
6500-line file, and states are cached after that.
Replace the Travis tests, which used a separate repo and no longer
ran, with tests in this repo. Each case in test/cases is indented as
a whole and should be unchanged, with optional syntax, fold and tag
checks. The cases are from the previous tests, plus script-setup.vue
for <script setup> keywords and a sync check in oneline.vim.
test/run.sh runs the cases with Vim in a pseudo terminal, as syntax in
Ex mode isn't the same, and Neovim headless.
Add the APIs from https://vuejs.org/api/ that were missing, like
defineProps, defineEmits, defineModel, withDefaults, useTemplateRef
and toValue, and the options emits, expose, slots and serverPrefetch.
Also highlight them before type arguments, e.g.
defineProps<{ foo: string }>() or ref<number>(1).
A one-line block like <style>p { color: red; }</style> matched the
sync pattern of the block start, so when Vim synced syntax at or after
it, e.g. after jumping to a later line, the following blocks were
taken as inside the style block.