aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRohan Vashisht <81112205+RohanVashisht1234@users.noreply.github.com>2024-04-20 21:55:41 +0530
committerGitHub <noreply@github.com>2024-04-20 18:25:41 +0200
commitded40e146b7bb79eba0c3e14ba88f1cd110e039f (patch)
tree276f64ef7d989ce41adb3c0eaf4c522a27011085
parentad65bd2e4886f6661001db7968f0298354351a30 (diff)
downloadlite-xl-plugins-ded40e146b7bb79eba0c3e14ba88f1cd110e039f.tar.gz
lite-xl-plugins-ded40e146b7bb79eba0c3e14ba88f1cd110e039f.zip
added support for Bazel syntax (#420)
* Create language_bazel.lua * Update language_bazel.lua * Update manifest.json * Update manifest.json * Update language_bazel.lua * Update manifest.json * Update language_bazel.lua * Update language_bazel.lua * Bump `meta_languages` version --------- Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
-rw-r--r--manifest.json11
-rw-r--r--plugins/language_bazel.lua102
2 files changed, 113 insertions, 0 deletions
diff --git a/manifest.json b/manifest.json
index 4a8c53a..3b1b936 100644
--- a/manifest.json
+++ b/manifest.json
@@ -65,6 +65,7 @@
"language_assembly_x86": {},
"language_autohotkey_v1": {},
"language_batch": {},
+ "language_bazel": {},
"language_bib": {},
"language_blade": {},
"language_blueprint": {},
@@ -670,6 +671,16 @@
"version": "0.1"
},
{
+ "description": "Syntax for [Bazel](https://bazel.build/) build tool files.",
+ "id": "language_bazel",
+ "mod_version": "3",
+ "path": "plugins/language_bazel.lua",
+ "tags": [
+ "language"
+ ],
+ "version": "0.1"
+ },
+ {
"description": "Syntax for [BibTex](https://en.wikipedia.org/wiki/BibTeX) files",
"id": "language_bib",
"mod_version": "3",
diff --git a/plugins/language_bazel.lua b/plugins/language_bazel.lua
new file mode 100644
index 0000000..8b0348e
--- /dev/null
+++ b/plugins/language_bazel.lua
@@ -0,0 +1,102 @@
+--- Author: Rohan Vashisht: https://github.com/rohanvashisht1234/
+-- mod-version:3
+------------ IMPORT LIB ------------
+local syntax_highlight = require("core.syntax")
+------------------------------------
+
+------------- DATABASE -------------
+
+---- SYMBOLS ----
+local SYMBOLS = {}
+
+local KEYWORDS = {
+ "break",
+ "continue",
+ "elif",
+ "else",
+ "for",
+ "if",
+ "pass",
+ "return",
+ "True",
+ "False"
+}
+
+local KEYWORDS2 = {
+ "as",
+ "assert",
+ "class",
+ "del",
+ "except",
+ "finally",
+ "from",
+ "global",
+ "import",
+ "in",
+ "is",
+ "lambda",
+ "nonlocal",
+ "raise",
+ "try",
+ "while",
+ "with",
+ "yield"
+}
+
+local LITERALS = {
+ "all",
+ "any",
+ "bool",
+ "dict",
+ "dir",
+ "enumerate",
+ "getattr",
+ "hasattr",
+ "hash",
+ "int",
+ "len",
+ "list",
+ "load",
+ "max",
+ "min",
+ "repr",
+ "reversed",
+ "sorted",
+ "str",
+ "tuple",
+ "type",
+ "zip"
+}
+-----------------
+
+---- PATTERNS ----
+local PATTERNS = {
+ { pattern = { '"', '"', '\\' }, type = "string" }, -- tested ok
+ { pattern = "#.*", type = "comment" }, -- tested ok
+ { pattern = "[!%-/*?:=><]", type = "operator" }, -- tested ok
+ { pattern = "-?%d+[%d%.eE_]*", type = "number" }, -- tested ok
+ { pattern = '[%a_][%w_]*%f[(]', type = 'function' }, -- tested ok
+ { pattern = "-?%d+[%d%.eE_]*", type = "number" }, -- tested ok
+ { pattern = "[%a_][%w_]*", type = "normal" } -- tested ok
+}
+------------------
+------------------------------------
+
+--------------- MAIN ---------------
+for _, keyword in ipairs(KEYWORDS) do
+ SYMBOLS[keyword] = "keyword"
+end
+for _, keyword2 in ipairs(KEYWORDS2) do
+ SYMBOLS[keyword2] = "keyword2"
+end
+for _, literal in ipairs(LITERALS) do
+ SYMBOLS[literal] = "literal"
+end
+syntax_highlight.add {
+ name = "Bazel",
+ files = {"%.bazel$","%.bzl$"},
+ comment = "#",
+ patterns = PATTERNS,
+ symbols = SYMBOLS,
+}
+------------------------------------