Thanks to the command-line compiler, it is possible to use an integrated development environment (IDE) for writing and compiling Mindcode. This document has some tips on setting up the shop.
The command line tool allows you to compile your files, including the option to copy the compiled code into the clipboard automatically or even to send it to Mindustry through the Mlog Watcher mod. The command line compiler can be set up in the following way:
- Download and install Eclipse Temurin version 22.
- Download
mindcode.jarfrom the Releases page and place it in a directory on your computer. - To run the command line compiler, use
java.exe -jar mindcode.jar <arguments>. Provide full paths to thejava.exefile from the Eclipse Temurin installation created in the first step, and to themindcode.jarfile downloaded in the second step.<arguments>are the command line arguments passed to the Mindcode compiler.
For example, the following command compiles program.mnd into program.mlog, copies the resulting mlog code into the clipboard and attempts to send it directly to Mindustry (the Mlog Watcher mod must be installed for that):
java -jar mindcode.jar cm program.mnd program.mlog -c -w
For easier integration with IDEs, create a script file/batch file containing this command, using full paths to both java.exe and mindcode.jar, and put this file onto the executable path.
When reporting an error or warning, Mindcode emits the full path of the file name plus the positional information. Some IDEs may not recognize file paths in the compiler output but may be able to recognize a URI. For this reason, it is possible to use the --file-references command-line option to choose the desired format. The option can take these arguments:
path(the default value): file references are emitted as an absolute file path.uri: file references are emitted as a URI.windows-uri: file references are emitted as a URI. When the current environment is Windows, and the URI starts withfile:/and not withfile:///, the prefix is changed tofile:///. This helps some IDEs recognize the file reference.
IntelliJ IDEA can be downloaded here: https://www.jetbrains.com/idea/download/. The Community edition is free to use.
After installing and running IDEA, you can import the settings file containing Mindcode file types and external tool configurations.
- File types: settings-filetypes.zip
- External tools (Windows): settings-tools-windows.zip
- External tools (Linux): settings-tools-linux.zip (The settings for Linux were adapted from a Windows environment but weren't tested—they may need some tweaking to work.)
To import these settings, choose File/Manage IDE settings/Import settings... and select the appropriate settings file.
The file types settings contain Mindcode, Schemacode and mlog file type definitions configured for syntax highlighting of Mindcode and Mindustry Logic keywords. The file containing these settings is automatically kept up to date with each release of Mindcode. When a new version adds or removes keywords, importing the settings again will update your IDE to the latest language definition.
Note
Names of mlog variables generated by Mindcode consist of special characters, numeric indexes and identifiers. The mlog file type definition for IntelliJ IDEA doesn't correctly recognize and highlight these names.
The external tools settings contain two external tools: Mindcode compiler and Schemacode compiler. You may want to assign a shortcut key to them in Settings/Keymap/External tools, and to review the command line arguments configured for either tool in Settings/Tools/External tools.
Example of syntax highlighting with the given settings:
Unfortunately, the syntax highlighting doesn't correctly recognize some literals, but otherwise it is reasonably good.
@schittli kindly contributed a VS Code syntax highlighter.
Download the extension from the Visual Studio marketplace.
Unfortunately, this extension wasn't updated for a long time and doesn't support recent additions to Mindcode syntax.
« Previous: Command line tool | Up: Contents | Next: Mlog Watcher »

