aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/queries
diff options
context:
space:
mode:
authorAlan Russell <ajrussellaudio@gmail.com>2025-07-18 17:04:42 +0100
committerGitHub <noreply@github.com>2025-07-18 18:04:42 +0200
commit61ec748ef7624b1962f392191aad61b91c0f9829 (patch)
tree84fb1dedbe96ca7b624058b8c1ab400c32a5be86 /runtime/queries
parentfeat(parsers): update arduino, editorconfig, gdscript, idl, javadoc, koto, ma... (diff)
downloadnvim-treesitter-61ec748ef7624b1962f392191aad61b91c0f9829.tar
nvim-treesitter-61ec748ef7624b1962f392191aad61b91c0f9829.tar.gz
nvim-treesitter-61ec748ef7624b1962f392191aad61b91c0f9829.tar.bz2
nvim-treesitter-61ec748ef7624b1962f392191aad61b91c0f9829.tar.lz
nvim-treesitter-61ec748ef7624b1962f392191aad61b91c0f9829.tar.xz
nvim-treesitter-61ec748ef7624b1962f392191aad61b91c0f9829.tar.zst
nvim-treesitter-61ec748ef7624b1962f392191aad61b91c0f9829.zip
feat(groq): add parser and queries (#8008)
Diffstat (limited to 'runtime/queries')
-rw-r--r--runtime/queries/ecma/injections.scm11
-rw-r--r--runtime/queries/groq/folds.scm5
-rw-r--r--runtime/queries/groq/highlights.scm104
-rw-r--r--runtime/queries/groq/indents.scm11
-rw-r--r--runtime/queries/groq/injections.scm2
5 files changed, 133 insertions, 0 deletions
diff --git a/runtime/queries/ecma/injections.scm b/runtime/queries/ecma/injections.scm
index 04abafcde..669c75671 100644
--- a/runtime/queries/ecma/injections.scm
+++ b/runtime/queries/ecma/injections.scm
@@ -48,6 +48,17 @@
(#offset! @injection.content 0 1 0 -1)
(#set! injection.include-children))
+; Sanity CMS GROQ query
+; defineQuery(`...`)
+(call_expression
+ function: (identifier) @_name
+ (#eq? @_name "defineQuery")
+ arguments: (arguments
+ (template_string) @injection.content)
+ (#offset! @injection.content 0 1 0 -1)
+ (#set! injection.include-children)
+ (#set! injection.language "groq"))
+
(call_expression
function: (identifier) @_name
(#eq? @_name "gql")
diff --git a/runtime/queries/groq/folds.scm b/runtime/queries/groq/folds.scm
new file mode 100644
index 000000000..1eb05837d
--- /dev/null
+++ b/runtime/queries/groq/folds.scm
@@ -0,0 +1,5 @@
+[
+ (object)
+ (projection)
+ (array)
+] @fold
diff --git a/runtime/queries/groq/highlights.scm b/runtime/queries/groq/highlights.scm
new file mode 100644
index 000000000..e320e42c3
--- /dev/null
+++ b/runtime/queries/groq/highlights.scm
@@ -0,0 +1,104 @@
+; Keywords
+[
+ "select"
+ "asc"
+ "desc"
+] @keyword
+
+[
+ "in"
+ "match"
+] @keyword.operator
+
+; Operators
+[
+ "=="
+ "!="
+ ">"
+ ">="
+ "<"
+ "<="
+ "&&"
+ "||"
+ "!"
+ "+"
+ "-"
+ "*"
+ "/"
+ "%"
+ "**"
+ ".."
+ "..."
+ "=>"
+ "->"
+ "|"
+] @operator
+
+; Punctuation
+[
+ "("
+ ")"
+ "["
+ "]"
+ "{"
+ "}"
+] @punctuation.bracket
+
+[
+ ","
+ ":"
+ "."
+] @punctuation.delimiter
+
+; Literals
+(string) @string
+
+(number) @number
+
+[
+ (true)
+ (false)
+] @boolean
+
+; Special references
+[
+ (null)
+ (star)
+ (parent)
+ (this)
+] @constant.builtin
+
+; Identifiers
+(identifier) @variable
+
+; Parameters
+(parameter
+ "$" @variable.parameter
+ (identifier) @variable.parameter)
+
+; Function calls
+(function_call
+ (identifier) @function)
+
+(order_function
+ "order" @function.builtin)
+
+; Comments
+(comment) @comment @spell
+
+; String keys in projections/objects
+(pair
+ (literal
+ (string) @property))
+
+; Highlight field names in projections
+(projection
+ (identifier) @property)
+
+; Built-in functions (essential GROQ functions)
+(function_call
+ (identifier) @function.builtin
+ (#any-of? @function.builtin
+ "count" "length" "defined" "references" "now" "dateTime" "coalesce" "unique" "max" "min" "sum"
+ "avg" "round" "floor" "ceil" "abs" "sqrt" "upper" "lower" "string" "number" "boolean" "array"
+ "object" "type" "global" "sanity" "path" "delta" "after" "before"))
diff --git a/runtime/queries/groq/indents.scm b/runtime/queries/groq/indents.scm
new file mode 100644
index 000000000..b8ce9713d
--- /dev/null
+++ b/runtime/queries/groq/indents.scm
@@ -0,0 +1,11 @@
+[
+ (object)
+ (projection)
+] @indent.begin
+
+[
+ "{"
+ "}"
+] @indent.branch
+
+"}" @indent.end
diff --git a/runtime/queries/groq/injections.scm b/runtime/queries/groq/injections.scm
new file mode 100644
index 000000000..2f0e58eb6
--- /dev/null
+++ b/runtime/queries/groq/injections.scm
@@ -0,0 +1,2 @@
+((comment) @injection.content
+ (#set! injection.language "comment"))