aboutsummaryrefslogtreecommitdiff
path: root/plugins/language_liquid.lua
blob: f9ee8e49db993e864cde740e48e476f3fe084e5a (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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
-- lite-xl 1.16
local syntax = require "core.syntax"

local liquid_syntax = {
  patterns = {
    { pattern = { '"', '"', '\\' },        type = "string"   },
    { pattern = { "'", "'", '\\' },        type = "string"   },
    { pattern = "-?%d+[%d%.]*f?",          type = "number"   },
    { pattern = "-?%.?%d+f?",              type = "number"   },
    { pattern = "%w+",                     type = "symbol" },
  },
  symbols = {
    ["abs"] = "keyword2",
    ["and"] = "operator",
    ["append"] = "keyword2",
    ["assign"] = "keyword",
    ["at_least"] = "keyword2",
    ["at_most"] = "keyword2",
    ["break"] = "keyword",
    ["camelcase"] = "keyword2",
    ["capitalize"] = "keyword2",
    ["capture"] = "keyword",
    ["endcapture"] = "keyword",
    ["case"] = "keyword",
    ["ceil"] = "keyword2",
    ["comment"] = "keyword",
    ["endcomment"] = "keyword",
    ["concat"] = "keyword2",
    ["contains"] = "operator",
    ["cycle"] = "keyword",
    ["date"] = "keyword2",
    ["decrement"] = "keyword",
    ["default"] = "keyword2",
    ["divided_by"] = "keyword2",
    ["downcase"] = "keyword2",
    ["else"] = "keyword",
    ["elsif"] = "keyword",
    ["false"] = "literal",
    ["first"] = "keyword2",
    ["floor"] = "keyword2",
    ["for"] = "keyword",
    ["endfor"] = "keyword",
    ["forloop"] = "literal",
    ["handleize"] = "keyword2",
    ["handle"] = "keyword2",
    ["if"] = "keyword",
    ["endif"] = "keyword",
    ["increment"] = "keyword",
    ["index0"] = "literal",
    ["index"] = "literal",
    ["in"] = "operator",
    ["join"] = "keyword2",
    ["last"] = "keyword2",
    ["length"] = "literal",
    ["limit"] = "keyword",
    ["lstrip"] = "keyword",
    ["map"] = "keyword2",
    ["minus"] = "keyword2",
    ["modulo"] = "keyword2",
    ["nil"] = "literal",
    ["null"] = "literal",
    ["offset"] = "keyword2",
    ["or"] = "operator",
    ["pluralize"] = "keyword2",
    ["plus"] = "keyword2",
    ["prepend"] = "keyword2",
    ["raw"] = "keyword",
    ["endraw"] = "keyword",
    ["removefirst"] = "keyword2",
    ["remove"] = "keyword2",
    ["replacefirst"] = "keyword2",
    ["replace"] = "keyword2",
    ["reversed"] = "operator",
    ["reverse"] = "keyword2",
    ["rindex0"] = "literal",
    ["rindex"] = "literal",
    ["round"] = "keyword2",
    ["rstrip"] = "keyword2",
    ["size"] = "keyword2",
    ["slice"] = "keyword2",
    ["sort"] = "keyword2",
    ["split"] = "keyword2",
    ["strip"] = "keyword2",
    ["strip_newlines"] = "keyword2",
    ["times"] = "keyword2",
    ["true"] = "literal",
    ["truncate"] = "keyword2",
    ["truncatewords"] = "keyword2",
    ["uniq"] = "keyword2",
    ["unless"] = "keyword",
    ["endunless"] = "keyword",
    ["upcase"] = "keyword2",
    ["when"] = "keyword",
    ["where"] = "keyword2"
    
  },
}

syntax.add {
  files = { "%.liquid?$" },
  patterns = {
    { pattern = { "{%%", "%%}" }, syntax = liquid_syntax, type = "function" },
    { pattern = { "{{", "}}" }, syntax = liquid_syntax, type = "function" },
    { 
      pattern = { 
        "<%s*[sS][cC][rR][iI][pP][tT]%s+[tT][yY][pP][eE]%s*=%s*" ..
          "['\"]%a+/[jJ][aA][vV][aA][sS][cC][rR][iI][pP][tT]['\"]%s*>",
        "<%s*/[sS][cC][rR][iI][pP][tT]>" 
      },
      syntax = ".js", 
      type = "function" 
    },
    { 
      pattern = { 
        "<%s*[sS][cC][rR][iI][pP][tT]%s*>",
        "<%s*/%s*[sS][cC][rR][iI][pP][tT]>" 
      },
      syntax = ".js",
      type = "function"
    },
    { 
      pattern = { 
        "<%s*[sS][tT][yY][lL][eE][^>]*>", 
        "<%s*/%s*[sS][tT][yY][lL][eE]%s*>" 
      },
      syntax = ".css",
      type = "function"
    },
    { pattern = { "<!%-%-", "%-%->" },     type = "comment"  },
    { pattern = { '%f[^>][^<]', '%f[<]' }, type = "normal"   },
    { pattern = { '"', '"', '\\' },        type = "string"   },
    { pattern = { "'", "'", '\\' },        type = "string"   },
    { pattern = "0x[%da-fA-F]+",           type = "number"   },
    { pattern = "-?%d+[%d%.]*f?",          type = "number"   },
    { pattern = "-?%.?%d+f?",              type = "number"   },
    { pattern = "%f[^<]![%a_][%w_]*",      type = "keyword2" },
    { pattern = "%f[^<][%a_][%w_]*",       type = "function" },
    { pattern = "%f[^<]/[%a_][%w_]*",      type = "function" },
    { pattern = "[%a_][%w_]*",             type = "keyword"  },
    { pattern = "[/<>=]",                  type = "operator" }
  },
  symbols = {},
}