aboutsummaryrefslogtreecommitdiff
path: root/plugins/language_zig.lua
blob: fdd4d1a41f83f683f293f47c665c2c147502ec0d (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
-- mod-version:1 -- lite-xl 1.16
local syntax = require "core.syntax"

syntax.add {
  files = { "%.zig$" },
  comment = "//",
  patterns = {
    { pattern = "//.-\n", type = "comment"  },
    { pattern = "\\\\.-\n", type = "string" },
    { pattern = { '"', '"', '\\' }, type = "string"   },
    { pattern = { "'", "'", '\\' }, type = "string"   },
    { pattern = "[iu][%d_]+", type = "keyword2" },
    { pattern = "0b[01_]+", type = "number" },
    { pattern = "0o[0-7_]+", type = "number" },
    { pattern = "0x[%x_]+", type = "number" },
    { pattern = "0x[%x_]+%.[%x_]*[pP][-+]?%d+", type = "number" },
    { pattern = "0x[%x_]+%.[%x_]*", type = "number" },
    { pattern = "0x%.[%x_]+[pP][-+]?%d+", type = "number" },
    { pattern = "0x%.[%x_]+", type = "number" },
    { pattern = "0x[%x_]+[pP][-+]?%d+", type = "number" },
    { pattern = "0x[%x_]+", type = "number" },
    { pattern = "%d[%d_]*%.[%d_]*[eE][-+]?%d+", type = "number" },
    { pattern = "%d[%d_]*%.[%d_]*", type = "number" },
    { pattern = "%d[%d_]*", type = "number" },
    { pattern = "[%+%-=/%*%^%%<>!~|&%.%?]", type = "operator" },
    { pattern = "[%a_][%w_]*()%s*%(",     type = {"function", "normal"} },
    { pattern = "[A-Z][%w_]*", type = "keyword2" },
    { pattern = "[%a_][%w_]*", type = "symbol" },
    { pattern = "@()[%a_][%w_]*", type = {"operator", "function"} },
  },
  symbols = {
    ["fn"]          = "keyword",
    ["asm"]         = "keyword",
    ["volatile"]    = "keyword",
    ["continue"]    = "keyword",
    ["break"]       = "keyword",
    ["switch"]      = "keyword",
    ["for"]         = "keyword",
    ["while"]       = "keyword",
    ["var"]             = "keyword",
    ["anytype"]         = "keyword",
    ["const"]           = "keyword",
    ["test"]            = "keyword",
    ["packed"]          = "keyword",
    ["extern"]          = "keyword",
    ["export"]          = "keyword",
    ["pub"]             = "keyword",
    ["defer"]           = "keyword",
    ["errdefer"]        = "keyword",
    ["align"]           = "keyword",
    ["usingnamespace"]  = "keyword",
    ["noasync"]     = "keyword",
    ["async"]       = "keyword",
    ["await"]       = "keyword",
    ["cancel"]      = "keyword",
    ["suspend"]     = "keyword",
    ["resume"]      = "keyword",
    ["threadlocal"] = "keyword",
    ["linksection"] = "keyword",
    ["callconv"]    = "keyword",
    ["try"]         = "keyword",
    ["catch"]       = "keyword",
    ["orelse"]      = "keyword",
    ["unreachable"] = "keyword",
    ["error"]       = "keyword",
    ["if"]          = "keyword",
    ["else"]        = "keyword",
    ["return"]      = "keyword",
    ["comptime"]    = "keyword",
    ["stdcallcc"]   = "keyword",
    ["ccc"]         = "keyword",
    ["nakedcc"]     = "keyword",
    ["and"]         = "keyword",
    ["or"]          = "keyword",
    ["struct"] = "keyword",
    ["enum"] = "keyword",
    ["union"] = "keyword",
    ["opaque"] = "keyword",

    -- types
    ["f16"] = "keyword2",
    ["f32"] = "keyword2",
    ["f64"] = "keyword2",
    ["f128"] = "keyword2",
    ["void"]            = "keyword2",
    ["c_void"]          = "keyword2",
    ["isize"]           = "keyword2",
    ["usize"]           = "keyword2",
    ["c_short"]         = "keyword2",
    ["c_ushort"]        = "keyword2",
    ["c_int"]           = "keyword2",
    ["c_uint"]          = "keyword2",
    ["c_long"]          = "keyword2",
    ["c_ulong"]         = "keyword2",
    ["c_longlong"]      = "keyword2",
    ["c_ulonglong"]     = "keyword2",
    ["c_longdouble"]    = "keyword2",
    ["bool"]            = "keyword2",

    ["noreturn"]        = "keyword2",
    ["type"]            = "keyword2",
    ["anyerror"]        = "keyword2",
    ["comptime_int"]    = "keyword2",
    ["comptime_float"]  = "keyword2",

    ["true"]            = "literal",
    ["false"]           = "literal",
    ["null"]            = "literal",
    ["undefined"]       = "literal",
  },
}