aboutsummaryrefslogtreecommitdiff
path: root/plugins/language_json.lua
blob: 26d05a2ffc2d21ba836ba56762e1d3b3b1f3b344 (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
-- mod-version:3 priority:110

local syntax = require "core.syntax"

syntax.add {
  name = "JSON",
  
  files = { 
    "%.json$",
    "%.cjson$",
    "%.jsonc$",
    "%.ipynb$",
  },
  
  comment = "//",
  block_comment = {"/*", "*/"},
  patterns = {
  
    -- cjson support
    { pattern = "//.*", type = "comment" },
    { pattern = { "/%*", "%*/" }, type = "comment" },
    
    { regex = [["(?:[^"\\]|\\.)*"()\s*:]], type = { "keyword", "normal" } }, -- key
    { regex = [["(?:[^"\\]|\\.)*"]], type = "string" }, -- value
    { pattern = "0x[%da-fA-F]+", type = "number" },
    { pattern = "-?%d+[%d%.eE]*",  type = "number" },
    { pattern = "-?%.?%d+", type = "number" },
    { pattern = "null", type = "literal" },
    { pattern = "true", type = "literal" },
    { pattern = "false", type = "literal" }
  },
  symbols = { }
}