Add GROQ language support#7914
Conversation
0cd62ab to
735624c
Compare
|
Updated with |
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
735624c to
23e3eb1
Compare
|
Fixed the incorrect sort order in |
🤔 The fact you had to do this suggests that you might not have used the script to add your grammar as detailed in the CONTRIBUTING.md file as it does it for you. |
I was having trouble with the docker image not wanting to be run on ARMv8, and then some issues with ruby versions etc. Originally I just read what those scripts did and manually did the same steps, but just went through and forced amd64 architecture for the docker images and resolved the ruby version issues - output is the same as in the PR though (minus the extensions for js/markdown) |
Add GROQ (Graph-Relational Object Queries) as a recognized data language with syntax highlighting for
.groqfiles, JS/TS template literal injection, and markdown code block injection.source.groq,groq-injection.js,groq-injection.markdownDescription
GROQ is an open query language for JSON-like data, created by Sanity.io and published under the OWFa 1.0 license since 2019. It is purpose-built for querying and transforming content in document stores, with first-class support for references, projections, and filtering.
GROQ is widely used across the Sanity ecosystem, which includes companies like Nike, Figma, Cloudflare, Spotify, Shopify, and Riot Games. The
groqnpm package sees 800k+ weekly downloads (24M+ annually).While
.groqfiles represent one surface for the language, the majority of GROQ is written as tagged template literals in JavaScript/TypeScript (groq`*[_type == "post"]`) and in markdown code blocks (```groq). The grammar source (sanity-io/groq-syntax) provides injection grammars for both of these, following the same pattern as GraphQL in Linguist (inline.graphql,inline.graphql.markdown.codeblockvia graphql/graphiql).An ace mode recently landed as well, so this PR is also set to use that.
Usage evidence
groqtemplate literals in TSgroqtemplate literals in JS```groqmarkdown blocksimport groqin JS/TS.groqfiles (excl. forks)The
.groqextension meets the 200-file threshold for extensions that typically occur once per repository (likeMakefile). The results show broad distribution across independent users and organizations - not concentrated in Sanity's own repos.The broader surface (5,500+ template literal files, 630+ markdown code blocks) demonstrates that the community already treats GROQ as a distinct language deserving syntax highlighting.
VS Code extension
The Sanity VS Code extension has 50,000+ installs and has provided GROQ syntax highlighting since 2018. The grammar was recently extracted to a dedicated repo (sanity-io/groq-syntax) to support multiple editors and Linguist integration.
Checklist:
#fa84ffI have updated the heuristics to distinguish my language from others using the same extension.Not needed -
.groqis not used by any other language.