Repository navigation
Fix TypeScript, indent and compatibility issues, add help doc and CI matrix - #31
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merge of 8 branches, each with regression tests:
<script lang="ts">as JavaScript withoutg:vim_svelte_plugin_use_typescript, instead of no highlight and removed indent.GetSvelteSubtype()still returnstypescript.lang='ts'andlang=scssin single quotes or without quotes, for TypeScript and enabled languages.doc/vim-svelte-plugin.txtfor:help vim-svelte-plugin.E714and one level too deep indent after a multiline tag ending with>.shiftwidth=0in indent and fold byshiftwidth().xdg-openon any Unix other than macOS, and remove!from the searched text.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.