Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions syntax/svelte.vim
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,15 @@ highlight default link cssKeyFrameProp2 Constant
" Syntax patch {{{
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Patch 7.4.1142
if has("patch-7.4-1142")
if has("win32")
syn iskeyword @,48-57,_,128-167,224-235,$
else
syn iskeyword @,48-57,_,192-255,$
" Add '$' to keyword characters for svelteKeyword, keeping others like '-'
" from css.vim for css keywords such as font-size
if has('patch-7.4.1142') && exists('*execute')
let s:iskeyword = matchstr(execute('syntax iskeyword'),
\ 'syntax iskeyword \zs\S\+')
if empty(s:iskeyword) || s:iskeyword ==# 'not'
let s:iskeyword = &iskeyword
endif
execute 'syntax iskeyword '.s:iskeyword.',$'
endif

" Style
Expand Down
16 changes: 16 additions & 0 deletions test/cases/dollar.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<script>
import { count } from './stores';

$: doubled = $count * 2;
$: {
console.log(doubled);
}
</script>

<p>{$count}</p>

<style>
p {
font-size: 2em;
}
</style>
9 changes: 9 additions & 0 deletions test/cases/dollar.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
" $: reactive statements and $store in script, css keywords with '-'
let g:test_flatten = 1

function! Check()
call ExpectSyntax('$: doubled', 'svelteKeyword')
call ExpectNoSyntax('$count', 'svelteKeyword')
call ExpectSyntax('$: {', 'svelteKeyword')
call ExpectSyntax('font-size', 'cssFontProp')
endfunction
Loading