Skip to content

Commit c5f4fb1

Browse files
committed
Update interpolation syntaxes
1 parent 284d508 commit c5f4fb1

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

examples/rescript-project/src/interpolationSyntax.res

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@ let name = "Amirali"
22

33
let var = `hello ${name} how you doin?`
44

5+
let var2 = j`hello ${name} how you doin?`
6+
7+
let var3 = j`hello $name how you doin?`
8+
9+
let varInvalid = `hello $name how you doin?`
10+
511
let expr = `2 + 2 is ${Int.toString(2 + 2)}`

syntax/rescript.vim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ syntax match resUnicodeChar "\v\\u[A-Fa-f0-9]\{4}" contained
8282
syntax match resEscapedChar "\v\\[\\"'ntbrf]" contained
8383
syntax region resString start="\v\"" end="\v\"" contains=resEscapedQuote,resEscapedChar,resUnicodeChar
8484

85+
" Interpolation
86+
syntax match resInterpolationVariable "\v\$[a-z_][A-Za-z0-0_'$]*" contained
8587
syntax region resInterpolationBlock matchgroup=resInterpolationDelimiters start="\v\$\{" end="\v\}" contained contains=TOP
8688
syntax region resString start="\v`" end="\v`" contains=resInterpolationBlock
87-
syntax region resString start="\v[a-z]`" end="\v`" contains=resInterpolationBlock
89+
syntax region resString start="\v[a-z]`" end="\v`" contains=resInterpolationBlock,resInterpolationVariable
8890

8991
" Polymorphic variants
9092
syntax match resPolyVariant "\v#[A-za-z][A-Za-z0-9_'$]*"
@@ -110,6 +112,7 @@ highlight default link resUnicodeChar Character
110112
highlight default link resEscapedChar Character
111113
highlight default link resString String
112114
highlight default link resInterpolationDelimiters Macro
115+
highlight default link resInterpolationVariable Macro
113116
highlight default link resAttribute PreProc
114117

115118
let b:current_syntax = "rescript"

0 commit comments

Comments
 (0)