Skip to content

Repository files navigation

Sphere Scripter

Language support for Sphere script files (.scp) in Visual Studio Code: highlighting, formatting, and static checks for the mistakes the engine accepts without a word.

What it does

Syntax highlighting for 52 section kinds, 258 triggers, and the property and function catalogs of every scriptable class.

Formatting. Block indentation, keyword casing, and blank-line separation between sections and trigger handlers. Book pages, [COMMENT] prose, [NAMES] tables and [DIALOG … TEXT] gump strings are emitted verbatim — what a player reads is never rewritten. Format a selection with range formatting, or the whole file.

Static checks. Five rules, each for a failure that loads clean and then quietly does the wrong thing:

Check What it catches
cmpsub A > inside a <...> read closes it. <EVAL (5 > 3)> answers 5 and the rest of the line stops being script, so the gate is always open.
hex0x A C-style 0x literal reads as 0; Sphere writes hex with a leading zero.
flow An IF/FOR/WHILE/BEGIN that is never closed.
locals A LOCAL read but never set. It reads back as "0" and nothing is logged, so a mistyped name silently disables whatever it guards.
itemev An item-only trigger in an [EVENTS] block — indexed against the character trigger table, so it attaches and never fires. It has to be a [TYPEDEF].

Editor support. Completion for triggers, sections and the names your pack defines; hover on a trigger for what SRC is, which ARGN/ARGO it carries and what RETURN 1 does; go to definition for any DEFNAME across the workspace; an outline and folding for sections and their handlers; and 70 snippets.

Settings

Setting Default
sphereScripter.format.triggerCase canonical How ON=@... is cased: canonical (@DClick), upper (@DCLICK) or preserve.
sphereScripter.diagnostics.enabled true Turn the static checks off entirely.
sphereScripter.diagnostics.disabledChecks [] Silence individual checks by id.

The first format of an existing pack rewrites nearly every ON=@ line to the catalog's spelling. Set triggerCase to preserve or upper first if you would rather it left them alone.

Contributing

The keyword catalogs live in formatter/constants.js and nowhere else. The grammar's trigger, section and flow patterns and the language configuration's indentation rules are generated from them:

npm run sync:language   # regenerate
npm run lint            # eslint, plus a check that the generated files are current
npm run test:unit       # the rules, over a vscode stub — runs anywhere
npm test                # the integration suite; needs a real VS Code and a display

Editing the grammar's generated patterns by hand is how the two copies drifted to 158 and 235 triggers, and how [DEFNAME] went uncoloured for years.

Thanks

This extension is based on: https://github.com/ruben-feito/spherescript-syntax-highlight-formatter

About

Syntax Highlight Formatter extension for Sphere script files (.scp) for improve the coding experience in Visual Studio Code.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages