mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 11:06:54 -04:00
feat(groq): add parser and queries (#8008)
This commit is contained in:
parent
a5edb0a274
commit
61ec748ef7
7 changed files with 142 additions and 0 deletions
1
SUPPORTED_LANGUAGES.md
generated
1
SUPPORTED_LANGUAGES.md
generated
|
|
@ -117,6 +117,7 @@ ecma (queries only)[^ecma] | unstable | `HFIJL` | | @steelsojka
|
||||||
[graphql](https://github.com/bkegley/tree-sitter-graphql) | unstable | `H IJ ` | | @bkegley
|
[graphql](https://github.com/bkegley/tree-sitter-graphql) | unstable | `H IJ ` | | @bkegley
|
||||||
[gren](https://github.com/MaeBrooks/tree-sitter-gren) | unstable | `H J ` | | @MaeBrooks
|
[gren](https://github.com/MaeBrooks/tree-sitter-gren) | unstable | `H J ` | | @MaeBrooks
|
||||||
[groovy](https://github.com/murtaza64/tree-sitter-groovy) | unstable | `HFIJL` | | @murtaza64
|
[groovy](https://github.com/murtaza64/tree-sitter-groovy) | unstable | `HFIJL` | | @murtaza64
|
||||||
|
[groq](https://github.com/ajrussellaudio/tree-sitter-groq) | unstable | `HFIJ ` | | @ajrussellaudio
|
||||||
[gstlaunch](https://github.com/tree-sitter-grammars/tree-sitter-gstlaunch) | unstable | `H ` | | @theHamsta
|
[gstlaunch](https://github.com/tree-sitter-grammars/tree-sitter-gstlaunch) | unstable | `H ` | | @theHamsta
|
||||||
[hack](https://github.com/slackhq/tree-sitter-hack) | unstable | `H J ` | |
|
[hack](https://github.com/slackhq/tree-sitter-hack) | unstable | `H J ` | |
|
||||||
[hare](https://github.com/tree-sitter-grammars/tree-sitter-hare) | unstable | `HFIJL` | | @amaanq
|
[hare](https://github.com/tree-sitter-grammars/tree-sitter-hare) | unstable | `HFIJL` | | @amaanq
|
||||||
|
|
|
||||||
|
|
@ -857,6 +857,14 @@ return {
|
||||||
maintainers = { '@murtaza64' },
|
maintainers = { '@murtaza64' },
|
||||||
tier = 2,
|
tier = 2,
|
||||||
},
|
},
|
||||||
|
groq = {
|
||||||
|
install_info = {
|
||||||
|
revision = '9959049ddeb4416101653a071ee923ba9f7a5cb1',
|
||||||
|
url = 'https://github.com/ajrussellaudio/tree-sitter-groq',
|
||||||
|
},
|
||||||
|
maintainers = { '@ajrussellaudio' },
|
||||||
|
tier = 2,
|
||||||
|
},
|
||||||
gstlaunch = {
|
gstlaunch = {
|
||||||
install_info = {
|
install_info = {
|
||||||
revision = '549aef253fd38a53995cda1bf55c501174372bf7',
|
revision = '549aef253fd38a53995cda1bf55c501174372bf7',
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,17 @@
|
||||||
(#offset! @injection.content 0 1 0 -1)
|
(#offset! @injection.content 0 1 0 -1)
|
||||||
(#set! injection.include-children))
|
(#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
|
(call_expression
|
||||||
function: (identifier) @_name
|
function: (identifier) @_name
|
||||||
(#eq? @_name "gql")
|
(#eq? @_name "gql")
|
||||||
|
|
|
||||||
5
runtime/queries/groq/folds.scm
Normal file
5
runtime/queries/groq/folds.scm
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
[
|
||||||
|
(object)
|
||||||
|
(projection)
|
||||||
|
(array)
|
||||||
|
] @fold
|
||||||
104
runtime/queries/groq/highlights.scm
Normal file
104
runtime/queries/groq/highlights.scm
Normal file
|
|
@ -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"))
|
||||||
11
runtime/queries/groq/indents.scm
Normal file
11
runtime/queries/groq/indents.scm
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
[
|
||||||
|
(object)
|
||||||
|
(projection)
|
||||||
|
] @indent.begin
|
||||||
|
|
||||||
|
[
|
||||||
|
"{"
|
||||||
|
"}"
|
||||||
|
] @indent.branch
|
||||||
|
|
||||||
|
"}" @indent.end
|
||||||
2
runtime/queries/groq/injections.scm
Normal file
2
runtime/queries/groq/injections.scm
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
((comment) @injection.content
|
||||||
|
(#set! injection.language "comment"))
|
||||||
Loading…
Add table
Add a link
Reference in a new issue