Skip to content

Commit a1e2551

Browse files
committed
Add more complete ReasonML language support
This builds on 4e1b9f6 by adding testing support and documentation. It also revises the region match patterns with more flexible white space handling.
1 parent 4e1b9f6 commit a1e2551

5 files changed

Lines changed: 52 additions & 3 deletions

File tree

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ lint: .bundle/vim-vimhelplint
1010
-c 'verb VimhelpLintEcho' \
1111
-c q
1212

13-
test: .bundle/vader.vim .bundle/vim-javascript
13+
test: .bundle/vader.vim .bundle/vim-javascript .bundle/vim-reasonml
1414
cd test && vim -EsNu vimrc --not-a-term -c 'Vader! * */*'
1515

1616
.bundle/vader.vim:
@@ -19,5 +19,8 @@ test: .bundle/vader.vim .bundle/vim-javascript
1919
.bundle/vim-javascript:
2020
git clone --depth 1 https://github.com/pangloss/vim-javascript.git .bundle/vim-javascript
2121

22+
.bundle/vim-reasonml:
23+
git clone --depth 1 https://github.com/jordwalke/vim-reasonml .bundle/vim-reasonml
24+
2225
.bundle/vim-vimhelplint:
2326
git clone --depth 1 https://github.com/machakann/vim-vimhelplint.git .bundle/vim-vimhelplint

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,26 @@ filetypes can be "compound" (`javascript.jsx` and `typescript.tsx`) or use the
7272
Syntax highlighting is also available within [Vue](https://vuejs.org/)
7373
templates.
7474

75+
## ReasonML Support
76+
77+
GraphQL syntax support inside of [ReasonML](https://reasonml.org/) template
78+
strings using [graphql-ppx][] is available when [vim-reasonml][] is also
79+
installed.
80+
81+
```reason
82+
[%graphql {|
83+
query UserQuery {
84+
user {
85+
id
86+
name
87+
}
88+
}
89+
|}];
90+
```
91+
92+
[graphql-ppx]: https://github.com/reasonml-community/graphql-ppx
93+
[vim-reasonml]: https://github.com/jordwalke/vim-reasonml
94+
7595
## Testing
7696

7797
The test suite uses [Vader.vim](https://github.com/junegunn/vader.vim). To run

after/syntax/reason/graphql.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ syn include @GraphQLSyntax syntax/graphql.vim
2929
if exists('s:current_syntax')
3030
let b:current_syntax = s:current_syntax
3131
endif
32-
syntax region graphqlExtensionPoint start=/\[%graphql\s*\n\s*{|/ end=/|}\s*\n\s*\]/ contains=@GraphQLSyntax keepend
33-
32+
syntax region graphqlExtensionPoint start=/\[%graphql\_s*{|/ end=/|}\_s*\]/ contains=@GraphQLSyntax,reasonTemplateExpression keepend
33+
hi def link graphqlExtensionPoint reasonTaggedTemplate

doc/graphql.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,11 @@ plugin. For older versions, you can install yats directly.
4141
TypeScript syntax support also uses |graphql-javascript-options| to customize
4242
the list of recognized template tag names.
4343

44+
REASONML *graphql-reasonml*
45+
46+
GraphQL syntax support inside of ReasonML template strings using graphql-ppx
47+
is available when vim-reasonml (https://github.com/jordwalke/vim-reasonml) is
48+
also installed.
49+
4450
------------------------------------------------------------------------------
4551
vim:tw=78:ft=help:norl:

test/reason/default.vader

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Before:
2+
source ../after/syntax/reason/graphql.vim
3+
4+
Execute (Expected syntax groups):
5+
Assert graphql#has_syntax_group('graphqlExtensionPoint')
6+
7+
Given reason (Template):
8+
[%graphql {|
9+
query UserQuery {
10+
user {
11+
id
12+
name
13+
}
14+
}
15+
|}];
16+
17+
Execute (Syntax assertions):
18+
" AssertEqual 'graphqlTaggedTemplate', SyntaxOf('gql')
19+
" AssertEqual 'graphqlTemplateString', SyntaxOf('`')
20+
AssertEqual 'graphqlName', SyntaxOf('user')

0 commit comments

Comments
 (0)