aboutsummaryrefslogtreecommitdiff
path: root/plugins/language_groovy.lua
blob: 8a3c5b82e56b14e4aa2d32087818b98e9700a643 (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
-- mod-version:3
local syntax = require "core.syntax"

syntax.add {
  name = "Groovy",
  files = { "%.groovy$" },
  comment = "//",
  block_comment = { "/*", "*/" },
  patterns = {
    { pattern = "//.*",                          type = "comment"  }, -- Single-line comment
    { pattern = { "/%*", "%*/" },                type = "comment"  }, -- Multi-line comment
    { pattern = { '"', '"', '\\' },              type = "string"   }, -- String, double quotes
    { pattern = { "'", "'", '\\' },              type = "string"   }, -- String, apices
    { pattern = { "%/", "%/", '\\' },            type = "string"   }, -- Slashy string
    { pattern = { "%$%/", "%/%$", '\\' },        type = "string"   }, -- Dollar slashy string
    { pattern = "'\\x%x?%x?%x?%x'",              type = "string"   }, -- character hexadecimal escape sequence
    { pattern = "'\\u%x%x%x%x'",                 type = "string"   }, -- character unicode escape sequence
    { pattern = "'\\?.'",                        type = "string"   }, -- character literal
    { pattern = "-?0x%x+",                       type = "number"   }, -- ?
    { pattern = "-?%d+[%d%.eE]*[a-zA-Z]?",       type = "number"   }, -- ?
    { pattern = "-?%.?%d+",                      type = "number"   }, -- ?
    { pattern = "-?[%d_+]+[a-zA-Z]?",            type = "number"   }, -- ?
    { pattern = "[%+%-=/%*%^%%<>!~|&]",          type = "operator" }, -- Operators
    { pattern = "[%a_][%w_]*%f[(]",              type = "function" }, -- Function/Class/Method/...
    { pattern = "[%a_][%w_]*%f[%[]",             type = "function" }, -- Custom Type
    { regex   = "[A-Z]+_?[A-Z]+",                type = "keyword2" }, -- Constants
    { pattern = "[%a_][%w_]*",                   type = "symbol"   }, -- ?
    { pattern = "[a-zA-Z]+%.+",                  type = "function" }, -- Lib path
    -- TODO: .class.
  },
  symbols = {
    -- Reserved keywords
    ["abstract"]           = "keyword",
    ["assert"]             = "keyword",
    ["break"]              = "keyword",
    ["case"]               = "keyword",
    ["catch"]              = "keyword",
    ["class"]              = "keyword",
    ["const"]              = "keyword",
    ["continue"]           = "keyword",
    ["def"]                = "keyword",
    ["default"]            = "keyword",
    ["do"]                 = "keyword",
    ["else"]               = "keyword",
    ["enum"]               = "keyword",
    ["extends"]            = "keyword",
    ["final"]              = "keyword",
    ["finally"]            = "keyword",
    ["for"]                = "keyword",
    ["goto"]               = "keyword",
    ["if"]                 = "keyword",
    ["implements"]         = "keyword",
    ["import"]             = "keyword",
    ["instanceof"]         = "keyword",
    ["interface"]          = "keyword",
    ["native"]             = "keyword",
    ["new"]                = "keyword",
    ["non-sealed"]         = "keyword",
    ["package"]            = "keyword",
    ["public"]             = "keyword",
    ["protected"]          = "keyword",
    ["private"]            = "keyword",
    ["return"]             = "keyword",
    ["static"]             = "keyword",
    ["strictfp"]           = "keyword",
    ["super"]              = "keyword",
    ["switch"]             = "keyword",
    ["synchronizedthis"]   = "keyword",
    ["threadsafe"]         = "keyword",
    ["throw"]              = "keyword",
    ["throws"]             = "keyword",
    ["transient"]          = "keyword",
    ["try"]                = "keyword",
    ["while"]              = "keyword",
    
    -- Contextual keywords
    ["as"]                 = "keyword",
    ["in"]                 = "keyword",
    ["permitsrecord"]      = "keyword",
    ["sealed"]             = "keyword",
    ["trait"]              = "keyword",
    ["var"]                = "keyword",
    ["yields"]             = "keyword",
    
    -- ?
    ["true"]               = "literal",
    ["false"]              = "literal",
    ["null"]               = "literal",
    ["boolean"]            = "literal",

    -- Types
    ["char"]               = "keyword",
    ["byte"]               = "keyword",
    ["short"]              = "keyword",
    ["int"]                = "keyword",
    ["long"]               = "keyword",
    ["float"]              = "keyword",
    ["double"]             = "keyword",
    
    ["Integer"]            = "keyword",
    ["BigInteger"]         = "keyword",
    ["Long"]               = "keyword",
    ["Float"]              = "keyword",
    ["BigDecimal"]         = "keyword",
    ["Double"]             = "keyword",
    ["String"]             = "keyword",
  },
}