How to preview Syntax Highlighting Extension during development

How do I preview a language syntax. I am trying to create a syntax highlighter for the Imba language, but I have no success at seeing if my extension is working.
I have clicked “Activate Project as Extension” I used another extension as a starter template, and changed the detectors and name to match my language, and I have had no success.

What is the process for previewing the extensions?
Here’s my process.

  1. Extensions > Create New Extension
  2. Editd meta and detector in Syntaxes/imba.xml and extension.json
  3. I applied a basic comment syntax expression for testing.
<?xml version="1.0" encoding="UTF-8"?>
<syntax name="Imba">

        <extension priority="1.0">imba</extension>

                <expression>###</expression> <!-- imba -->
                <expression>###</expression> <!-- imba -->
  1. Activate Project as Extension

Should I expect syntax highlighting to be working for comments already, or what else do I need to do?

Highlighting needs highlighting scopes to be defined in the <scopes> element, which your extension (as posted above) doesn’t contain. The <comments> element you included doesn’t do that, it

defines the rules for commenting and uncommenting text within a document.

Otherwise, you assumption is correct: activate the extension and open a file of the correct type (or assign your syntax from the selector in the status bar to an already open one).

Thank you for your reply. I finally got the syntax highlighting to show up.
Is this xml based syntax grammar unique to Nova, or is this a standard used by others? To better phrase the question, is the nova documentation all there is to know about writing grammars compatible with nova?

XML based syntax definitions hark back to Textmate, I think, but the exact flavour is Nova’s own, so the documentation is the only reference I am aware of. You can also study other languages’ syntax definitions (Nova’s builtin ones, albeit technically compiled into the app, are also included as extension bundles inside the application), and this forum is good for questions about their less obvious parts. Beyond that, you are on your own.

Just to piggyback on what Martin was saying, I found the existing syntax highlighting extensions a lifesaver when trying to develop my own. Go into Finder, then /Applications, right-click, Show Package Contents and browse around in there and you’ll eventually find all the built-in syntax definitions. Don’t just copy 'em straight out and pass them off as your own of course, and I wouldn’t publish those anywhere publicly since that’s Panic’s own IP, but those really helped me wrap my head around how to set some things up, since the documentation isn’t all that clear to me in a lot of cases. They make for great examples to work off of.

EDIT: By the way, when you update your syntax definition file and CMD+S to save, if you have another file open in another window that has code for the language in question in there, it should update in real time according to what you’ve done there. Makes for a handy preview. I also found an invaluable resource for testing/hacking together regexes (definitely not my strong suit) and have found named capture groups to be absolutely awesome. Good luck!

1 Like

Thanks so much Jeff. looks like it will be incredibly helpful.
I am trying to convert a vscode plugin we have with most of the regexes we’ll need. Now I just need to figure out how to equate the tmLanguage file to Nova’s XML syntax.

Wow, thank you so much @kopischke and @thedude for the tip! Being able to see the bundled syntaxes was just what I needed to make sense of Panic’s documentation.