From 2ed4d554750527d3fd09d6dbfe0e02ae086be543 Mon Sep 17 00:00:00 2001 From: Tamnac <49466795+Tamnac@users.noreply.github.com> Date: Sun, 8 Sep 2024 18:33:53 -0700 Subject: Add language kdl (#477) * Add language_kdl * [CI] Updated README.md and manifest.json. * Add language_kdl to manifest * [CI] Updated README.md and manifest.json. --------- Co-authored-by: Github Actions <> --- README.md | 1 + manifest.json | 11 +++++++ plugins/language_kdl.lua | 84 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 plugins/language_kdl.lua diff --git a/README.md b/README.md index 6984ea4..136ab5e 100644 --- a/README.md +++ b/README.md @@ -257,6 +257,7 @@ to follow with `extra.follow_branch`.* | [`language_json`](plugins/language_json.lua?raw=1) | Syntax for the [JSON](https://www.json.org/json-en.html) language | | [`language_jsx`](plugins/language_jsx.lua?raw=1) | Syntax for the [JSX](https://reactjs.org/docs/introducing-jsx.html) language for the React framework in JavaScript | | [`language_julia`](plugins/language_julia.lua?raw=1) | Syntax for the [Julia](https://julialang.org/) programming language | +| [`language_kdl`](plugins/language_kdl.lua?raw=1) | Syntax for the [KDL](https://kdl.dev) document language | | [`language_kotlin`](plugins/language_kotlin.lua?raw=1) | Syntax for the [Kotlin](https://kotlinlang.org/docs/home.html) programming language | | [`language_ksy`](https://raw.githubusercontent.com/whiteh0le/lite-plugins/main/plugins/language_ksy.lua?raw=1)* | Syntax for [Kaitai](http://kaitai.io/) struct files | | [`language_lilypond`](plugins/language_lilypond.lua?raw=1) | Syntax for the [LilyPond](https://lilypond.org/) music typesetting language | diff --git a/manifest.json b/manifest.json index 4fd7a35..e95b120 100644 --- a/manifest.json +++ b/manifest.json @@ -115,6 +115,7 @@ "language_json": {}, "language_jsx": {}, "language_julia": {}, + "language_kdl": {}, "language_kotlin": {}, "language_lilypond": {}, "language_liquid": {}, @@ -1191,6 +1192,16 @@ ], "version": "0.1" }, + { + "description": "Syntax for the [KDL](https://kdl.dev) document language", + "id": "language_kdl", + "mod_version": "3", + "path": "plugins/language_kdl.lua", + "tags": [ + "language" + ], + "version": "0.1" + }, { "description": "Syntax for the [Kotlin](https://kotlinlang.org/docs/home.html) programming language", "id": "language_kotlin", diff --git a/plugins/language_kdl.lua b/plugins/language_kdl.lua new file mode 100644 index 0000000..a08a0bb --- /dev/null +++ b/plugins/language_kdl.lua @@ -0,0 +1,84 @@ +-- mod-version:3 +local syntax = require "core.syntax" + +local identifier = "\"?[^%d%s\\/%(%){}<>;%[%]=,\"][^%s\\/%(%){}<>;%[%]=,\"]*\"?" + +syntax.add { + name = "KDL", + files = { "%.kdl" }, + space_handling = false, + comment = "//", + block_comment = {"/*", "*/"}, + patterns = { + { + pattern = "^%s*".. identifier .."%s*", + type = "keyword" + },-- + { pattern = "%s+", type = "normal" }, + { + pattern = "[{;]%s*()" .. identifier .. "%s*", + type = {"normal", "keyword"} + },-- + { pattern = { "r#+\"", "\"#+" }, type = "string" }, + { pattern = { '"', '"', '\\' }, type = "string" }, + { pattern = "[%-+]?0x[%x_]+", type = "number" }, + { pattern = "[%-+]?0b[01_]+", type = "number" }, + { pattern = "[%-+]?0o[0-7_]+", type = "number" }, + { + pattern = "[%-+]?[%d_]+%.[%d_]+e[%-+]?[%d_]+", + type = "number" + }, + { pattern = "[%-+]?[%d_]+%.[%d_]+", type = "number" }, + { pattern = "[%-+]?[%d_]+e[%-+]?[%d_]+", type = "number" }, + { pattern = "[%-+]?[%d_]+", type = "number" }, + { pattern = "/[%-/].-\n", type = "comment" }, + { pattern = {"/%*", "%*/"}, type = "comment" }, + { pattern = identifier, type = "keyword2" }, + { + pattern = "%(()" .. identifier .. "()%)", + type = {"normal", "function", "normal"} + }, + }, + symbols = { + ["null"] = "literal", + ["true"] = "literal", + ["false"] = "literal", + ["i8"] = "function", + ["i32"] = "function", + ["i16"] = "function", + ["i64"] = "function", + ["u8"] = "function", + ["u32"] = "function", + ["u16"] = "function", + ["u64"] = "function", + ["isize"] = "function", + ["usize"] = "function", + ["f32"] = "function", + ["f64"] = "function", + ["decimal64"] = "function", + ["decimal128"] = "function", + ["date-time"] = "function", + ["time"] = "function", + ["date"] = "function", + ["duration"] = "function", + ["decimal"] = "function", + ["currency"] = "function", + ["country-2"] = "function", + ["country-3"] = "function", + ["country-subdivision"] = "function", + ["email"] = "function", + ["idn-email"] = "function", + ["hostname"] = "function", + ["idn-hostname"] = "function", + ["ipv4"] = "function", + ["ipv6"] = "function", + ["url"] = "function", + ["url-reference"] = "function", + ["irl"] = "function", + ["irl-reference"] = "function", + ["url-template"] = "function", + ["uuid"] = "function", + ["regex"] = "function", + ["base64"] = "function", + }, +} -- cgit v1.2.3