...
- 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 In 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 open your source file in NetBeans, as described in the previous chapter, you should be able to see the various parts of the languages language (e.g. keywords) 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.
...
public class KotlinLSPServer implements LanguageServerProvider {
private static final Logger LOG = Logger.getLogger(KotlinLSPServer.class.getName());
@Override
public LanguageServerDescription startServer(Lookup lookup) {
File server = new File("kotlin-language-server/server/build/install/server/bin/kotlin-language-server");
try {
Process p = new ProcessBuilder(new String[] {server.getAbsolutePath()})
.directory(server.getParentFile().getParentFile())
.redirectError(ProcessBuilder.Redirect.INHERIT).start();
return LanguageServerDescription.create(p.getInputStream(), p.getOutputStream(), p);
...
You may want to create a new "Project Type" for your specific language. More explicitly, when you click on File → New Project, you can customize the New Project wizard dialog to create a new project for your language. For instance, "Rust" projects usually have a folder structure defined by the "cargo" tool. rust/rust.project.api
module allows the user to create a new cargo project.
The NetBeans Project Type Tutorial is a good starting point.
5. Configuring the language support
NetBeans IDE provides the Options window (menu Tools →
Options or NetBeans →
Preferences on MacOS) that allows the user to customize it. You can provide any customizations for your language support in the Options window, too. E.g. you could allow the user to provide the path to the Kotlin compiler. See e.g. rust/rust.cargo
module that allows the user to provide the path to cargo
for Rust projects.
The NetBeans Options Window Module Tutorial explains how you could do that.
6. Refactoring
...
7. Error Hints/Fixes/Suggestions
...
8. Debugging
---------
Other support you may need to provide:
...