feat(languages): GraphQL (#1515)

* Add Graphql language support

* Fix docs gen

* Add JS Graphql injection query

* Updates based on PR feedback

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
pull/1555/head
Jared Ramirez 3 years ago committed by GitHub
parent f453f8724d
commit 0b55b21f30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

4
.gitmodules vendored

@ -206,6 +206,10 @@
path = helix-syntax/languages/tree-sitter-git-config path = helix-syntax/languages/tree-sitter-git-config
url = https://github.com/the-mikedavis/tree-sitter-git-config.git url = https://github.com/the-mikedavis/tree-sitter-git-config.git
shallow = true shallow = true
[submodule "helix-syntax/languages/tree-sitter-graphql"]
path = helix-syntax/languages/tree-sitter-graphql
url = https://github.com/bkegley/tree-sitter-graphql
shallow = true
[submodule "helix-syntax/languages/tree-sitter-elm"] [submodule "helix-syntax/languages/tree-sitter-elm"]
path = helix-syntax/languages/tree-sitter-elm path = helix-syntax/languages/tree-sitter-elm
url = https://github.com/elm-tooling/tree-sitter-elm url = https://github.com/elm-tooling/tree-sitter-elm

@ -18,6 +18,7 @@
| git-rebase | ✓ | | | | | git-rebase | ✓ | | | |
| glsl | ✓ | | ✓ | | | glsl | ✓ | | ✓ | |
| go | ✓ | ✓ | ✓ | `gopls` | | go | ✓ | ✓ | ✓ | `gopls` |
| graphql | ✓ | | | |
| haskell | ✓ | | | | | haskell | ✓ | | | |
| html | ✓ | | | | | html | ✓ | | | |
| java | ✓ | | | | | java | ✓ | | | |

@ -0,0 +1 @@
Subproject commit 5e66e961eee421786bdda8495ed1db045e06b5fe

@ -568,6 +568,14 @@ injection-regex = "git-config"
comment-token = "#" comment-token = "#"
indent = { tab-width = 4, unit = "\t" } indent = { tab-width = 4, unit = "\t" }
[[language]]
name = "graphql"
scope = "source.graphql"
injection-regex = "graphql"
file-types = ["gql", "graphql"]
roots = []
indent = { tab-width = 2, unit = " " }
[[language]] [[language]]
name = "elm" name = "elm"
scope = "source.elm" scope = "source.elm"

@ -0,0 +1,163 @@
; Types
;------
(scalar_type_definition
(name) @type)
(object_type_definition
(name) @type)
(interface_type_definition
(name) @type)
(union_type_definition
(name) @type)
(enum_type_definition
(name) @type)
(input_object_type_definition
(name) @type)
(directive_definition
(name) @type)
(directive_definition
"@" @type)
(scalar_type_extension
(name) @type)
(object_type_extension
(name) @type)
(interface_type_extension
(name) @type)
(union_type_extension
(name) @type)
(enum_type_extension
(name) @type)
(input_object_type_extension
(name) @type)
(named_type
(name) @type)
(directive) @type
; Properties
;-----------
(field
(name) @variable.other.member)
(field
(alias
(name) @variable.other.member))
(field_definition
(name) @variable.other.member)
(object_value
(object_field
(name) @variable.other.member))
(enum_value
(name) @variable.other.member)
; Variable Definitions and Arguments
;-----------------------------------
(operation_definition
(name) @variable)
(fragment_name
(name) @variable)
(input_fields_definition
(input_value_definition
(name) @variable.parameter))
(argument
(name) @variable.parameter)
(arguments_definition
(input_value_definition
(name) @variable.parameter))
(variable_definition
(variable) @variable.parameter)
(argument
(value
(variable) @variable))
; Constants
;----------
(string_value) @string
(int_value) @constants.numeric.integer
(float_value) @constants.numeric.float
(boolean_value) @constants.builtin.boolean
; Literals
;---------
(description) @comment
(comment) @comment
(directive_location
(executable_directive_location) @type.builtin)
(directive_location
(type_system_directive_location) @type.builtin)
; Keywords
;----------
[
"query"
"mutation"
"subscription"
"fragment"
"scalar"
"type"
"interface"
"union"
"enum"
"input"
"extend"
"directive"
"schema"
"on"
"repeatable"
"implements"
] @keyword
; Punctuation
;------------
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
"=" @operator
"|" @punctuation.delimiter
"&" @punctuation.delimiter
":" @punctuation.delimiter
"..." @punctuation.special
"!" @punctuation.special

@ -9,6 +9,14 @@
] ]
arguments: (template_string) @injection.content) arguments: (template_string) @injection.content)
; Parse the contents of gql template literals
((call_expression
function: (identifier) @_template_function_name
arguments: (template_string) @injection.content)
(#eq? @_template_function_name "gql")
(#set! injection.language "graphql"))
; Parse regex syntax within regex literals ; Parse regex syntax within regex literals
((regex_pattern) @injection.content ((regex_pattern) @injection.content

Loading…
Cancel
Save