@elastic/textmate-esql
v4.35.0
Published
TextMate grammar for ES|QL syntax highlighting
Readme
@elastic/textmate-esql
TextMate grammar for ES|QL syntax highlighting.
Usable in any editor or tool that supports TextMate grammars: VS Code, Sublime Text, Zed, and syntax highlighters such as shiki.
Installation
npm install @elastic/textmate-esqlUsage
As a JavaScript/TypeScript import
import { grammar } from '@elastic/textmate-esql';The grammar export is a plain object matching the TextMate grammar JSON schema. Pass it directly to any tool that accepts a TextMate grammar, for example shiki:
import { createHighlighter } from 'shiki';
import { grammar } from '@elastic/textmate-esql';
const highlighter = await createHighlighter({
themes: ['github-dark'],
langs: [{ ...grammar, name: 'esql' }],
});
const html = highlighter.codeToHtml('FROM logs | LIMIT 10', {
lang: 'esql',
theme: 'github-dark',
});As raw grammar files
The package also ships the grammar in the syntaxes/ directory, for tools that reference grammar files by path (VS Code extensions, Sublime Text packages, JetBrains TextMate bundles):
syntaxes/esql.tmLanguage.json— JSON formatsyntaxes/esql.tmLanguage— XML plist format
Development
The source of truth is src/index.ts — the grammar is authored in TypeScript and pulls command, function, and keyword lists from @elastic/esql-definitions, so it stays in sync with the ES|QL language as definitions are updated. Alternations are sorted longest-first at build time, as TextMate regexes require.
Build files under syntaxes/ are build artifacts regenerated by pnpm build — do not edit them by hand.
pnpm build # compile TS and regenerate syntaxes/ artifacts
pnpm test # structural checks + shiki-based tokenization testsVisual testing is available through the repo-level Storybook (pnpm storybook at the repo root, then see TextmateEsql/Grammar).
License
MIT
