The extension registers the brightscript language ID for .brs files and provides a TextMate grammar (syntaxes/brightscript.tmLanguage.json) with scopes for:
- Keywords:
sub,function,if,else,for,while,return,end,try,catch, etc. - Storage types:
Boolean,Integer,Float,Double,String,Object,Dynamic,Void - Type annotations:
as <type>patterns — the type name receivesstorage.typescope even when it overlaps with a keyword (e.g.as FunctionhighlightsFunctionas a type, not a keyword) - Boolean/null literals:
true,false,invalid - Built-in functions:
CreateObject,Abs,Len,ParseJson, etc. - Strings: double-quoted with
""escape sequence support - Numbers: integer, float, hex (
0x...), type-suffixed (!,#,%,&) - Operators: arithmetic, comparison, logical, string concatenation (
&) - Function declarations: function/sub name receives
entity.name.functionscope - Function calls: any identifier followed by
(receivessupport.functionscope, matching built-in function colouring mvariable: the BrightScript component scope variablemreceivesstorage.typescope, matching type keyword colouring- Kopytko
@importannotations: specially highlighted (see Kopytko Imports) - Kopytko
@mockannotations: same structure as@importbut with a distinctkeyword.control.mockscope for@mockandfromkeywords; path and package name share the same scopes as@import
Configured in language-configuration.json:
- Line comments: apostrophe (
') andREM - Auto-closing pairs:
(),[],{},"" - Indent rules: increase after
sub,function,if,for,while,try; decrease onend sub,end function,end if, etc. - Word pattern:
[a-zA-Z_][a-zA-Z0-9_]*
Available snippets (prefix → expansion):
| Prefix | Description |
|---|---|
sub |
Subroutine block |
fn |
Function with return type |
if |
If block |
ife |
If-else block |
foreach |
For-each loop |
for |
For loop |
while |
While loop |
try |
Try-catch block |
import |
Kopytko internal @import |
importfrom |
Kopytko external @import ... from |
kopytko-init |
Kopytko component init boilerplate |
aa |
AssociativeArray literal |
print |
Print statement |
Available in test files (*.test.brs):
| Prefix | Description |
|---|---|
testsuite |
Kopytko test suite scaffold |
testsuitefw |
Framework test suite scaffold (extends KopytkoFrameworkTestSuite) |
it |
Single test case with it() |
test |
Single test case with test() |
iteach |
Parameterized test case with itEach() |
beforeeach |
beforeEach setup block |
aftereach |
afterEach teardown block |
mockfn |
mockFunction() call with return value |
expect |
expect() assertion with matcher |
expectmock |
expect() assertion with mock matcher |
mock |
@mock annotation |
The official BrightScript language reference is at: https://developer.roku.com/docs/references/brightscript/language/brightscript-language-reference.md
- Loosely typed by default; optional
as <Type>annotations - Functions as first-class values
mreference to the component's associative array (equivalent tothis)invalidas the null value- Array and AssociativeArray literals (
[],{}) - Exception handling via
try/catch/throw/end try for each ... initeration over arrays and associative arrays- String concatenation with
+or&