diff --git a/.github/workflows/update-grammars.yml b/.github/workflows/update-grammars.yml index 61c8574e7..f1ff76046 100644 --- a/.github/workflows/update-grammars.yml +++ b/.github/workflows/update-grammars.yml @@ -55,6 +55,7 @@ jobs: - glsl - go - gpr + - graphql - groovy - haskell - haxe diff --git a/.gitmodules b/.gitmodules index f29cdd662..64a398377 100644 --- a/.gitmodules +++ b/.gitmodules @@ -630,3 +630,9 @@ update = none ignore = dirty branch = master +[submodule "repos/graphql"] + path = repos/graphql + url = https://github.com/bkegley/tree-sitter-graphql + update = none + ignore = dirty + branch = master diff --git a/CHANGELOG.md b/CHANGELOG.md index 35af75c14..6b4cd9e1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## Unreleased +- Add `GraphQL` support ## 0.12.301 - 2025-08-24 diff --git a/queries/graphql/highlights.scm b/queries/graphql/highlights.scm new file mode 100644 index 000000000..c1ee501c4 --- /dev/null +++ b/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) + +(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) + +; Directives +;----------- +(directive_definition + "@" @attribute + (name) @attribute) + +(directive) @attribute + +; Properties +;----------- +(field + (name) @property) + +(field + (alias + (name) @property)) + +(field_definition + (name) @property) + +(object_value + (object_field + (name) @property)) + +(enum_value + (name) @property) + +; 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) @number + +(float_value) @number.float + +(boolean_value) @boolean + +; Literals +;--------- +(description + (string_value) @string.documentation @spell) + +(comment) @comment @spell + +(directive_location + (executable_directive_location) @type.builtin) + +(directive_location + (type_system_directive_location) @type.builtin) + +; Keywords +;---------- +[ + "query" + "mutation" + "subscription" + "fragment" + "scalar" + "input" + "extend" + "directive" + "schema" + "on" + "repeatable" + "implements" +] @keyword + +[ + "enum" + "union" + "type" + "interface" +] @keyword.type + +; Punctuation +;------------ +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +"=" @operator + +"|" @punctuation.delimiter + +"&" @punctuation.delimiter + +":" @punctuation.delimiter + +"..." @punctuation.special + +"!" @punctuation.special diff --git a/repos/graphql b/repos/graphql new file mode 160000 index 000000000..5e66e961e --- /dev/null +++ b/repos/graphql @@ -0,0 +1 @@ +Subproject commit 5e66e961eee421786bdda8495ed1db045e06b5fe diff --git a/tree-sitter-langs.el b/tree-sitter-langs.el index fb54e9b0e..978898c4b 100644 --- a/tree-sitter-langs.el +++ b/tree-sitter-langs.el @@ -143,6 +143,7 @@ See `tree-sitter-langs-repos'." (glsl-mode . glsl) (go-mode . go) (gpr-mode . gpr) + (graphql-mode . graphql) (groovy-mode . groovy) (jenkinsfile-mode . groovy) (haskell-mode . haskell)