Skip to content

Editor integration

The language entry point provides what an editor needs, without assuming which editor.

import { LanguageService } from "solve-engine/language";

The service produces completion candidates for the current input, including function names, unit names, and package-contributed keywords.

Every token carries a category such as number, unit, function or operator. Map those categories to your own theme rather than hardcoding colours, so that a package adding new syntax is highlighted without further work.

The route from a line of text to a coloured line is four short steps, and the engine only owns the middle two.

  1. 12 km in miles

One string. No structure yet.

Your editor knows where the caret is and what the line says. It knows nothing about what any of it means, and it should not have to.

Editor integration

For deciding whether to decorate a line at all, there is a non-throwing check that avoids constructing an error object for the common case of prose that is not an expression. On a document that is mostly prose, that difference is substantial.