aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitmodules4
-rw-r--r--book/src/generated/lang-support.md1
m---------helix-syntax/languages/tree-sitter-graphql0
-rw-r--r--languages.toml8
-rw-r--r--runtime/queries/graphql/highlights.scm163
-rw-r--r--runtime/queries/javascript/injections.scm8
6 files changed, 184 insertions, 0 deletions
diff --git a/.gitmodules b/.gitmodules
index 118fa2d8..780d1b63 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -206,6 +206,10 @@
path = helix-syntax/languages/tree-sitter-git-config
url = https://github.com/the-mikedavis/tree-sitter-git-config.git
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"]
path = helix-syntax/languages/tree-sitter-elm
url = https://github.com/elm-tooling/tree-sitter-elm
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index bfaac97b..fa8aa3ef 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -18,6 +18,7 @@
| git-rebase | ✓ | | | |
| glsl | ✓ | | ✓ | |
| go | ✓ | ✓ | ✓ | `gopls` |
+| graphql | ✓ | | | |
| haskell | ✓ | | | |
| html | ✓ | | | |
| java | ✓ | | | |
diff --git a/helix-syntax/languages/tree-sitter-graphql b/helix-syntax/languages/tree-sitter-graphql
new file mode 160000
+Subproject 5e66e961eee421786bdda8495ed1db045e06b5f
diff --git a/languages.toml b/languages.toml
index ea93df3a..f9362eac 100644
--- a/languages.toml
+++ b/languages.toml
@@ -569,6 +569,14 @@ comment-token = "#"
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]]
name = "elm"
scope = "source.elm"
injection-regex = "elm"
diff --git a/runtime/queries/graphql/highlights.scm b/runtime/queries/graphql/highlights.scm
new file mode 100644
index 00000000..9fab4051
--- /dev/null
+++ b/runtime/queries/graphql/highlights.scm
@@ -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
diff --git a/runtime/queries/javascript/injections.scm b/runtime/queries/javascript/injections.scm
index 5539241a..e8429111 100644
--- a/runtime/queries/javascript/injections.scm
+++ b/runtime/queries/javascript/injections.scm
@@ -9,6 +9,14 @@
]
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
((regex_pattern) @injection.content