aboutsummaryrefslogtreecommitdiff
path: root/plugins/language_yaml.lua
blob: b3ebdcda556e365c97386ab85a825a497d06878d (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
-- mod-version:1 -- lite-xl 2.00
local syntax = require "core.syntax"

syntax.add {
  files = { "%.yml$", "%.yaml$" },
  comment = "#",
  patterns = {
    { pattern = { "#", "\n"},                  type = "comment"  },
    { pattern = { '"', '"', '\\' },            type = "string"   },
    { pattern = { "'", "'", '\\' },            type = "string"   },
    { pattern = "%-?%.inf",                    type = "number"   },
    { pattern = "%.NaN",                       type = "number"   },
    {
      pattern = "%&()%g+",
      type = { "keyword", "literal" }
    },
    { pattern = "!%g+",                        type = "keyword"  },
    { pattern = "<<",                          type = "literal"  },
    {
      pattern = "[%s]%*()[%w%d_]+",
      type = { "keyword", "keyword2" }
    },
    {
      pattern = "%*()[%w%d_]+",
      type = { "keyword", "literal" }
    },
    {
      pattern = "[%[%{]()%s*[%w%d]+%g+%s*():%s",
      type = { "operator", "keyword2", "operator" }
    },
    {
      pattern = "[%s][%w%d]+%g+%s*():%s",
      type = { "keyword2", "operator" }
    },
    {
      pattern = "[%w%d]+%g+%s*():%s",
      type = { "literal", "operator" }
    },
    { pattern = "0%d+",                        type = "number"   },
    { pattern = "0x%x+",                       type = "number"   },
    { pattern = "[%+%-]?%d+[,%.eE:%+%d]*%d+",  type = "number"   },
    { pattern = "[%*%|%!>%%]",                 type = "keyword"  },
    { pattern = "[%-:%?%*%{%}%[%]]",           type = "operator" },
    -- Everything else for keywords to work
    {
      pattern = "[%d%a_][%g_]*()[%]%},]",
      type = { "string", "operator" }
    },
    { pattern = "[%d%a_][%g_]*",               type = "string"   },
  },
  symbols = {
    ["true"]  = "number",
    ["false"] = "number",
    ["y"]     = "number",
    ["n"]     = "number"
  }
}