From a1e2551d916f0ac704f2c541099bf0319ca5b603 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Sun, 16 Aug 2020 14:12:52 -0700 Subject: [PATCH] Add more complete ReasonML language support This builds on 4e1b9f6a by adding testing support and documentation. It also revises the region match patterns with more flexible white space handling. --- Makefile | 5 ++++- README.md | 20 ++++++++++++++++++++ after/syntax/reason/graphql.vim | 4 ++-- doc/graphql.txt | 6 ++++++ test/reason/default.vader | 20 ++++++++++++++++++++ 5 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 test/reason/default.vader diff --git a/Makefile b/Makefile index ff36c0d..be87af2 100644 --- a/Makefile +++ b/Makefile @@ -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: @@ -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 diff --git a/README.md b/README.md index 6ebb911..6fd7c66 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/after/syntax/reason/graphql.vim b/after/syntax/reason/graphql.vim index b0c86af..14ec4ea 100644 --- a/after/syntax/reason/graphql.vim +++ b/after/syntax/reason/graphql.vim @@ -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 diff --git a/doc/graphql.txt b/doc/graphql.txt index 74c76b4..49067ff 100644 --- a/doc/graphql.txt +++ b/doc/graphql.txt @@ -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: diff --git a/test/reason/default.vader b/test/reason/default.vader new file mode 100644 index 0000000..a38826c --- /dev/null +++ b/test/reason/default.vader @@ -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')