Skip to content

Anduh/rmacro

Repository files navigation

Roll20 Macros - rmacro

VSMarket: rmacro installs Last Commit Contributions

Twitter: @anduh_ Patreon Donate

Support & Syntax Highlight for Roll20's macro language.

Features

Bracket pairing

Automatic bracket pairing for roll20 syntax

  • roll20 macros (@{ }, ?{ }, %{ }, &{ }, $[[ ]])
  • correctly distinguished [[ ]]/{{ }} from [ [ ] ]/{ { } }
  • identifies 1st and 2nd order query nesting & HTML replacement characters

Syntax highlights

  • inline roll labels
  • roll, macro & API commands (e.g. /r, !example #dex)
  • normal and fate (dF) die
  • some keywords (selected, target, %%NEWLINE%%, max, cf, ceil, tracker)
  • special characters used in macros (e.g. ~,|#=+, and [HTML Entities](HTML replacement characters)
  • rmacro highlight in other languages:
    • js/pug (everything inside roll` ` will highlight)
    • markdown (fenced codeblocks, with rmacro set as language)

Snippets

  • as you type, some matching suggestions will be provided
  • also includes couple of more advanced examples

Example

Macro nesting bracket highlight

Missing bracket stands out

Rmacro syntax highlight in javascript:

Rmacro syntax highlight in markdown files:

Use

VScode shows/recognizes "rmacro"-syntax highlight when:

  • a file has the filetype .roll (.rmacro/.roll20/.r20macro also works)
  • inside fenced codeblocks of markdown files, with rmacro set as the language.
  • inside .js and .pug-files, when the macro is inside a tagged template literal with rmacro as the tag

The autocompletions work only in .roll/.rmacro/.roll20/.r20macro-files

This extension also works on vscode.dev

You can download example.roll and the rest of the sample files) to get started.

Issues

Sometimes extra spaces are needed to keep the bracket highlight working correctly.

When nesting double- & single-bracket syntax, leave a space after the last inner character.

Good:

{{name=@{character_name} }}

Bad:

{{name=@{character_name}}}

Settings

Sets following default setting for .rmacro-files:

  • "editor.bracketPairColorization.enabled": true - If this is overruled by user settings, all bracket highlights will disappear, not just the extra coloring.
  • "editor.wordWrap": "on" - wraps lines by default. roll20 macros are often on a single line, and this improves readability.

Installs an extended version of file-icons Theme, which changes the the fileicon for .rmacro-files & some roll20 Sheet/API development-related filenames.

Contribute

repo: Anduh/rmacro

You can help even without knowing how VS Code extensions work. Here are a few concrete parts to start from:

Related Extensions

Roll20 Sheet Dev helps with Character Sheet Development.