Skip to content

Commit

Permalink
ReScript v11 syntax changes
Browse files Browse the repository at this point in the history
- highlight `dict`, `result`, `:>` and `...`
- Don't highlight template string prefix
  • Loading branch information
aspeddro committed Jul 29, 2024
1 parent aea5715 commit 0bdb7e4
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
**Improvements:**

- Improve syntax highlighting for escaped backticks in interpolated strings ([#55](https://github.com/rescript-lang/vim-rescript/pull/55))
- Highlight improvements ([#69](https://github.com/rescript-lang/vim-rescript/pull/69))
- Highlight improvements ([#69](https://github.com/rescript-lang/vim-rescript/pull/69)) and https://github.com/rescript-lang/vim-rescript/pull/78
- Support `commentstring`. https://github.com/rescript-lang/vim-rescript/pull/76

## 2.1.0
Expand Down
7 changes: 4 additions & 3 deletions syntax/rescript.vim
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ syntax keyword resException try catch exception assert
syntax keyword resKeyword async await

" Types
syntax keyword resType bool int float char string unit promise
syntax keyword resType bool int float char string unit promise dict result
syntax keyword resType array option ref exn format
syntax match resType "list{\@!"

Expand Down Expand Up @@ -47,6 +47,8 @@ syntax match resOperator "\v\@"

syntax match resOperator "\v\!"
syntax match resOperator "\v\&"
syntax match resOperator "\v\:\>"
syntax match resOperator "\v\.\.\."

" Delimiter
syntax match resDelimiter "\v\|"
Expand Down Expand Up @@ -101,8 +103,7 @@ syntax region resCustomOperator start="\v\\\"" end="\v\""
" 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,resInterpolatedStringEscapeSeq
syntax region resString start="\v[a-z]`" end="\v`" contains=resInterpolationBlock,resInterpolationVariable,resInterpolatedStringEscapeSeq
syn region resString start=+`+ skip=+\\\\\|\\`+ end=+`+ contains=resInterpolationBlock,resInterpolationVariable,resInterpolatedStringEscapeSeq

" Polymorphic variants
syntax match resPolyVariant "\v#[A-za-z][A-Za-z0-9_'$]*"
Expand Down
32 changes: 32 additions & 0 deletions test/syntax/expected/highlight.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,36 @@
hl_group = "resType",
hl_group_link = "Type"
} }
}, {
col = 9,
row = 135,
syntax = {}
}, {
col = 10,
row = 138,
syntax = { {
hl_group = "resType",
hl_group_link = "Type"
} }
}, {
col = 10,
row = 141,
syntax = { {
hl_group = "resType",
hl_group_link = "Type"
} }
}, {
col = 21,
row = 144,
syntax = { {
hl_group = "resNone",
hl_group_link = "resNone"
} }
}, {
col = 7,
row = 147,
syntax = { {
hl_group = "resNone",
hl_group_link = "resNone"
} }
} }
15 changes: 15 additions & 0 deletions test/syntax/highlight.res
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,18 @@ let ref = ref(false)
//^
let option = None
//^

let _ = sql`select * from table`
//^

type a = dict<string>
//^

type b = result<int, string>
//^

let _ = (x: r1) => (x :> r2)
//^

foo(1, ...)
//^

0 comments on commit 0bdb7e4

Please sign in to comment.