Hexicon for VS Code
Write, build, and play Hexicon games in Visual Studio Code.

Install Hexicon first. The extension uses the hexicon program, which it does not bring with it: get it from Hexicon's releases, with installers for Windows, macOS, and Linux. If the extension finds none, it says so, with Get Hexicon (see Where the program comes from).
Hexicon is a system for writing interactive fiction, parser games and choice games both, in its own language or in sentences of English, on its library, Hexad. This extension knows both ways of writing a game:
| Language |
File extensions |
What you get |
| Hexicon |
.hxn, .hxh |
Highlighting, including actions, verbs, and handlers (action Toll(dobj): TAction, verb Ring 'ring' singleDobj:, dobj Take { ... }), what is in a string (<<...>>, <<one of>>, <q>, <.reveal key>, {The subj dobj}), patterns (R'<digit>+'), and the preprocessor; snippets for Hexad |
| Hexicon's English |
.hxe |
Highlighting of sentences (rules, talk, hints, choices, and tests), kinds of thing, quoted text, and [comments]; a block of Hexicon after In Hexicon: is highlighted as Hexicon; snippets for each kind of sentence |
| The manifest |
hexicon.toml |
Checked as you type: a key the compiler does not know, a library given wrongly, or a game on Hexad that does not say its LANGUAGE is marked, with what each key is for on hover |
The manifest is checked through the schema this extension gives to TOML extensions that read schemas, such as Even Better TOML; install one to have it.
Snippets
Type a prefix and accept the suggestion. In a Hexicon source: story, room, thing, door, actor, topic, dobj, action, verb, moment, choice, achievement, goal, scenario, step, walkthrough, modify, import, and foreach, for, and if. In an English source: story, room, thing, door, character, rule, score, hint, moment, test, walkthrough, and hexicon, for a block of Hexicon.
Building and playing
With a Hexicon source or a game's hexicon.toml open, the buttons in the editor's title bar build the game and play it. The commands are also in the palette, under "Hexicon:", and in the Explorer's menu of a hexicon.toml, a .hxe, or a game file (.hxg).
| Command |
What it does |
| Hexicon: New Game... |
Asks for a folder, a name, and whether the game is played by typing commands or by choosing, starts it with hexicon new, and opens its first source |
| Hexicon: Build |
Saves what is unsaved and builds the game with hexicon build; its problems go to the Problems panel, each on its lines, and everything the build said to the "Hexicon" output |
| Hexicon: Build for Debugging |
The same, with -d |
| Hexicon: Play |
Builds the game, and plays it in a tab beside the source (below); given a game file, plays that |
| Hexicon: Play in Terminal |
Builds the game, and plays it in a terminal with hexicon run |
| Hexicon: Add Source to Game... |
Makes a source beside the manifest, and adds it to the manifest's sources: a .hxn, unless its name ends .hxe |
| Hexicon: Show the Hexicon This English Becomes |
Shows what hexicon english makes of an English source, read with the game's other English sources as a build reads them; it is made again each time a source is saved |
| Hexicon: Describe Game File |
What is in a game file, as hexicon dump says |
| Hexicon: Disassemble Game File |
The byte code of a game's functions, as hexicon disasm lists it |
| Hexicon: Show Program Location |
Which hexicon is used, and everywhere it was looked for |
The build gives each problem its lines but not its column, so a problem marks its lines from their first character that is not a space. A problem in a library built into hexicon, such as Hexad, is shown on the game's manifest, saying where it is.
The player
A game file (.hxg) opens in a tab that plays it, as Hexicon: Play opens it, beside the source. The tab is Hexicon's own web page, as a browser and Hexicon's player show a game: its pictures, sounds, styled text, panes, links, and choices, and its settings (colors, font, size, and more), which the tab remembers. Its colors follow VS Code's theme, light or dark, unless its settings say otherwise.
- It plays the game again from its start when the game is built again (
hexicon.player.reloadOnChange).
- Saved games are kept where Hexicon's player keeps them: in your documents, in the folder Hexicon, with a folder for each game. A game saved in VS Code can be restored in the player, and the other way about. Saving and restoring show VS Code's file dialogs, starting in that folder.
- Hexicon: Play Again from the Start, Hexicon: Replay Commands..., and Hexicon: Make a Scenario from This Session... are in the tab's title bar:
- Replay Commands plays the game from its start and enters the commands of a script: an event script, as
hexicon run --script reads (walk.txt in the guide's examples), or a file with a command on each line.
- Make a Scenario writes the commands played since the game started as a scenario for
hexicon test, a step for each, in the game's first test source; or in a new one, tests.hxn, which it adds to the manifest's tests, with Hexad's scenarios extension. Each step can then say what it must show (mentions = '...') or make true (expect = (...)).
The language server
The hexicon program is also a language server, hexicon lsp, which the extension starts. For the Hexicon and English sources open in the editor, it gives:
- Problems as the build gives them, as you type, in all of a game's sources, open or not, each where on its line it is; and again when the game's manifest changes. A problem in Hexad, or in the manifest, is shown on the game's manifest.
- The outline (the Outline view, breadcrumbs, and Go to Symbol in Editor): a source's classes, objects (nested as
+ places them), their properties, methods, and handlers, functions, verbs, macros, templates, and enumerations; and of an English source, the objects its sentences make. Go to Symbol in Workspace finds the same names in the game and its libraries.
- Go to Definition of a class, object, property, function, action, verb, or macro, in the game or in Hexad, and Find All References; Rename Symbol, for a name of the game's own.
- Hover, with a name's declaration, its comment, and what it is built on; and completion, of the names the game and its libraries define, and of an object's members after a
..
- Hexad's own files, which are built into
hexicon, opened read-only where a definition, a reference, or a problem is in them (hexicon:/hexad/thing.hxn).
A build shows a problem only if the server does not (as hexicon build): what only a build does, such as preinitialization, and the problems of a game none of whose sources is open, which the server has not read. hexicon.languageServer.enabled turns it off, when a build shows them all; Hexicon: Restart Language Server starts it again, as changing hexicon.path does. What it does is in the "Hexicon Language Server" output, and hexicon.trace.server shows the messages between it and VS Code.
The map
Hexicon: Show Map (the map in the title bar of a Hexicon or English source, and on a manifest in the Explorer) draws the game's world beside its source: its rooms, by their titles, and the ways between them, from the language server, so it is the game as the editor has it, and is drawn again as you type.
- Laid out by the compass, as a hand-drawn map is, from the room the player starts in, which has the heavier border: north above, east to the right. A room where its exits say another already is goes to the nearest place its line can reach without crossing a room, and a line that would still cross one bends around it.
- Floors apart: the rooms the compass joins are laid out together, and a set of them reached only by up or down, in or out (a basement, a ship's hold) is laid out beside the rest, with a mark at each end ("down to Corridor") that goes to the room it names. A single room up or down from another, such as a lamp room up a stair, is put beside it with a labeled line.
- What each line is: a way both rooms give is a line, a way one room gives an arrow, and a way through a door has a bar across it. A way that is refused is a short line ending in ×, and one the game decides as it runs, a short line ending in ?; hovering over any of them says what it is.
- A click on a room opens its source where it is written, and on a line, where its exit is; the room the cursor is in is marked as you move through the source. Drag to move the map, use the wheel to zoom, and Fit to see it all.
The reference
Hexicon: Open Reference (the book in the title bar of a Hexicon source) shows the game's reference, as hexicon doc writes it, in a panel beside the source: every class and object the game and its libraries define, with what each is built on, its properties, methods, and handlers, and the comments above them; its files, functions, actions, messages, macros, and a search. Links stay in the panel, with Back and Forward in its title bar, Alt+Left and Alt+Right, and the mouse's back and forward buttons; a link to a line of a source opens the source there, the game's own or one of Hexad's. Hexicon: Open Hexad's Reference shows Hexad's, with its extensions and the system library.
A reference is written when it is first opened, and again when the game has changed since (a few seconds), into the extension's storage rather than the game's folder: a game's is some 45 MB, mostly its libraries', which would otherwise be committed and synced with the game. The five games' references most recently opened are kept. Hexad's is written once for each build of hexicon. To have a game's reference in its folder, run hexicon doc there.
Tests
A game's scenarios and walkthroughs are in VS Code's Testing view, each game with any an item, and each of them in it, at the line that declares it, in Hexicon or in English. Running a game plays all of them, walkthroughs too, with hexicon test; running one plays it alone. A failure is shown on the check that failed, or its step, with what the game said; a scenario that starts after one that failed is skipped. A game that does not build shows why in the Problems panel. Running a whole game also marks the choices no scenario played, on their declarations.
Make a Scenario from This Session..., in the player, writes a session as a scenario, which then appears here.
Where the program comes from
The extension does not bring the hexicon program with it; it finds it. It looks, in order, at the hexicon.path setting; at the build of a Hexicon repository the workspace is in (target/release), for those working on Hexicon itself; at the PATH, where the installers put it; and where the installers put it, if the PATH does not have it yet, and where cargo install puts it.
If it finds none, it says so, with Get Hexicon, which opens the page of Hexicon's latest release, where its installers for Windows, macOS, and Linux are; Choose the Program..., to say where one is; and Open Settings.
It needs a hexicon of its own version or later, as a release of Hexicon and of the extension are built together. It asks the one it finds (hexicon --version) when the language server starts and when it builds, and if that one is older, or too old to say, it says so once, with Get Hexicon, and carries on with it. Hexicon: Show Program Location says which version it found.
What is coming
Whatever the plan's "Later" earns: editing the world from the map, a map for players drawn as they explore, and a debugger, once Hexicon's virtual machine has one. The plan is in docs/vscode-plan.md.
Working on the extension
The extension is in editors/vscode of the Hexicon repository, with Node 22 or later. The player is Hexicon's web page, which npm test and npm run package copy in from web/, so build that first, with tools/build-web.sh (see its top for what it needs):
npm install
npm test # builds it, and runs its tests in a copy of VS Code
npm run package # makes hexicon-<version>.vsix
F5 in VS Code, with this folder open, starts a window with the extension, opened on the guide's examples.
The tests check the grammars over every source in the repository (Hexad, the system library, the guide's examples, and the tutorial's steps), that nothing is left open at the end of any, and the scopes of each form; the schema against every manifest in the repository, and against manifests it must refuse; that VS Code gives each kind of source its language; how the build's messages and a manifest are read; and, with the hexicon this repository builds (cargo build --release), each command, on copies of the guide's games, the player among them: a game played, saved, and restored, a scenario made from a session and played by hexicon test, a walkthrough replayed, and a game of choices alone; the Testing view, on copies of The Gorge and The Harbor, with a failure and a game that does not build; and the language server, on a copy of The Lighthouse: its problems, cleared when mended, its outline, a file of Hexad's opened, and each problem shown once when a build shows it too, in a source open or not; the map, laid out from worlds made for it (floors, rooms that would land where others are, rooms no exit reaches), and drawn from the server on copies of The Lighthouse and The Harbor: its rooms and doors, drawn again as the source is edited, the room the cursor is in, and a room's source opened; and the reference, on a copy of The Lighthouse: written outside the game's folder, its links, Back and Forward, the search, a game's source and one of Hexad's opened at a line, written again only for a change; and Hexad's, written once.
| |