Skip to content

Commit

Permalink
Update interpolation syntaxes
Browse files Browse the repository at this point in the history
  • Loading branch information
amiralies committed Jul 7, 2021
1 parent 284d508 commit c5f4fb1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions examples/rescript-project/src/interpolationSyntax.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@ let name = "Amirali"

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

let var2 = j`hello ${name} how you doin?`

let var3 = j`hello $name how you doin?`

let varInvalid = `hello $name how you doin?`

let expr = `2 + 2 is ${Int.toString(2 + 2)}`
5 changes: 4 additions & 1 deletion syntax/rescript.vim
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ syntax match resUnicodeChar "\v\\u[A-Fa-f0-9]\{4}" contained
syntax match resEscapedChar "\v\\[\\"'ntbrf]" contained
syntax region resString start="\v\"" end="\v\"" contains=resEscapedQuote,resEscapedChar,resUnicodeChar

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

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

let b:current_syntax = "rescript"

0 comments on commit c5f4fb1

Please sign in to comment.