diff options
-rw-r--r-- | manifest.json | 9 | ||||
-rw-r--r-- | plugins/language_json.lua | 27 |
2 files changed, 36 insertions, 0 deletions
diff --git a/manifest.json b/manifest.json index 40b118a..40f993f 100644 --- a/manifest.json +++ b/manifest.json @@ -106,6 +106,7 @@ "language_java": {}, "language_jiyu": {}, "language_jsx": {}, + "language_json": {}, "language_julia": {}, "language_ksy": {}, "language_lilypond": {}, @@ -873,6 +874,14 @@ "tags": ["language"] }, { + "description": "Syntax for the [JSON](https://www.json.org/json-en.html) language", + "version": "0.1", + "path": "plugins/language_json.lua", + "id": "language_json", + "mod_version": "3", + "tags": ["language"] + }, + { "description": "Syntax for the [Julia](https://julialang.org/) programming language", "version": "0.1", "path": "plugins/language_julia.lua", diff --git a/plugins/language_json.lua b/plugins/language_json.lua new file mode 100644 index 0000000..eae97d4 --- /dev/null +++ b/plugins/language_json.lua @@ -0,0 +1,27 @@ +-- mod-version:3 priority:110 + +local syntax = require "core.syntax" + +syntax.add { + name = "JSON", + files = { "%.json$", "%.cjson$", "%.jsonc$" }, + 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 = { } +} + |