Contents

Editor colouring with Monarch

Jacker’s editor colours a language pack’s language with a Monarch grammar, the format of the Monaco editor. This page covers what Jacker accepts.

The file

Name it in the language’s syntax.monarch. It’s a JSON object with a tokenizer object, and regular expressions are strings:

json
{
  "keywords": ["fn", "let", "return"],
  "tokenizer": {
    "root": [
      ["//.*$", "comment"],
      ["\"[^\"]*\"", "string"],
      ["\\d+", "number"],
      ["[a-zA-Z_]\\w*", { "cases": { "@keywords": "keyword", "@default": "identifier" } }]
    ]
  }
}

The file must be valid JSON, at most 256 KB, with a tokenizer. A file that fails any of these isn’t used, and the language shows as plain text. Because the file is JSON, it can’t contain functions.

TextMate grammars aren’t supported.

Comments

Put comment markers in the manifest, not the Monarch file, so the editor’s Toggle Comment works:

json
"syntax": {
  "monarch": "syntax/LANG.monarch.json",
  "comments": { "line": "//", "block": ["/*", "*/"] }
}

Languages the editor already colours

If your language’s id is one the editor already ships, such as go or rust, the editor keeps its own colouring and your Monarch file isn’t used. Your language server, if any, still runs.

We use only essential cookies to keep you signed in and the app working. With your consent we may enable optional analytics to help us improve e-volv. See our Privacy Policy and Terms.