Skip to content

Commit

Permalink
Add more complete ReasonML language support
Browse files Browse the repository at this point in the history
This builds on 4e1b9f6 by adding testing support and documentation. It
also revises the region match patterns with more flexible white space
handling.
  • Loading branch information
jparise committed Aug 16, 2020
1 parent 4e1b9f6 commit a1e2551
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ lint: .bundle/vim-vimhelplint
-c 'verb VimhelpLintEcho' \
-c q

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

.bundle/vader.vim:
Expand All @@ -19,5 +19,8 @@ test: .bundle/vader.vim .bundle/vim-javascript
.bundle/vim-javascript:
git clone --depth 1 https://github.com/pangloss/vim-javascript.git .bundle/vim-javascript

.bundle/vim-reasonml:
git clone --depth 1 https://github.com/jordwalke/vim-reasonml .bundle/vim-reasonml

.bundle/vim-vimhelplint:
git clone --depth 1 https://github.com/machakann/vim-vimhelplint.git .bundle/vim-vimhelplint
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,26 @@ filetypes can be "compound" (`javascript.jsx` and `typescript.tsx`) or use the
Syntax highlighting is also available within [Vue](https://vuejs.org/)
templates.

## ReasonML Support

GraphQL syntax support inside of [ReasonML](https://reasonml.org/) template
strings using [graphql-ppx][] is available when [vim-reasonml][] is also
installed.

```reason
[%graphql {|
query UserQuery {
user {
id
name
}
}
|}];
```

[graphql-ppx]: https://github.com/reasonml-community/graphql-ppx
[vim-reasonml]: https://github.com/jordwalke/vim-reasonml

## Testing

The test suite uses [Vader.vim](https://github.com/junegunn/vader.vim). To run
Expand Down
4 changes: 2 additions & 2 deletions after/syntax/reason/graphql.vim
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ syn include @GraphQLSyntax syntax/graphql.vim
if exists('s:current_syntax')
let b:current_syntax = s:current_syntax
endif
syntax region graphqlExtensionPoint start=/\[%graphql\s*\n\s*{|/ end=/|}\s*\n\s*\]/ contains=@GraphQLSyntax keepend

syntax region graphqlExtensionPoint start=/\[%graphql\_s*{|/ end=/|}\_s*\]/ contains=@GraphQLSyntax,reasonTemplateExpression keepend
hi def link graphqlExtensionPoint reasonTaggedTemplate
6 changes: 6 additions & 0 deletions doc/graphql.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,11 @@ plugin. For older versions, you can install yats directly.
TypeScript syntax support also uses |graphql-javascript-options| to customize
the list of recognized template tag names.

REASONML *graphql-reasonml*

GraphQL syntax support inside of ReasonML template strings using graphql-ppx
is available when vim-reasonml (https://github.com/jordwalke/vim-reasonml) is
also installed.

------------------------------------------------------------------------------
vim:tw=78:ft=help:norl:
20 changes: 20 additions & 0 deletions test/reason/default.vader
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Before:
source ../after/syntax/reason/graphql.vim

Execute (Expected syntax groups):
Assert graphql#has_syntax_group('graphqlExtensionPoint')

Given reason (Template):
[%graphql {|
query UserQuery {
user {
id
name
}
}
|}];

Execute (Syntax assertions):
" AssertEqual 'graphqlTaggedTemplate', SyntaxOf('gql')
" AssertEqual 'graphqlTemplateString', SyntaxOf('`')
AssertEqual 'graphqlName', SyntaxOf('user')

0 comments on commit a1e2551

Please sign in to comment.