editor: Add Typst command completion in math regions - #604
Merged
Conversation
The sibling of the LaTeX source for notes whose typesetter is Typst: bare-word commands (sum, alpha, frac) complete from two letters on inside the same math regions, gated on mathRendererOf so each source stays out of the other typesetter's notes. Argument-taking functions insert as snippets with Typst syntax (frac(a, b), sum_(i=1)^(n), mat(1, 2; 3, 4)); the icon slot shows the exact Unicode glyph (α, ∑, ∫, ℝ) — no typesetting needed for previews yet. Starter table (~90 words): greek, core constructs, accents, set/logic symbols, named functions.
Templated options now typeset their preview through the shared Typst
render queue: the Unicode glyph paints immediately, the compiled SVG
swaps in when ready, and the svg cache makes every later popup
instant. The preview source is the snippet template with its fields
unwrapped (frac(${a}, ${b}) previews as frac(a, b)), so preview and
insertion cannot drift apart. Glyph-only entries (greek, symbols)
keep their exact Unicode form — no compile needed.
… (slice 3) Extends the table with the remaining everyday families: arrows with their ASCII shorthands noted in the detail (arrow.r / ->), comparisons (lt.eq, gt.eq, eq.not), sets (inter, nothing, subset.eq, in.not), circled operators under their canonical post-0.13 names (plus.o, times.o — the .circle spellings are deprecated in the bundled compiler), the dif differential, and text styles (bold, upright, cal, bb) as snippets with compiled previews. Every name compile-checked against typst 0.15.
adibhanna
approved these changes
Aug 16, 2026
adibhanna
left a comment
Contributor
There was a problem hiding this comment.
Reviewed against v2.29.0. The completion source is renderer-gated, math-context-scoped, and covered by focused tests. Verified the integrated tree with app-core typechecking, all 1,648 app-core tests, direct compilation of all 25 snippet previews and 120 completion labels using the bundled Typst compiler, and the fresh four-platform CI matrix. No blocking findings.
Contributor
|
Reviewed against Verification completed:
No blocking findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Following up on #594 and the feedback from the 2.28.2 merge, this PR brings the same math auto-completion experience to Typst syntax.
Because Typst writes math differently than LaTeX (parentheses instead of backslashes and braces), I built a dedicated completion source for it. The two sources are mutually exclusive: they check
mathRendererOf, so you'll only get suggestions relevant to the active math renderer.Completion fires after two letters to avoid popping up on single-letter math variables (though manual trigger still works for a single letter). For math-region detection, I reused
isInMathContextthis time.The completion table covers: snippets (frac, sum, integral, lim, mat, cases...), accents, text styles (bold, upright, cal, bb), Greek letters, comparisons, sets, and the usual operators. It also includes arrows with their ASCII shorthands (e.g.,
arrow.r/->).Note:
plus.circleandtimes.circleare deprecated, so the table uses the canonicalplus.oandtimes.oinstead.Following the LaTeX review, previews simply use exact Unicode characters (like α, ∑, ℝ) instead of a full render whenever possible to keep things lightweight. Snippets with arguments still use the existing shared, cached render queue.
Tests cover:
arrow.l.r.double).