VS Code extension
The official Gram VS Code extension turns your editor into a dedicated recipe development environment. Powered by @gram-lang/language-server, it provides real-time diagnostics, advanced editing assistance, and dynamic live rendering.
Core capabilities
Section titled “Core capabilities”1. Dynamic live preview & nutrition
Section titled “1. Dynamic live preview & nutrition”- Side-by-side rendering: As you type, the extension compiles your
.gramfile into HTML within a dedicated WebView panel. It uses the official Playground styles, ensuring a 1:1 match with production output. You can open it from the▶ PreviewCodeLens at the top of the file, the editor toolbar icon, orGram: Live Preview. - Always-on nutrition summary: The live preview displays the recipe’s nutritional summary automatically (matching the Playground), with an energy badge in the header linking to the nutrition table at the bottom (calories, protein, carbohydrates, fat, etc.), database coverage, and notices for ingredients missing nutritional data. Running
Gram: Macrosfrom the Command Palette opens the preview and scrolls straight to this table. - Paused on errors: When compilation errors prevent view updates, active panels retain their last valid rendered content (dimmed under a subtle banner) rather than being wiped. A Show the error action immediately navigates to the error location in the editor, while comprehensive diagnostics appear in the Problems panel. Views automatically resume as soon as errors are resolved, preventing transient typos from blanking panels.
2. All views and inspectors
Section titled “2. All views and inspectors”Gram: Show View...: Displays a quick-pick menu of all available outputs provided by the language server and opens the selected view in a dedicated panel: recipe presentation, operational run sheet, and developer inspectors (composed AST and compiled JSON, formatted as source text or an interactive collapsible tree). Inspectors update live as you type, offering immediate visibility into how the compiler understands your recipe.- Active editor synchronization: All open panels automatically track the active
.grameditor tab. The language server evaluates only views that are currently visible, eliminating background compute overhead. - Direct shortcuts: Dedicated commands
Gram: Live Preview,Gram: Run Sheet, andGram: Macrosquickly open the recipe view, the operational run sheet, and the recipe anchored directly to its nutrition summary. - Scale and stock: The Scale and stock section at the top of the recipe and run sheet panels adjusts this sitting, as the CLI’s
--scale,--stockand--bakers-referencedo: a scale in percent (200for twice the recipe), a number of portions when the recipe states them (the scale follows), or a target quantity of one ingredient (the rest follows); the baker’s reference whengram.bakersMathis on; and the@useimports already made, whose steps then leave the plan. Its summary says what is active, and a scale that cannot be applied (an ingredient the recipe does not have, a unit that does not convert) is said there, the recipe staying at its written size. Like the serving time, these choices are shared by every panel of the recipe, kept while VS Code is open, and never saved; diagnostics, hover and inlay hints stay on the recipe as written.
3. Run sheet view
Section titled “3. Run sheet view”- Dedicated run sheet panel: Run
Gram: Run Sheet(or click the checklist icon in the editor toolbar) to display the full schedule in a dedicated WebView independent of the live preview. It details daily kitchen presence, items to take out, tasks to perform, and background passive rests. - Relative countdown (
D-2,D-1,Day D): Without a serving time, the schedule is presented as a relative countdown with estimated durations per day (e.g. “about 55 min”). - Serving time: The Served at field at the top of the panel puts the plan on the calendar, with dates, clock times and margins, in your project’s time zone and within its availability (
timezoneandavailabilityin.gram/config.yaml). When to serve? proposes the times that work over the next seven days at your meal times (mealTimes), the earliest one first, and tells why the others do not; click one to use it. Clear goes back to the countdown. The serving time is kept per recipe while VS Code is open, and forgotten when you close the file or the window, so a plan is never laid out on a time already past. - Setting synchronization: The view adapts dynamically to the
gram.miseEnPlace,gram.restsandgram.commentsconfiguration settings (detailed below). - Gantt chart replacement: The legacy
Gram: Gantt Chartcommand is deprecated since version 1.4.0 (it redirects to the run sheet with a one-time notice) and will be removed in version 2.0.0.
The gram.miseEnPlace setting
Section titled “The gram.miseEnPlace setting”| Value | Effect |
|---|---|
perSection (default) | Each section’s mise en place is scheduled immediately before that section. |
upfront | All mise en place tasks are scheduled at the start of the recipe. |
perDay | The mise en place of each working day is scheduled at the start of that day (days derive from section day anchors, ~{-Nd}). |
The setting drives the live preview, the run sheet, and the total time hint displayed next to the recipe title. It adjusts computed total and idle times without altering ingredient lists, and applies immediately to all open documents without reloading the window. See When the mise en place happens.
The gram.rests setting
Section titled “The gram.rests setting”| Value | Effect |
|---|---|
shortest (default) | A range-based passive timer (~_{12-24h}) is resolved to its minimum duration. |
balanced | The passive timer is resolved to the midpoint of its range. |
longest | The passive timer is resolved to its maximum duration. |
Fixed passive timers and active timers with ranges (~{20-25min}, always planned using their upper bound) are unaffected. Like gram.miseEnPlace, this setting drives the live preview, the run sheet, and the total time hint, applying immediately to all open files. See Exact times and ranges.
The gram.comments setting
Section titled “The gram.comments setting”| Value | Effect |
|---|---|
show (default) | Recipe comments (// like this) appear in the preview and in the run sheet. In the run sheet, they are styled discreetly in small, muted text. |
hide | Both standalone notes on their own line and end-of-line comments are omitted from both views. |
This setting applies immediately to all open files (any unrecognized value defaults to show). The equivalent option is available in the CLI (--comments), the renderer API (comments), and the Playground (Display section).
Additional preview settings
Section titled “Additional preview settings”| Setting | Values | Effect |
|---|---|---|
gram.stepQuantities | show (default), hide | Controls whether ingredient quantities appear directly within step instructions, after each ingredient name, alongside standardized mass in grams: flour (250 ml, ~148 g). Section ingredient lists always display them. |
gram.clock v1.5.0 | auto (default), 12h, 24h | How the run sheet and the serving time suggestions write the time of day: 1:00 PM or 13:00. auto uses the clock setting of the project’s .gram/config.yaml when it sets one, else the region of your system’s locale. |
gram.nutritionBasis | auto (default), total, perPortion, per100g | Calculation basis for the nutrition panel. In auto mode, the preview shows every basis side by side (per 100 g, per portion); any other value narrows the table to that basis. |
gram.bakersMathOnly | false (default), true | Displays only baker’s percentages, omitting absolute weights. |
Analyzer settings control which calculations are derived from the ingredient database. All are enabled by default, matching the core compiler engine. Modifying any of these settings immediately re-analyzes every open recipe and refreshes its diagnostics.
| Setting | Effect when enabled |
|---|---|
gram.bakersMath | Computes baker’s percentages based on the ingredient marked with *. |
gram.massStandardization | Standardizes ingredient quantities into grams using database densities. |
gram.yieldCalculation | Accounts for preparation waste (peels, pits, trim), distinguishing gross purchasing weight from net culinary weight. |
gram.nutritionEstimation | Computes nutritional estimates displayed in the recipe preview. |
All of these settings are available with identical values in the CLI and in the Playground. Any unrecognized value falls back to its default.
A working day pushed beyond 24 hours by a prolonged passive phase triggers an explicit warning on its section (DAY_OVERFLOW), matching compiler diagnostics.
4. Smart ingredient management
Section titled “4. Smart ingredient management”- Silent plural management: The extension automatically maps common plural nouns in your recipe (e.g.
@carrots) to singular entries in your YAML database (carrot), maintaining natural language without raising false errors. - Fuzzy matching: If you misspell an ingredient, a Levenshtein distance algorithm suggests the closest known match via Code Actions (Quick Fixes).
- Hover insights: Hover over any ingredient to inspect its nutritional profile and automatic volume-to-mass conversions (
1 tbsp → 15g). Hover over a timer to see the parsed duration (~{1:30 h}→1 h 30 min), over a section anchor to see its lead time, or over a sum/ratio to inspect its resolved value.
5. Editing assistance & navigation
Section titled “5. Editing assistance & navigation”- Semantic tokens: Highlighting is driven directly by the compiler AST rather than regular expressions. Modifiers, nested units, ratio operators, and composite ingredients (
<@) are colored accurately according to their syntactic role. - Inlay hints: Displays total recipe duration at the end of the
title:line (updating dynamically withgram.miseEnPlaceandgram.rests) and resolved values inline after unit ratios and proportional times (= 5,= 24 min). - Intelligent autocomplete:
@suggests ingredients declared in your database, automatically enclosing multi-word names in{}brackets.&suggests available intermediate declarations (e.g.->&dough).{}contextually suggests canonical units (mass, volume) and their aliases as soon as a digit is typed; inside a timer (~{}), only time units are offered.
Navigation shortcuts
Section titled “Navigation shortcuts”| Shortcut | Command | Behavior |
|---|---|---|
F12 | Go to Definition | Jumps from a reference (&ref) to its original declaration (->&ref). |
Shift+F12 | Find All References | Locates every usage of a specific intermediate variable across the document. |
F2 | Rename Symbol | Safely and atomically renames an intermediate variable across the entire document. |
6. Diagnostics & refactoring
Section titled “6. Diagnostics & refactoring”- Real-time validation: The language server immediately flags orphaned references, unused declarations, and scheduling conflicts.
- Code Actions 💡:
- Add missing
title:frontmatter property. - Remove unused intermediate declarations.
- Declare a missing intermediate for an orphaned reference.
- Convert volume measurements to mass directly in code (if density is known).
- Add missing
7. Auto-formatting
Section titled “7. Auto-formatting”Trigger document formatting (Alt+Shift+F or Shift+Option+F on macOS) to instantly normalize syntax using the 13 canonical rules:
Editor UI enhancements
Section titled “Editor UI enhancements”- Outline view: The native VS Code Outline panel populates with a clean hierarchy of sections and intermediate variables, making large recipes easy to navigate.
- Gutter folding: Frontmatter blocks and section bodies can be folded to maximize screen space.
- Rich snippets: Use trigger prefixes like
recipe,##,step,@ing, or#cwto rapidly scaffold complete recipe structures.