Rockstar for Visual Studio Code
Syntax highlighting for Rockstar, the programming language for writing programs that are also power ballads.
Rockstar can't be highlighted properly with regular expressions: with can be addition or part of a function call, says starts a poetic string, and every word after like is a poetic digit. So this extension parses your code with the same grammar as the CodeMirror editor on codewithrockstar.com (codemirror-lang-rockstar, a Lezer port of the Rockstar 2 PEG grammar), and reports the results as VS Code semantic tokens. Comments, strings and numbers are also covered by a small TextMate grammar. That grammar colours them instantly, and it's used in places that don't run extensions.
What gets highlighted
| Rockstar |
Token |
variables (my heart, Tommy, Johnny B Goode) |
variable |
pronouns (it, she, them...) |
variable.defaultLibrary |
| function names, and the function being defined |
function, function.declaration |
| function parameters |
parameter.declaration |
| numbers and strings |
number, string |
| poetic numbers and poetic strings |
number.poetic, string.poetic |
true, false, null, mysterious, empty |
constant |
( ), #, { } and [ ] comments |
comment |
plus, times, is higher than, and, not... |
operator |
if, while, else, return, yeah, baby... |
keyword.controlFlow |
everything else (put, into, let, say...) |
keyword |
Run Developer: Inspect Editor Tokens and Scopes to see what any token is.
Development
npm install
npm test # rebuilds the Lezer grammar, bundles, runs the tests
npm run package # builds rockstar-x.y.z.vsix
To try it out, press F5 in VS Code with this folder open. The examples folder from the website opens in an Extension Development Host.
The grammar lives in ../codemirror-lang-rockstar/src/grammars. Change it there and both the website editor and this extension pick it up. The build regenerates the parser from rockstar.grammar, so ../codemirror-lang-rockstar needs its own npm install first.
| |