aboutsummaryrefslogtreecommitdiff
path: root/plugins/language_kdl.lua
blob: a08a0bbe976647189a94c812ebd44dc2faf242e1 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
-- mod-version:3
local syntax = require "core.syntax"

local identifier = "\"?[^%d%s\\/%(%){}<>;%[%]=,\"][^%s\\/%(%){}<>;%[%]=,\"]*\"?"

syntax.add {
  name = "KDL",
  files = { "%.kdl" },
  space_handling = false,
  comment = "//",
  block_comment = {"/*", "*/"},
  patterns = {
    {
		pattern = "^%s*".. identifier .."%s*",
		type = "keyword"
	},--
    { pattern = "%s+",                      type = "normal"   },
    {
		pattern = "[{;]%s*()" .. identifier .. "%s*",
		type = {"normal", "keyword"}
	},--
    { pattern = { "r#+\"", "\"#+" },         type = "string"   },
    { pattern = { '"', '"', '\\' },          type = "string"   },
    { pattern = "[%-+]?0x[%x_]+",            type = "number"   },
    { pattern = "[%-+]?0b[01_]+",            type = "number"   },
    { pattern = "[%-+]?0o[0-7_]+",           type = "number"   },
    {
		pattern = "[%-+]?[%d_]+%.[%d_]+e[%-+]?[%d_]+",
		type = "number"
	},
	{ pattern = "[%-+]?[%d_]+%.[%d_]+",      type = "number"   },
    { pattern = "[%-+]?[%d_]+e[%-+]?[%d_]+", type = "number"   },
    { pattern = "[%-+]?[%d_]+",              type = "number"   },
    { pattern = "/[%-/].-\n",                type = "comment"  },
    { pattern = {"/%*", "%*/"},              type = "comment"  },
    { pattern = identifier,                  type = "keyword2" },
	{
		pattern = "%(()" .. identifier .. "()%)",
		type = {"normal", "function", "normal"}
	},
  },
  symbols = {
  	["null"]  = "literal",
  	["true"]  = "literal",
  	["false"] = "literal",
  	["i8"]    = "function",
  	["i32"]   = "function",
  	["i16"]   = "function",
  	["i64"]   = "function",
  	["u8"]    = "function",
  	["u32"]   = "function",
  	["u16"]   = "function",
  	["u64"]   = "function",
  	["isize"]   = "function",
  	["usize"]   = "function",
  	["f32"]   = "function",
  	["f64"]   = "function",
  	["decimal64"]   = "function",
  	["decimal128"]   = "function",
  	["date-time"]   = "function",
  	["time"]   = "function",
  	["date"]   = "function",
  	["duration"]   = "function",
  	["decimal"]   = "function",
  	["currency"]   = "function",
  	["country-2"]   = "function",
  	["country-3"]   = "function",
  	["country-subdivision"]   = "function",
  	["email"]   = "function",
  	["idn-email"]   = "function",
  	["hostname"]   = "function",
  	["idn-hostname"]   = "function",
  	["ipv4"]   = "function",
  	["ipv6"]   = "function",
  	["url"]   = "function",
  	["url-reference"]   = "function",
  	["irl"]   = "function",
  	["irl-reference"]   = "function",
  	["url-template"]   = "function",
  	["uuid"]   = "function",
  	["regex"]   = "function",
  	["base64"]   = "function",
  },
}