diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 4510efb..784dd11 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -6,10 +6,23 @@ on:
jobs:
test:
+ name: ${{ matrix.neovim && 'nvim' || 'vim' }} ${{ matrix.version }}
runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - { neovim: false, version: v8.2.0000 }
+ - { neovim: false, version: stable }
+ - { neovim: true, version: v0.9.5 }
+ - { neovim: true, version: stable }
steps:
- uses: actions/checkout@v4
- - name: Install Vim and Neovim
- run: sudo apt-get update && sudo apt-get install -y vim neovim
+ - uses: rhysd/action-setup-vim@v1
+ with:
+ neovim: ${{ matrix.neovim }}
+ version: ${{ matrix.version }}
- name: Run tests
run: ./test/run.sh
+ env:
+ SVELTE_TEST_EDITORS: ${{ matrix.neovim && 'nvim' || 'vim' }}
diff --git a/.gitignore b/.gitignore
index 20641df..137ca65 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@ README.html
test.svelte
.idea
test/deps/
+doc/tags
diff --git a/README.md b/README.md
index 052ec1f..f2a5be8 100644
--- a/README.md
+++ b/README.md
@@ -43,6 +43,8 @@ Vim syntax and indent plugin for `.svelte` files. Forked from [vim-vue-plugin][3
This plugin works if it has set `filetype` to `svelte`. Please stay up to date. Feel free to open an issue or pull request.
+See `:help vim-svelte-plugin` for the documentation in Vim.
+
## How it works
It combines HTML, CSS and JavaScript syntax and indent in one file.
@@ -70,7 +72,7 @@ Set global variable to `1` to enable or `0` to disable. Ex:
| g:vim_svelte_plugin_load_full_syntax \* | Enable: load all syntax files in `runtimepath` to enable related syntax plugins. Disable: only in `$VIMRUNTIME/syntax`, `~/.vim/syntax` and `$VIM/vimfiles/syntax` | 0 |
| g:vim_svelte_plugin_use_pug \* | Enable pug syntax for ``. | 0 |
| g:vim_svelte_plugin_use_coffee | Enable coffee syntax for `+
- \ keepend contains=@htmlCoffeeScript,jsImport,jsExport,svelteTag
-
-syntax region typescriptSvelteScript fold
- \ start=++
- \ keepend contains=@TypeScript,svelteTag
-
-syntax region cssLessSvelteStyle fold
- \ start=++
- \ keepend contains=@LessSyntax,svelteTag
+" lang="..." in double quotes, also in single quotes or without quotes if the
+" language is enabled. Otherwise those stay in the default language as before
+function! s:Lang(lang, enabled)
+ return a:enabled
+ \ ? 'lang=["'']\?'.a:lang.'\>["'']\?'
+ \ : 'lang="'.a:lang.'"'
+endfunction
+
+execute 'syntax region pugSvelteTemplate fold'
+ \ 'start=+]*'.s:Lang('pug', s:use_pug).'[^>]*>+'
+ \ 'end=++'
+ \ 'keepend contains=@PugSyntax,svelteTag'
+
+execute 'syntax region coffeeSvelteScript fold'
+ \ 'start=++'
+ \ 'keepend contains=@htmlCoffeeScript,jsImport,jsExport,svelteTag'
+
+" Without TypeScript syntax enabled, highlight it as JavaScript
+execute 'syntax region typescriptSvelteScript fold'
+ \ 'start=++'
+ \ 'keepend'
+ \ s:use_typescript
+ \ ? 'contains=@TypeScript,svelteTag'
+ \ : 'contains=@htmlJavaScript,jsImport,jsExport,svelteTag,svelteKeyword'
+
+execute 'syntax region cssLessSvelteStyle fold'
+ \ 'start=++'
+ \ 'keepend contains=@LessSyntax,svelteTag'
" SugarSS (lang="sss") is indent-based like sass
-syntax region cssSassSvelteStyle fold
- \ start=++
- \ keepend contains=@SassSyntax,svelteTag
-syntax region cssScssSvelteStyle fold
- \ start=++
- \ keepend contains=@SassSyntax,svelteTag
-syntax region cssStylusSvelteStyle fold
- \ start=++
- \ keepend contains=@StylusSyntax,svelteTag
+execute 'syntax region cssSassSvelteStyle fold'
+ \ 'start=++'
+ \ 'keepend contains=@SassSyntax,svelteTag'
+execute 'syntax region cssScssSvelteStyle fold'
+ \ 'start=++'
+ \ 'keepend contains=@SassSyntax,svelteTag'
+execute 'syntax region cssStylusSvelteStyle fold'
+ \ 'start=++'
+ \ 'keepend contains=@StylusSyntax,svelteTag'
syntax region svelteTag
\ start=+^<[^/]+ end=+>+ skip=+>+
diff --git a/test/cases/basic.vim b/test/cases/basic.vim
index f1c2bbd..b15096f 100644
--- a/test/cases/basic.vim
+++ b/test/cases/basic.vim
@@ -8,4 +8,12 @@ function! Check()
call ExpectEqual(getline('.'), '', 'after % from
+
+
{count}
+
+
+
+
diff --git a/test/cases/lang-attr-disabled.vim b/test/cases/lang-attr-disabled.vim
new file mode 100644
index 0000000..3d04911
--- /dev/null
+++ b/test/cases/lang-attr-disabled.vim
@@ -0,0 +1,7 @@
+" Without the language enabled, lang in single quotes stays in the default
+" language as before, while lang="..." uses its own block
+function! Check()
+ call ExpectBlock('let count', 'script', 'typescript', 'typescriptSvelteScript')
+ call ExpectBlock('color: red', 'style', 'css', 'cssSvelteStyle')
+ call ExpectBlock('color: red', 'style', 'scss', 'cssScssSvelteStyle')
+endfunction
diff --git a/test/cases/lang-attr.svelte b/test/cases/lang-attr.svelte
new file mode 100644
index 0000000..0e0e3ef
--- /dev/null
+++ b/test/cases/lang-attr.svelte
@@ -0,0 +1,9 @@
+
+
+
{count}
+
+
diff --git a/test/cases/lang-attr.vim b/test/cases/lang-attr.vim
new file mode 100644
index 0000000..caa0e70
--- /dev/null
+++ b/test/cases/lang-attr.vim
@@ -0,0 +1,7 @@
+" lang attribute in single quotes or without quotes
+let g:vim_svelte_plugin_use_sass = 1
+
+function! Check()
+ call ExpectBlock('let count', 'script', 'typescript', 'typescriptSvelteScript')
+ call ExpectBlock('$a: 1px', 'style', 'scss', 'cssScssSvelteStyle')
+endfunction
diff --git a/test/cases/multiline-tag.svelte b/test/cases/multiline-tag.svelte
new file mode 100644
index 0000000..bf37085
--- /dev/null
+++ b/test/cases/multiline-tag.svelte
@@ -0,0 +1,18 @@
+
+ text
+
+
+
+
end
+
diff --git a/test/cases/multiline-tag.vim b/test/cases/multiline-tag.vim
new file mode 100644
index 0000000..49e0002
--- /dev/null
+++ b/test/cases/multiline-tag.vim
@@ -0,0 +1,14 @@
+" Lines after a multiline start tag or empty tag ending with '>' or '/>'
+let g:test_flatten = 1
+
+function! Check()
+ " Indent of each line, as when typing it
+ for lnum in range(2, line('$'))
+ let v:lnum = lnum
+ try
+ call ExpectEqual(GetSvelteIndent(), indent(lnum), 'indent at line '.lnum)
+ catch
+ call Fail('line '.lnum.': '.v:exception)
+ endtry
+ endfor
+endfunction
diff --git a/test/cases/no-devdocs.svelte b/test/cases/no-devdocs.svelte
new file mode 100644
index 0000000..d87d760
--- /dev/null
+++ b/test/cases/no-devdocs.svelte
@@ -0,0 +1 @@
+