Grammars / syntax highlighting
PRQL contains multiple grammar definitions to enable tools to highlight PRQL code. These are all intended to provide as good an experience as the grammar supports. Please raise any shortcomings in a GitHub issue.
The definitions are somewhat scattered around the codebase; this page serves as an index.
Lezer — used by CodeMirror editors. The PRQL file is at
Handlebars — currently duplicated:
- The book:
- The website (outside of the book & playground):
- The book:
Textmate — used by the VS Code extension. It’s in the
Monarch — used by the Monaco editor, which we use for the Playground. The grammar is at
Tree-Sitter — used by the neovim and helix. The grammar can be found at https://github.com/PRQL/tree-sitter-prql.
Since the Elm language coincidentally provides syntax highlighting suitable for PRQL, it may look better to mark PRQL code as Elm when the above definition files are not available.
For example, the following Markdown code block will be nicely highlighted on GitHub, Pandoc, and other Markdown renderers:
```elm from employees filter start_date > @2021-01-01 ```
We hope that in the future these renderers will recognize PRQL code blocks and have syntax highlighting applied, and we are tracking these with several issues.
- GitHub (Linguist): https://github.com/PRQL/prql/issues/1636
- Pandoc (Kate): https://github.com/PRQL/prql/issues/2213