...
- Download the TextMate json file for your language. A list of Textmate syntaxes is provided here and here but in other places, too. Let's call it
my-grammar.json
for the purposes of this example. E.g. for Kotlin this should beKotlin.tmLanguage.json
and for Rustrust.tmLanguage.json
. Right-click on Libraries folder of your module project and select Add Module Dependency. Enter "TextMate Lexer" inside Filter and add the module found in the Module list as a dependency to your module.
Into the DataObject that you created in the previous chapter, add this annotation:
@GrammarRegistration(grammar="my-grammar.json", mimeType="text/sh")
and import it:
import org.netbeans.modules.textmate.lexer.api.GrammarRegistration;
If you now open your source file in NetBeans again, as described in the previous chapter, you should be able to see the various parts of the languages to be coloured as defined in the TextMate grammar file. Braces matching is also there. Take a look at java/kotlin.editor/src/org/netbeans/modules/kotlin/editor/KtDataObject.java
as an example.
...