Skip to content

Support escape seq in backtick strings #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 24, 2022
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
27 changes: 27 additions & 0 deletions examples/rescript-project/src/escapeSyntax.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
let a = "abc"

let str = "aaa\"bbb"

Js.log(` \` ccc ${a} ddd `)

Js.log(`a = ${a}`)

Js.log(``)

Js.log(`\``)

Js.log(`first line\nsecond line`)

Js.log(`first line\r\nsecond line`)

Js.log(`
multi line
\`
multi line
`)

let b = 34

let parser = %raw(`
adsfadsfzz
`)
13 changes: 8 additions & 5 deletions syntax/rescript.vim
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,16 @@ syntax match resAttribute "\v\@([a-zA-z][A-Za-z0-9_']*)(\.([a-zA-z])[A-Za-z0-9_'

" String
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
syntax match resStringEscapeSeq "\v\\[\\"ntbrf]" contained
syntax match resInterpolatedStringEscapeSeq "\v\\[\\`ntbrf]" contained

syntax region resString start="\v\"" end="\v\"" contains=resStringEscapeSeq,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,resInterpolationVariable
syntax region resString start="\v`" end="\v`" contains=resInterpolationBlock,resInterpolatedStringEscapeSeq
syntax region resString start="\v[a-z]`" end="\v`" contains=resInterpolationBlock,resInterpolationVariable,resInterpolatedStringEscapeSeq

" Polymorphic variants
syntax match resPolyVariant "\v#[A-za-z][A-Za-z0-9_'$]*"
Expand All @@ -109,7 +111,8 @@ highlight default link resModuleOrVariant Function
highlight default link resPolyVariant Function
highlight default link resModuleChain Macro
highlight default link resUnicodeChar Character
highlight default link resEscapedChar Character
highlight default link resStringEscapeSeq Character
highlight default link resInterpolatedStringEscapeSeq Character
highlight default link resString String
highlight default link resInterpolationDelimiters Macro
highlight default link resInterpolationVariable Macro
Expand Down