Engine symbols

What the compiler tells the editor. And what each record buys us.

Each compile can write a symbols sidecar (zitex-symbols/1, pdfTeX only) next to the PDF. Main already has commands and environments. PR #2453 adds eight record kinds the engine sees and a text parser cannot. Every example below is a real sidecar, decoded by the editor's own decoder.

  • 8new record kinds in #2453
  • 2already on main
  • 30 / 39editor features wired today
  • 216new records from a 27-line project

Commands symbols[]

On mainEnd-of-run table walkTAR-72TAR-290

At the end of the run the engine walks its hash table and primitive table and writes every defined control sequence, with the definition site it recorded when the macro was assigned. Format symbols get sites from the format's .provsites sidecar.

What the engine records

name, kind
\foo; primitive, macro or control-sequence
params, body_preview
parameter text and body, as \show prints them
def
file, line, 1-based byte column; source_site for \let aliases
origin
package/class stem, body (the document) or format / unknown
internal
@-names and expl3 internals, hidden by default

Limits

  • End-of-run state only: a macro defined inside a group is gone.
  • origin names the defining file, not the package that loaded it (hpdftex.def reports body).
  • Shorthand and font definitions (\chardef, \font) report no site.

What it unlocks in the editor

  • ShippedCommand completion with signature and body, incl. package internalssymbols.ts
  • ShippedHover card: definition, origin package, alias sourcesymbols.ts
  • ShippedGo to definition of commands (F12)symbols.ts
  • FutureOpen the .sty / .cls a library macro lives insites are recorded; needs a read-only source viewer

