Search code examples
xmlvisual-studio-codesyntax-highlightingbrightscript

Add Brightscript Highlighting in XML in VSCode


I will be working on a project soon that involves writing BrightScript and SceneGraph code. I know that there is a plugin for Eclipse, but it still doesn't do what I would like either. My question mostly revolves around adding syntax highlighting to XML files that contain other kinds of code. If you have never developed for Roku before, you can add a script tag (much like HTML and Javascript) inside of a XML file. That script contains BrightScript. Currently there is no syntax highlighting for that code inside the script tag. I was wondering if it was possible to add it to VSCode. As I understand VSCode is very extensible, but I have never worked with it before. Thanks!


Solution

  • As far as i remember, VSC already properly highlights both .BRS (BrightScript) and XML files. My suggestion is to keep code and markup separate, i.e. do not embed your code in XML but instead put in .brs file and include it in the XML with a tag

    <script type="text/brightscript" uri="pkg:/components/myComp.brs" />
    

    It's considered good practice and you'll get proper syntax highlights.