Skip to content

Fix TypeScript, indent and compatibility issues, add help doc and CI matrix - #31

Merged
leafOfTree merged 17 commits into
masterfrom
svelte-fixes
Oct 21, 2026
Merged

leafOfTree merged 17 commits into
masterfrom
svelte-fixes

Conversation

@leafOfTree

Copy link
Copy Markdown
Owner

Merge of 8 branches, each with regression tests:

  • ts-default: highlight and indent <script lang="ts"> as JavaScript without g:vim_svelte_plugin_use_typescript, instead of no highlight and removed indent. GetSvelteSubtype() still returns typescript.
  • lang-attr: allow lang='ts' and lang=scss in single quotes or without quotes, for TypeScript and enabled languages.
  • help-doc: add doc/vim-svelte-plugin.txt for :help vim-svelte-plugin.
  • multiline-tag-indent: fix E714 and one level too deep indent after a multiline tag ending with >.
  • shiftwidth-zero: support shiftwidth=0 in indent and fold by shiftwidth().
  • devdocs-compat: make the devdocs mapping work in Vim before 8.2.1978, map it only in Normal and Visual mode, use xdg-open on any Unix other than macOS, and remove ! from the searched text.
  • cleanup: undo foldexpr settings when filetype changes, remove unused variables.
  • ci-matrix: test with Vim 8.2.0000, latest Vim, Neovim 0.9.5 and latest Neovim, with test deps at fixed commits.

Behavior changes: <script lang="ts"> without TypeScript enabled now has JavaScript highlight and indent; the devdocs key is no longer mapped in Operator-pending and Select mode.

Without g:vim_svelte_plugin_use_typescript, the TypeScript cluster was
empty, so <script lang="ts"> had no highlighting and indenting it
removed all indent. Use JavaScript syntax and indent for it instead.
The region name is kept, so GetSvelteTag() and GetSvelteSubtype() still
return 'script' and 'typescript'.
s:PrevMultilineEmptyTag() looked for the tag start with '^<$', which
matches almost nothing, so it reached the first line and returned no
value, causing E714 in GetSvelteIndent(). The line after a multiline
empty tag like <input ...> was also indented one level too deep.

Look for a line starting a tag without its '>', and return [0, 0] when
none is found.
With shiftwidth=0, Vim uses the value of tabstop, but &sw is 0. So
blocks and multiline tags weren't indented, 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.
<Cmd> needs Vim 8.2.1978 or Neovim 0.5. Use :call in Normal mode for
older versions. Map only in Normal and Visual mode, as it isn't useful
in Operator-pending or Select mode.

Also use xdg-open on any Unix other than macOS, as has('linux') is only
in newer Vim, and remove '!' from the text, which :! expands to the
previous command.
Restore foldmethod and foldexpr by b:undo_ftplugin when the filetype
changes. Remove unused variables in autoload/svelte.vim and
ftplugin/svelte/fold.vim.
<script lang='ts'> and <style lang=scss> weren't recognized. Allow them
for TypeScript, which falls back to JavaScript, and for the other
languages when they're enabled. If not enabled, they stay in the default
language as before, instead of a block without syntax.
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 $SVELTE_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.
Add doc/vim-svelte-plugin.txt for :help with the configuration,
functions and mappings in README.
@leafOfTree
leafOfTree merged commit 33258d1 into master Oct 21, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant