Skip to content

Commit 0cd62ab

Browse files
committed
Add GROQ language support
Add GROQ (Graph-Relational Object Queries) as a recognized data language with syntax highlighting for .groq files, JS/TS template literal injection, and markdown code block injection. - Grammar source: sanity-io/groq-syntax (MIT licensed) - Scopes: source.groq, groq-injection.js, groq-injection.markdown - Samples: blog query, product filter, site navigation
1 parent 537297c commit 0cd62ab

9 files changed

Lines changed: 130 additions & 0 deletions

File tree

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,9 @@
554554
[submodule "vendor/grammars/groovy.tmbundle"]
555555
path = vendor/grammars/groovy.tmbundle
556556
url = https://github.com/textmate/groovy.tmbundle
557+
[submodule "vendor/grammars/groq-syntax"]
558+
path = vendor/grammars/groq-syntax
559+
url = https://github.com/sanity-io/groq-syntax.git
557560
[submodule "vendor/grammars/haxe-TmLanguage"]
558561
path = vendor/grammars/haxe-TmLanguage
559562
url = https://github.com/vshaxe/haxe-TmLanguage

grammars.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,10 @@ vendor/grammars/graphviz.tmbundle:
453453
- source.dot
454454
vendor/grammars/groovy.tmbundle:
455455
- source.groovy
456+
vendor/grammars/groq-syntax:
457+
- groq-injection.js
458+
- groq-injection.markdown
459+
- source.groq
456460
vendor/grammars/haxe-TmLanguage:
457461
- documentation.markdown.injection.haxe
458462
- markdown.haxe.codeblock

lib/linguist/languages.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2467,6 +2467,14 @@ GN:
24672467
codemirror_mode: python
24682468
codemirror_mime_type: text/x-python
24692469
language_id: 302957008
2470+
GROQ:
2471+
type: data
2472+
color: "#fa84ff"
2473+
extensions:
2474+
- ".groq"
2475+
tm_scope: source.groq
2476+
ace_mode: text
2477+
language_id: 727704671
24702478
GSC:
24712479
type: programming
24722480
color: "#FF6800"

samples/GROQ/blog-posts.groq

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Fetch published blog posts with resolved author references
2+
*[_type == "post" && !(_id in path("drafts.**"))] | order(publishedAt desc) [0...10] {
3+
_id,
4+
title,
5+
"slug": slug.current,
6+
publishedAt,
7+
"excerpt": pt::text(body[0..2]),
8+
mainImage {
9+
asset-> {
10+
url,
11+
"dimensions": metadata.dimensions
12+
},
13+
alt
14+
},
15+
author-> {
16+
name,
17+
image {
18+
asset-> { url }
19+
}
20+
},
21+
categories[]-> {
22+
title,
23+
"slug": slug.current
24+
}
25+
}

samples/GROQ/product-filter.groq

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Product listing with faceted filtering and pagination
2+
*[
3+
_type == "product"
4+
&& category->slug.current == $category
5+
&& price >= $minPrice
6+
&& price <= $maxPrice
7+
&& ($brand == null || brand == $brand)
8+
&& count(variants[inStock == true]) > 0
9+
] | order(
10+
select(
11+
$sort == "price-asc" => price asc,
12+
$sort == "price-desc" => price desc,
13+
$sort == "newest" => _createdAt desc,
14+
_createdAt desc
15+
)
16+
) [$offset...$offset + $limit] {
17+
_id,
18+
title,
19+
"slug": slug.current,
20+
price,
21+
"compareAtPrice": math::max(variants[].compareAtPrice),
22+
"thumbnail": images[0].asset->url,
23+
"inStockCount": count(variants[inStock == true]),
24+
brand,
25+
category-> { title, "slug": slug.current }
26+
}

samples/GROQ/site-navigation.groq

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Resolve site-wide navigation with conditional projections
2+
*[_type == "siteConfig"][0] {
3+
title,
4+
description,
5+
"logoUrl": logo.asset->url,
6+
mainNavigation[] {
7+
_type == "navLink" => {
8+
"type": "link",
9+
title,
10+
url
11+
},
12+
_type == "navGroup" => {
13+
"type": "group",
14+
title,
15+
children[] {
16+
title,
17+
url,
18+
"icon": icon.asset->url
19+
}
20+
}
21+
},
22+
footer {
23+
copyright,
24+
socialLinks[] {
25+
platform,
26+
url
27+
}
28+
}
29+
}

vendor/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
214214
- **GLSL:** [euler0/sublime-glsl](https://github.com/euler0/sublime-glsl)
215215
- **GN:** [devoncarew/language-gn](https://github.com/devoncarew/language-gn)
216216
- **GSC:** [Jake-NotTheMuss/CoDT7-Sublime](https://github.com/Jake-NotTheMuss/CoDT7-Sublime)
217+
- **GROQ:** [sanity-io/groq-syntax](https://github.com/sanity-io/groq-syntax)
217218
- **Game Maker Language:** [mikomikotaishi/c.tmbundle](https://github.com/mikomikotaishi/c.tmbundle)
218219
- **Gemfile.lock:** [hmarr/gemfile-lock-tmlanguage](https://github.com/hmarr/gemfile-lock-tmlanguage)
219220
- **Gemini:** [printfn/gemini-vscode](https://github.com/printfn/gemini-vscode)

vendor/grammars/groq-syntax

Submodule groq-syntax added at a0d15cf
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: groq-syntax
3+
version: a0d15cf651c04963f8dafe836eda37cca97f5723
4+
type: git_submodule
5+
homepage: https://github.com/sanity-io/groq-syntax.git
6+
license: mit
7+
licenses:
8+
- sources: LICENSE
9+
text: |
10+
MIT License
11+
12+
Copyright (c) 2026 Sanity.io
13+
14+
Permission is hereby granted, free of charge, to any person obtaining a copy
15+
of this software and associated documentation files (the "Software"), to deal
16+
in the Software without restriction, including without limitation the rights
17+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18+
copies of the Software, and to permit persons to whom the Software is
19+
furnished to do so, subject to the following conditions:
20+
21+
The above copyright notice and this permission notice shall be included in all
22+
copies or substantial portions of the Software.
23+
24+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30+
SOFTWARE.
31+
- sources: README.md
32+
text: MIT - see [LICENSE](LICENSE).
33+
notices: []

0 commit comments

Comments
 (0)