aboutsummaryrefslogtreecommitdiff
path: root/plugins/language_toml.lua
blob: eb3a2d772e5d3f61a383dbed09a9821089767eb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
-- mod-version:3

local syntax = require "core.syntax"

syntax.add {
  name = "TOML",
  files = { "%.toml$" },
  comment = '#',

  patterns = {
    { pattern = "#.*",                                type = "comment"  },

    { pattern = { '"""', '"""', '\\' },               type = "string"   },
    { pattern = { "'''", "'''"       },               type = "string"   },
    { pattern = { '"',   '"',   '\\' },               type = "string"   },
    { pattern = { "'",   "'"         },               type = "string"   },

    { pattern = "[%w_%.%-]+%s*%f[=]",                 type = "function" },

    { pattern = {"^%s*%[", "%]"},                     type = "keyword"  },

    { pattern = "0x[%x_]+",                           type = "number"   },
    { pattern = "0o[0-7_]+",                          type = "number"   },
    { pattern = "0b[01_]+",                           type = "number"   },
    { pattern = "%d[%d_]*%.?[%d_]*[eE][%-+]?[%d_]+",  type = "number"   },
    { pattern = "%d[%d_]*%.?[$d_]*",                  type = "number"   },
    { pattern = "%f[-+%w_][-+]%f[%w%.]",              type = "number"   },

    { pattern = "[%+%-:TZ]",                          type = "operator" },
    { pattern = "%a+",                                type = "symbol"   },
  },

  symbols = {
    ["true"] = "literal",
    ["false"] = "literal",

    ["nan"]  = "number",
    ["inf"]  = "number"
  },
}