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. |
Yep, I initially hit issues with the Docker image on ARMv8 and some Ruby version mismatches, so I read through the scripts and did the equivalent steps by hand. I've since gotten the scripts working (forcing linux/amd64 for the Docker image, fixing the Ruby version) and re-ran script/add-grammar from a clean checkout - the output matches what's currently in the PR. |
|
@lildude is there anything you'd like changed before this can move forward? Happy to adjust the grammar registration, samples, language metadata, or anything else - just let me know |
|
I've marked this as pending popularity as we can only really measure the use which this PR will impact in extensions and markdown files, and many of the results indicate this is commonly used more than once a repo, often in directories like |
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.