Skip to content
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

ReScript v11 syntax changes #78

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
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
38 changes: 38 additions & 0 deletions test/syntax/expected/highlight.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@
syntax = { {
hl_group = "resNone",
hl_group_link = "resNone"
}, {
hl_group = "resOperator",
hl_group_link = "Operator"
} }
}, {
col = 9,
Expand Down Expand Up @@ -301,4 +304,39 @@
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"
}, {
hl_group = "resOperator",
hl_group_link = "Operator"
} }
} }
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, ...)
//^