From the real sidecar: 58 symbols in the fixture (cut to the project's own; the full capture is 11.5 MB)

nameparamsbodydeforigin
\sys_rand_seed:—\tex_the:D \tex_randomseed:D main.tex:1:1body
\sys_if_shell_unrestricted:F#1#1main.tex:1:1body
\sys_if_shell:TF#1#2#1main.tex:1:1body
\mathbf —\select@group \mathbf \M@OT1 \OT1/cmr/bx/n main.tex:24:1body
\sys_if_shell:T#1#1main.tex:1:1body

provenance_status: loaded

Environments environments[]

On mainDerived from symbolsTAR-72

A convenience list: every \foo / \endfoo pair where both are macros and \endfoo has a body. Structural, so a new package's environments appear without a name list.

What the engine records

name
environment name, no backslash
begin, end
the macro pair, \document / \enddocument

Limits

  • Advisory: the symbols stay the source of truth.
  • Internal pairs (@float) are listed; the client filters them.

What it unlocks in the editor

  • Shipped\begin{ / \end{ completion from what was really loadedsymbols.ts
  • ShippedGo to definition of environmentssymbols.ts
  • ShippedAuto-insert the matching \end{}editor/autoEndEnvironment.ts

From the real sidecar: 77 environments (article, amsmath, glossaries, supertabular …)

namebeginend
document\document\enddocument
align\align\endalign
theglossary\theglossary\endtheglossary
supertabular\supertabular\endsupertabular

Labels labels[]

New in #2453Recorder (event table)TAR-747TAR-781

Labels have no eqtb entry, so they are recorded as they happen: a hook on the aux \write at shipout keeps each \newlabel{key}{…}, and a hook on every \label call supplies where the key was typed, even when the key went through your own macro.

What the engine records

key
the label key
number, page
what \ref and \pageref will print, from the aux
anchor
hyperref anchor, or null
counter
equation, section, figure … (best effort)
def
where the \label{key} was typed

Limits

  • Only labels that were shipped: one in a discarded float is absent, as it is from the .aux.
  • A built key (\label{sec:#1}) gets the calling line but no column.

What it unlocks in the editor

  • ShippedInlay hint on \ref: what it will print (“Fig. 4”, “(3)”)lsp/labels.ts
  • Shipped\ref hover: number, counter, pagelsp/labels.ts
  • ShippedGo to definition of labels your macros madelsp/labels.ts
  • ShippedDuplicate label marked on the hint (“3?”)lsp/labels.ts
  • ShippedWorkspace symbols show each label's printed numberlsp/workspaceSymbols.ts
  • FutureDuplicate-label diagnostic for keys made by macrosthe duplicate writes are recorded; the diagnostic is text-only

From the real sidecar: 3 labels

keynumberpagecounterdef
sec:intro11sectionmain.tex:23:23
eq:a11equationmain.tex:24:24
sec:chap21sectionchapters/intro.tex:1:25

In the editor (real lsp/ output on these records)

  • hover on \ref{sec:intro}: §1 on page 1
  • hover on \ref{eq:a}: Eq. (1) on page 1
  • hover on \ref{sec:chap}: §2 on page 1
  • inlay hint after \eqref{eq:a}: (1)

References references[]

New in #2453Call-site hookTAR-747TAR-782

Every \ref-family command ends up looking up \csname r@<key>\endcsname. The engine hooks that lookup and keeps one record per place a key was typed, so a key passed through \myref{…} is found at the \myref line.

What the engine records

key
the label key (cleveref's @cref suffix removed)
kind
ref, eqref, cref, autoref, pageref … (best effort)
site
where the key's characters were typed

Limits

  • A built key (\ref{sec:#1}) gets the right line, not the key's column.
  • Probes (\@ifundefined) and the aux are filtered and counted, not recorded.
  • One record per (key, site): no per-use count.

What it unlocks in the editor

  • ShippedFind references (Shift-F12), incl. uses through your macroslsp/references.ts
  • ShippedRename a label across files; engine-only sites reported, never edited blindlsp/references.ts
  • ShippedUnused-label hint counts uses through \myrefunusedLabels.ts
  • ShippedReference counts in workspace symbolslsp/workspaceSymbols.ts
  • FutureUndefined-reference check for keys a macro buildsundefined \ref is text-only today

From the real sidecar: 3 references

keykindsite
eq:aeqrefmain.tex:25:12
sec:introrefmain.tex:25:29
sec:introrefchapters/intro.tex:2:14

references_filtered: generated_file 3, probe 3, duplicate 0, no_file 0, internal 0

In the editor (real lsp/ output on these records)

  • Find References verifies exact sites against live source bytes.

Macro uses macro_uses[]

New in #2453Call-site hookTAR-747TAR-782

A hook on macro expansion records each place one of YOUR macros was called: defined in a document file by a definer the text names (\newcommand, \def, \NewDocumentCommand, \newenvironment …). Kernel macros reassigned while your file is open are excluded.

What the engine records

name
the macro, as in symbols[].name
site
where its name was typed
count
expansions from that site over the run

Limits

  • Names only a computation spells (\csname foo#1\endcsname) are not recorded.
  • A \let alias of a format macro is not a user macro (amsthm's \endthm).

What it unlocks in the editor

  • ShippedFind references and rename of your \newcommand macroslsp/references.ts
  • FutureUnused-\newcommand hintdefinitions + uses are both recorded
  • ShippedCall counts in the macro hover (hot macros)lsp/macroUses.ts

From the real sidecar: 1 macro uses

namesitecount
\myrefmain.tex:25:221

macro_uses_stats: origin_body_calls 4779, literal_calls 1, records 1, dropped 0

In the editor (real lsp/ output on these records)

  • Find References verifies exact sites against live source bytes.

Files files[]

New in #2453Recorder (event table)TAR-783

Recorded at the two seams that also write the -recorder .fls input lines, so it is exactly the run's input set, each with the site that asked for it: \input in a chapter names the chapter, \RequirePackage names the .sty.

What the engine records

requested
the name as typed (plot, amsmath, chapters/intro)
resolved
./path under the project, absolute for TEXMF
kind
tex, image, sty, cls, tfm … from the extension
site
the line that asked for it; null for the root

Limits

  • The site search is textual: a name a macro computes can match the same name typed nearby.
  • \openin probes are listed too (they are .fls inputs).

What it unlocks in the editor

  • ShippedRoot detection with no magic commentslsp/files.ts
  • ShippedCtrl-click paths built by macros or found via \graphicspathlsp/files.ts
  • FutureUnused-asset report (project images the run never read)the read set is complete
  • FutureJump into a loaded package's sourceresolved TEXMF paths are recorded

From the real sidecar: 60 files read

requestedresolvedkindsite
main.texmain.textex—
article…/article.clsclsmain.tex:1:16
localoptlocalopt.stystymain.tex:2:20
amsmath…/amsmath.stystymain.tex:3:13
graphicx…/graphicx.stystymain.tex:4:13
xcolor…/xcolor.stystymain.tex:5:13
glossaries…/glossaries.stystymain.tex:6:22

by kind: sty 29, tex 6, def 4, cfg 3, tfm 3, pfb 3, cnf 2, ldf 2, aux 2, map 2, fmt 1, cls 1, clo 1, mkii 1

In the editor (real lsp/ output on these records)

  • include closure: root main.tex, members chapters/intro.tex, main.tex
  • open chapters/intro.tex → rooted at main.tex

Colours colors[]

New in #2453End-of-run scanTAR-747TAR-784

xcolor stores each colour in a macro \color@<name>. At closeout the engine scans for them and reads back what xcolor stored, so HTML FF8800 arrives as rgb 1,0.53333,0 and a palette appears exactly when a package option loaded it.

What the engine records

name
colour name
model, value
what xcolor stored (rgb, cmyk, gray)
def
your \definecolor / \colorlet line, or the palette file
origin
body, xcolor, dvipsnam, svgnam …
alias_of, series
the \colorlet target; \definecolorseries method, step and reset

Limits

  • Only colours visible at the end of the run (not one defined in a group).
  • pdfTeX only; plain color.sty under another driver reports null.

What it unlocks in the editor

  • ShippedSwatches on \definecolor, \textcolor, mixes, tikz fill=lsp/colors.ts
  • ShippedColour-name completion incl. dvipsnames / svgnames paletteslsp/colors.ts
  • ShippedAlias chain and series step in the colour hover (accent → brand)lsp/colors.ts

From the real sidecar: 21 colours

namemodel / valueorigindef
brandrgb 1,0.53333,0bodymain.tex:7:1
accentrgb 1,0.53333,0bodymain.tex:8:1
redrgb 1,0,0xcolorxcolor.sty:1444:1
greenrgb 0,1,0xcolorxcolor.sty:1444:1
bluergb 0,0,1xcolorxcolor.sty:1444:1
brownrgb 0.75,0.5,0.25xcolorxcolor.sty:1444:1

Package and class options options[]

New in #2453Format hook + scanTAR-747TAR-785

\ProcessOptions erases what \DeclareOption made, so a scan cannot recover options. A kernel hook in the zitex format leaves one marker macro per \DeclareOption (and per top-level \ExecuteOptions default); the closeout scan turns the markers into records.

What the engine records

package, kind
what was loaded; package or class
option
the option; "*" is the \DeclareOption* handler
default
on unless overridden (\ExecuteOptions)
def
the \DeclareOption line
options_hook
false = format without the hook: unknown, not none

Limits

  • Needs the hooks format (all production formats have it; stock pdflatex.fmt does not).
  • \DeclareKeys options are l3keys and land in keys[], not here.

What it unlocks in the editor

  • Shipped\usepackage[…] / \documentclass[…] completionlsp/keyvals.ts
  • ShippedDefaults marked; the \DeclareOption* handler not offeredlsp/keyvals.ts
  • FutureUnknown-option diagnostic (silent for packages with a * handler)both facts are recorded

From the real sidecar: 24 options (options_hook: true)

packageoptionflagsdef
localopt (package)betadefaultlocalopt.sty:4:1
localopt (package)alpha—localopt.sty:3:1
localopt (package)*\DeclareOption* handlerlocalopt.sty:5:1
article (class)a4paper—article.cls:55:1
article (class)a5paper—article.cls:58:1
article (class)b5paper—article.cls:61:1

In the editor (real lsp/ output on these records)

  • \usepackage[|]{localopt} offers: beta, alpha
  • \documentclass[two|]{article} offers: twoside, twocolumn

Keys (key=value) keys[]

New in #2453End-of-run scanTAR-747TAR-786

A key is a macro with a known name pattern: KV@<family>@<key> for keyval, key code > <module>/<key> for l3keys, pgfk@<path>/.@cmd for pgfkeys. The closeout scan reads them back with defaults, types and choices; token stamps place each key where it is written.

What the engine records

system, family, key
keyval, xkeyval, l3keys or pgfkeys; Gin, mymod …
type, choices
bool, code, choice (with its values)
has_default, default
no default = the key needs a value
usage
load / preamble: only usable at load time
value_type, value_key, package
emitted, not read by the webapp yet

Limits

  • Keys defined inside a group, or built with \csname and never defined, are missed.
  • An xkeyval prefix family with no key that has a default stays invisible.

What it unlocks in the editor

  • ShippedKey completion for \includegraphics, \hypersetup, tikz, tcolorbox …lsp/keyvals.ts
  • ShippedChoice values after =, true/false for boolslsp/keyvals.ts
  • ShippedYour own \define@key / \keys_define:nn familieslsp/keyvals.ts
  • FutureValue checking (int / dim keys), unknown-key diagnosticvalue_type is emitted, not decoded

From the real sidecar: 103 keys

system / familykeytypevaluedef
keyval / myfamsize—requiredmain.tex:11:1
l3keys / mymodmodechoice: fast, slowrequiredmain.tex:16:5
l3keys / mymodlevelcodedefault 3main.tex:17:5
keyval / Ginwidth—requiredgraphicx.sty:65:1
keyval / Ginkeepaspectratio—default truegraphicx.sty:69:1

by family: glossaries.sty 69, Gin 31, myfam 1, mymod 2 · scan_stats: colors 21, options 491, keyval 148, xkeyval 7, l3keys 191, pgfkeys 0, glossary 1

In the editor (real lsp/ output on these records)

  • \includegraphics[|] offers: natheight, read, origin, bbllx, bblly, bburx, bbury, natwidth …

Glossary and acronyms glossary[]

New in #2453End-of-run scanTAR-787

Every glossaries definition ends in \gls@defglossaryentry, which stores each field in glo@<label>@<field>. The closeout scan reads them back; token stamps on the label say where the key was typed, also through your own macro.

What the engine records

key
the entry label
kind
acronym (has a long form) or entry
short, long, description
stored field values, null when empty
type, category
which glossary; glossaries-extra category
def
the line the key is typed on

Limits

  • Not the acronym package: \acrodef only exists from the next run, via the .aux (the editor's text scan covers it).
  • Listed whether or not it is used.

What it unlocks in the editor

  • ShippedCompletion in \gls{…}, \ac{…}, \acrfull{…} …lsp/glossary.ts
  • ShippedHover (API — application programming interface)lsp/glossary.ts
  • ShippedGo to definition of entries, incl. ones a macro madelsp/glossary.ts
  • FutureUnused-entry hintuses are not recorded yet

From the real sidecar: 1 glossary entries

keykindshortlongdef
apiacronymAPIapplication programming interfacemain.tex:21:13

Where the examples come from

The sample project

Three files, compiled twice by the shipped WASM engine with -dump-symbols. The sidecar is checked in at lib/zitex-intellisense/__fixtures__/real-records/main.symbols.json and imported by this page as is; realSidecar.unit.test.ts fails if the engine's contract moves.

main.tex
1\documentclass{article}
2\usepackage[alpha]{localopt}
3\usepackage{amsmath}
4\usepackage{graphicx}
5\usepackage{xcolor}
6\usepackage[acronym]{glossaries}
7\definecolor{brand}{HTML}{FF8800}
8\colorlet{accent}{brand}
9\newcommand{\myref}[1]{(see \ref{#1})}
10\makeatletter
11\define@key{myfam}{size}{\def\my@size{#1}}
12\makeatother
13\ExplSyntaxOn
14\keys_define:nn { mymod }
15  {
16    mode .choices:nn = { fast , slow } { } ,
17    level .int_set:N = \l_tmpa_int ,
18    level .default:n = 3
19  }
20\ExplSyntaxOff
21\newacronym{api}{API}{application programming interface}
22\begin{document}
23\section{Intro}\label{sec:intro}
24\begin{equation}\label{eq:a} x \end{equation}
25See \eqref{eq:a} and \myref{sec:intro}, via the \gls{api}.
26\input{chapters/intro}
27\end{document}
chapters/intro.tex
1\section{Chapter}\label{sec:chap}
2Back to \ref{sec:intro}.
localopt.sty
1\NeedsTeXFormat{LaTeX2e}
2\ProvidesPackage{localopt}
3\DeclareOption{alpha}{\def\localopt@a{1}}
4\DeclareOption{beta}{\def\localopt@b{1}}
5\DeclareOption*{\PackageWarning{localopt}{unknown \CurrentOption}}
6\ExecuteOptions{beta}
7\ProcessOptions\relax

Fields, sources and limits from zitex/docs/SYMBOLS_CONTRACT.md. “Shipped” means the named module under lib/zitex-intellisense/ uses the record in the editor today; “Future” is something the record already makes possible and nothing uses yet. Tickets: TAR-747, TAR-780.