Skip to content

Commit 13a6c74

Browse files
committed
ReScript v11 syntax changes
- highlight `dict`, `result`, `:>` and `...` - Don't highlight template string prefix
1 parent aea5715 commit 13a6c74

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

syntax/rescript.vim

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ syntax keyword resException try catch exception assert
1818
syntax keyword resKeyword async await
1919

2020
" Types
21-
syntax keyword resType bool int float char string unit promise
21+
syntax keyword resType bool int float char string unit promise dict result
2222
syntax keyword resType array option ref exn format
2323
syntax match resType "list{\@!"
2424

@@ -101,8 +101,7 @@ syntax region resCustomOperator start="\v\\\"" end="\v\""
101101
" Interpolation
102102
syntax match resInterpolationVariable "\v\$[a-z_][A-Za-z0-0_'$]*" contained
103103
syntax region resInterpolationBlock matchgroup=resInterpolationDelimiters start="\v\$\{" end="\v\}" contained contains=TOP
104-
syntax region resString start="\v`" end="\v`" contains=resInterpolationBlock,resInterpolatedStringEscapeSeq
105-
syntax region resString start="\v[a-z]`" end="\v`" contains=resInterpolationBlock,resInterpolationVariable,resInterpolatedStringEscapeSeq
104+
syn region resString start=+`+ skip=+\\\\\|\\`+ end=+`+ contains=resInterpolationBlock,resInterpolationVariable,resInterpolatedStringEscapeSeq
106105

107106
" Polymorphic variants
108107
syntax match resPolyVariant "\v#[A-za-z][A-Za-z0-9_'$]*"

test/syntax/expected/highlight.res.txt

+32
Original file line numberDiff line numberDiff line change
@@ -301,4 +301,36 @@
301301
hl_group = "resType",
302302
hl_group_link = "Type"
303303
} }
304+
}, {
305+
col = 9,
306+
row = 135,
307+
syntax = {}
308+
}, {
309+
col = 10,
310+
row = 138,
311+
syntax = { {
312+
hl_group = "resType",
313+
hl_group_link = "Type"
314+
} }
315+
}, {
316+
col = 10,
317+
row = 141,
318+
syntax = { {
319+
hl_group = "resType",
320+
hl_group_link = "Type"
321+
} }
322+
}, {
323+
col = 21,
324+
row = 144,
325+
syntax = { {
326+
hl_group = "resNone",
327+
hl_group_link = "resNone"
328+
} }
329+
}, {
330+
col = 7,
331+
row = 147,
332+
syntax = { {
333+
hl_group = "resNone",
334+
hl_group_link = "resNone"
335+
} }
304336
} }

test/syntax/highlight.res

+15
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,18 @@ let ref = ref(false)
132132
//^
133133
let option = None
134134
//^
135+
136+
let _ = sql`select * from table`
137+
//^
138+
139+
type a = dict<string>
140+
//^
141+
142+
type b = result<int, string>
143+
//^
144+
145+
let _ = (x: r1) => (x :> r2)
146+
//^
147+
148+
foo(1, ...)
149+
//^

0 commit comments

Comments
 (0)