aboutsummaryrefslogtreecommitdiff
path: root/plugins/language_crystal.lua
blob: 7f93c25859bfdcb3dc9cc4c55b5712186856387a (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
-- mod-version:3
-- based on the ruby plugin, see https://github.com/Tamnac/lite-xl-plugins to contribute
local syntax = require "core.syntax"

syntax.add {
  name = "Crystal",
  files = { "%.cr" },
  headers = "^#!.*[ /]crystal",
  comment = "#",
  patterns = {
    { pattern = { '"', '"', '\\' },     type = "string"   },
    { pattern = { "'", "'", '\\' },     type = "string"   },
    { pattern = "-?0x%x+",              type = "number"   },
    { pattern = "%#.-\n",               type = "comment"  },
    { pattern = "-?%d+[%d%.eE]*f?",     type = "number"   },
    { pattern = "-?%.?%d+f?",           type = "number"   },
    { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" },
    { pattern = "[%a_][%w_]*%f[(?]",    type = "function" },
    { pattern = "@?@[%a_][%w_]*",       type = "keyword2" },
    { pattern = "::[%w_]*",             type = "symbol"   },
    { pattern = ":[%w_]*",              type = "keyword2" },
    { pattern = "[%a_][%w_]*:[^:]",     type = "keyword2" },
    { pattern = "[%a_][%w_]*",          type = "symbol"   },
  },
  symbols = {
    ["__ENCODING__"] = "keyword",
    ["__FILE__"]     = "keyword",
    ["__LINE__"]     = "keyword",
    ["alias"]        = "keyword",
    ["annotation"]   = "keyword2",
    ["Array"]        = "keyword2",
    ["BEGIN"]        = "keyword",
    ["begin"]        = "keyword",
    ["Bool"]         = "keyword2",
    ["break"]        = "keyword",
    ["case"]         = "keyword",
    ["Char"]         = "keyword2",
    ["class"]        = "keyword",
    ["def"]          = "keyword",
    ["defined?"]     = "keyword",
    ["do"]           = "keyword",
    ["else"]         = "keyword",
    ["elsif"]        = "keyword",
    ["END"]          = "keyword",
    ["end"]          = "keyword",
    ["ensure"]       = "keyword",
    ["enum"]         = "keyword2",
    ["extend"]       = "keyword",
    ["false"]        = "literal",
    ["Float32"]      = "keyword2",
    ["Float64"]      = "keyword2",
    ["fun"]          = "keyword",
    ["if"]           = "keyword",
    ["in"]           = "keyword",
    ["include"]      = "keyword",
    ["Int8"]         = "keyword2",
    ["Int16"]        = "keyword2",
    ["Int32"]        = "keyword2",
    ["Int64"]        = "keyword2",
    ["module"]       = "keyword",
    ["NamedTuple"]   = "keyword2",
    ["next"]         = "keyword",
    ["nil"]          = "literal",
    ["not"]          = "keyword",
    ["out"]          = "function",
    ["private"]      = "keyword",
    ["Proc"]         = "keyword2",
    ["redo"]         = "keyword",
    ["require"]      = "keyword",
    ["rescue"]       = "keyword",
    ["retry"]        = "keyword",
    ["return"]       = "keyword",
    ["self"]         = "keyword",
    ["String"]       = "keyword2",
    ["struct"]       = "keyword2",
    ["super"]        = "keyword",
    ["then"]         = "keyword",
    ["times"]        = "function",
    ["true"]         = "literal",
    ["Tuple"]        = "keyword2",
    ["UInt8"]        = "keyword2",
    ["UInt16"]       = "keyword2",
    ["UInt32"]       = "keyword2",
    ["UInt64"]       = "keyword2",
    ["undef"]        = "keyword",
    ["union"]        = "keyword2",
    ["unless"]       = "keyword",
    ["until"]        = "keyword",
    ["when"]         = "keyword",
    ["while"]        = "keyword",
    ["yield"]        = "keyword"
  },
}