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:

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

action
    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:

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

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