Using MoonScript

You can write Marta plugins in MoonScript. It’s a programming language that compiles to Lua source code. It uses significant whitespaces, so it might be a better choice if you got used to Python.

MoonScript compiler is available on LuaRocks. See the Using LuaRocks dependencies to learn a bit more about LuaRocks package manager.

luarocks install moonscript

Note that you don’t have to bundle the MoonScript compiler dependency into your plugin, unless you want to generate and execute code fragments written in MoonScript in runtime. Just install the compiler locally.

Create the hello.moon file with the following contents:

    id: "marta.test.plugin"
    name: "Test plugin"
    apiVersion: "2.1"

    id: "show"
    name: "Test action"
    apply: (context) -> 
        martax.alert "Hello, world!"

See the MoonScript reference manual for more information on the language syntax.

Then open the terminal and run:

moonc hello.moon

If everything is OK, hello.lua will appear next to the MoonScript source. It will contain exactly the same code, but written in Lua:

  id = "marta.test.plugin",
  name = "Test plugin",
  apiVersion = "2.1"
return action({
  id = "show",
  name = "Test action",
  apply = function(context)
    return martax.alert("Hello, world!")

That’s it! You can install and distribute hello.lua as it was a Lua plugin.