Repository navigation
feat: register NLP++ math functions in the editor (3.11.12) - #1112
Merged
ddehilster merged 1 commit intoJul 26, 2026
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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,powandlog— in three places:syntaxes/nlp.tmLanguage.json— the builtin-function rule, so they colorizesrc/language/nlpxxData.ts—BUILTIN_FUNCTIONS, feeding hover, completion and diagnosticssnippets/nlp.json— snippet entries with argument placeholdersAlso registers
abs,modandrandomint. The engine has had these for a while, but they were never added to the grammar ornlpxxData— 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
logsits beforelogtenin the alternation. That's safe: the rule anchors with a trailing\b, so matchingloginsidelogtenfails 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-checksnlpxxDataagainst the grammar, which is what keeps these two lists from drifting apart.distrebuilt withwebpack-prodper 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