---
title: "Building a ShopifyQL Code Editor"
description: "Shopify integrated ShopifyQL into the CodeMirror editor by writing an adapter that feeds its existing ANTLR-based, LSP-conforming TypeScript language server into CodeMirror's Lezer parse trees, avoiding a Lezer grammar rewrite."
url: "https://swe.quest/articles/building-a-shopifyql-code-editor-ce9a095d961e0a80"
canonical: "https://shopify.engineering/building-a-shopifyql-code-editor"
source: "Shopify Engineering"
published: "2023-09-11"
difficulty: "medium"
kind: "Case study"
reading_minutes: 7
tags: ["developer-tools","frontend","typescript","compilers"]
---

# Building a ShopifyQL Code Editor

A post on [Shopify Engineering](https://swe.quest/sources/shopify.md), published 2023-09-11, 7 min read, Case study. Original: [https://shopify.engineering/building-a-shopifyql-code-editor](https://shopify.engineering/building-a-shopifyql-code-editor)

## Summary

Shopify integrated ShopifyQL into the CodeMirror editor by writing an adapter that feeds its existing ANTLR-based, LSP-conforming TypeScript language server into CodeMirror's Lezer parse trees, avoiding a Lezer grammar rewrite. The hard part was converting LSP semantic tokens, whose line and character offsets are relative to the previous token and can go negative when comments are parsed on a separate ANTLR channel, into CodeMirror's absolute document offsets. A custom TokenIterator tracks line lengths and the current position to compute absolute start and end offsets for a Lezer buffer. The language server's validate, complete and hover functions were then wired to CodeMirror's linting, autocomplete and hover-tooltip plugins.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Developer tools](https://swe.quest/tags/developer-tools.md) (Engineering practices)
- [Frontend](https://swe.quest/tags/frontend.md) (Web & mobile)
- [TypeScript](https://swe.quest/tags/typescript.md) (Languages)
- [Compilers](https://swe.quest/tags/compilers.md) (Compilers & runtimes)

## Prerequisites

- Language Server Protocol basics
- parsers and tokenization
- TypeScript ([easy posts on TypeScript](https://swe.quest/tags/typescript.md?difficulty=easy))

## Keywords

ShopifyQL, CodeMirror, Lezer, ANTLR, Language Server Protocol, ShopifyQL Notebooks

## Related posts

- [Improving the Developer Experience with the Ruby LSP](https://swe.quest/articles/improving-the-developer-experience-with-the-ruby-lsp-7b63921832eb2226.md): Shopify Engineering · 2023-02-24 · Medium · 16 min read · Ruby, Developer tools, Developer productivity
  Ruby LSP is a pure-Ruby language server from Shopify that provides editor features for Ruby without type checking or type annotations, aiming for performance and stability on large codebases like Shopify's Core monolith and leaning toward Rails-specific features.
- [Ghostwriter AI & Complete Code Beta](https://swe.quest/articles/ghostwriter-ai-complete-code-beta-eb4c500f5fc252eb.md): Replit · 2022-09-08 · Medium · 9 min read · AI for coding, Inference & serving, LLMs, Developer tools
  Replit's Ghostwriter adds AI code completion, generation, transformation, explanation and semantic search to its IDE, with Complete Code starting in closed beta.
- [Enabling low-latency, syntax-aware editing using Tree-sitter](https://swe.quest/articles/enabling-low-latency-syntax-aware-editing-using-tree-sitter-9ffe8225d976568b.md): Zed · 2023-03-27 · Medium · 10 min read · Developer tools, Compilers, Data structures, Rust
  Zed builds its syntax-aware features on Tree-sitter, a GLR-based incremental parsing framework with error recovery that produces concrete syntax trees.
- [Postgres Language Server: Initial Release](https://swe.quest/articles/postgres-language-server-initial-release-4b7148c84b3bcff0.md): Supabase · 2025-03-29 · Medium · 13 min read · PostgreSQL, Developer tools, Rust, SQL, Static analysis
  Postgres Language Server is an LSP implementation for Postgres offering autocompletion, syntax error highlighting, type-checking via PREPARE/EXPLAIN against a live database, and a Squawk-inspired linter, available for VSCode, Neovim and as a CLI.
- [Zed Has Rainbow Brackets](https://swe.quest/articles/zed-has-rainbow-brackets-56d1fa479c442850.md): Zed · 2025-12-03 · Medium · 6 min read · Developer tools, Rust, Caching, Performance engineering, Testing
  Zed implements rainbow brackets without language servers or a persistent syntax tree by running each language's tree-sitter brackets.scm queries over independent 50-row chunks and coloring pairs by nesting depth across 7 cycling theme accent colors.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
