diff options
| author | Alan Russell <ajrussellaudio@gmail.com> | 2025-07-18 17:04:42 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-18 18:04:42 +0200 |
| commit | 61ec748ef7624b1962f392191aad61b91c0f9829 (patch) | |
| tree | 84fb1dedbe96ca7b624058b8c1ab400c32a5be86 | |
| parent | feat(parsers): update arduino, editorconfig, gdscript, idl, javadoc, koto, ma... (diff) | |
| download | nvim-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)
| -rw-r--r-- | SUPPORTED_LANGUAGES.md | 1 | ||||
| -rw-r--r-- | lua/nvim-treesitter/parsers.lua | 8 | ||||
| -rw-r--r-- | runtime/queries/ecma/injections.scm | 11 | ||||
| -rw-r--r-- | runtime/queries/groq/folds.scm | 5 | ||||
| -rw-r--r-- | runtime/queries/groq/highlights.scm | 104 | ||||
| -rw-r--r-- | runtime/queries/groq/indents.scm | 11 | ||||
| -rw-r--r-- | runtime/queries/groq/injections.scm | 2 |
7 files changed, 142 insertions, 0 deletions
diff --git a/SUPPORTED_LANGUAGES.md b/SUPPORTED_LANGUAGES.md index a3aabea78..ded6c7a66 100644 --- a/SUPPORTED_LANGUAGES.md +++ b/SUPPORTED_LANGUAGES.md @@ -117,6 +117,7 @@ ecma (queries only)[^ecma] | unstable | `HFIJL` | | @steelsojka [graphql](https://github.com/bkegley/tree-sitter-graphql) | unstable | `H IJ ` | | @bkegley [gren](https://github.com/MaeBrooks/tree-sitter-gren) | unstable | `H J ` | | @MaeBrooks [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 [hack](https://github.com/slackhq/tree-sitter-hack) | unstable | `H J ` | | [hare](https://github.com/tree-sitter-grammars/tree-sitter-hare) | unstable | `HFIJL` | | @amaanq diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index ba034d42b..ef84595de 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -857,6 +857,14 @@ return { maintainers = { '@murtaza64' }, tier = 2, }, + groq = { + install_info = { + revision = '9959049ddeb4416101653a071ee923ba9f7a5cb1', + url = 'https://github.com/ajrussellaudio/tree-sitter-groq', + }, + maintainers = { '@ajrussellaudio' }, + tier = 2, + }, gstlaunch = { install_info = { revision = '549aef253fd38a53995cda1bf55c501174372bf7', 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")) |
