aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authordevrandom <gtimes3isgggg@disroot.org>2023-11-10 18:08:49 +0000
committerGitHub <noreply@github.com>2023-11-10 19:08:49 +0100
commitac897462f89b1c1cb3e51df01063f1191e9d2a72 (patch)
treea483006bb45ced7a5e4cee055879ef06fbc35712 /plugins
parentf7b259de3549a4a1d873066975f8278c74f8b4bb (diff)
downloadlite-xl-plugins-ac897462f89b1c1cb3e51df01063f1191e9d2a72.tar.gz
lite-xl-plugins-ac897462f89b1c1cb3e51df01063f1191e9d2a72.zip
Added syntax support for JSON files (#331)
* Create language_json.lua * Update manifest.json * Update manifest.json * Update plugins/language_json.lua Co-authored-by: Jefferson González <jgmdev@gmail.com> * removed invalid literals and numeric keys * updated key pattern to include spaces and hyphens, and updated value pattern to not match multiline strings * added priority again, changed value back to string and updated formatting a bit * actually added priority this time god it's hard working with 2 different files * patterns now match everything but newlines, and allow for whitespace to prefix the colon, and priority is now fixed aswell * added cjson comment support * Update plugins/language_json.lua Co-authored-by: Guldoman <giulio.lettieri@gmail.com> * Update plugins/language_json.lua Co-authored-by: Guldoman <giulio.lettieri@gmail.com> * Update plugins/language_json.lua Co-authored-by: Guldoman <giulio.lettieri@gmail.com> * avoid highlighting colon * updated pattern * Add ".jsonc" extension --------- Co-authored-by: Jefferson González <jgmdev@gmail.com> Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/language_json.lua27
1 files changed, 27 insertions, 0 deletions
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 = { }
+}
+