Skip to content

Commit 4112c06

Browse files
committed
feat: support JavaScript syntax on template
This support: 1. Non-zero length dynamic values (:attr="variable"); 2. Zero length dynamic values (:attr=""); 3. Slots syntax (#name) now have JavaScript syntax also (#default="{ thisHere }"); There is also comments explaining commands and the mustache syntax is considered htmlSpecialChar, because it's easier to see them that way. Closes posva#143
1 parent c424294 commit 4112c06

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

syntax/vue.vim

+10-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,16 @@ endfor
7171
syn region vueSurroundingTag contained start=+<\(script\|style\|template\)+ end=+>+ fold contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent
7272
syn keyword htmlSpecialTagName contained template
7373
syn keyword htmlArg contained scoped ts
74-
syn match htmlArg "[@v:][-:.0-9_a-z]*\>" contained
74+
syn match htmlArg "[@#v:a-z][-:.0-9_a-z]*\>" contained
75+
76+
" Prevent 0 lenght vue dynamic attributes from (:id="") from overflowing from
77+
" the area described by two quotes ("" or '') this works because syntax
78+
" defined earlier in the file have priority.
79+
syn match htmlString /\(\([@#:]\|v-\)[-:.0-9_a-z]*=\)\@<=["']\{2\}/ containedin=ALLBUT,htmlComment
80+
81+
" Actually provide the JavaScript syntax highlighting.
82+
syn region vueJavascriptInTemplate start=/\(\([@#:]\|v-\)[-:.0-9_a-z]*=\)\@<=["']/ms=e+1 keepend end=/["']/me=s-1 contains=@jsAll containedin=ALL
83+
syn region vueJavascriptInTemplate matchgroup=htmlSpecialChar start=/{{/ keepend end=/}}/ contains=@jsAll containedin=ALLBUT,htmlComment
7584

7685
syntax sync fromstart
7786

0 commit comments

Comments
 (0)