Skip to content

feat: register NLP++ math functions in the editor (3.11.12) - #1112

Merged
ddehilster merged 1 commit into
VisualText:masterfrom
ddehilster:feat/nlpxx-math-functions
Jul 26, 2026
Merged

ddehilster merged 1 commit into
VisualText:masterfrom
ddehilster:feat/nlpxx-math-functions

Conversation

@ddehilster

Copy link
Copy Markdown
Member

Editor-side companion to VisualText/nlp-engine#699, which adds a set of math functions to NLP++.

What this does

Registers the new engine builtins — floor, ceiling, round, truncate, sqrt, pow and log — in three places:

  • syntaxes/nlp.tmLanguage.json — the builtin-function rule, so they colorize
  • src/language/nlpxxData.ts — BUILTIN_FUNCTIONS, feeding hover, completion and diagnostics
  • snippets/nlp.json — snippet entries with argument placeholders

Also registers abs, mod and randomint. The engine has had these for a while, but they were never added to the grammar or nlpxxData — they had snippets, yet showed up unhighlighted and unknown to completion. All ten are inserted alphabetically into the existing lists.

One thing worth a look

log sits before logten in the alternation. That's safe: the rule anchors with a trailing \b, so matching log inside logten fails the boundary check and the engine backtracks to the longer alternative. Called out only because alternation order is an easy thing to trip on.

Testing

npm run test:language — 61 passed, 0 failed. That suite cross-checks nlpxxData against the grammar, which is what keeps these two lists from drifting apart.

dist rebuilt with webpack-prod per convention.

Note

These functions need VisualText/nlp-engine#699 to actually run. Highlighting and completion work regardless, so the two can merge in either order.

🤖 Generated with Claude Code

Adds the new engine math builtins -- floor, ceiling, round, truncate, sqrt,
pow and log -- to the TextMate grammar, the language data used by hover,
completion and diagnostics, and the snippet set.

Also registers abs, mod and randomint. The engine has had those for a while,
but they were never added to the grammar or nlpxxData, so they showed up
unhighlighted and unknown to completion even though snippets existed for
them. All ten now go in the builtin-function rule, inserted alphabetically.

Note that log sits before logten in the alternation. That is safe: the rule
anchors with a trailing \b, so matching "log" inside "logten" fails the
boundary check and the engine backtracks to the longer alternative.

61 language tests pass. The language suite cross-checks nlpxxData against
the grammar, which is what keeps these two lists honest.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant