diff options
author | rxi <rxi@users.noreply.github.com> | 2020-05-18 20:41:46 +0100 |
---|---|---|
committer | rxi <rxi@users.noreply.github.com> | 2020-05-18 20:41:46 +0100 |
commit | d846b97df5fc82b96f41189a5495422a9cc4979b (patch) | |
tree | 8c45c10735ca137688cddc08da4f0d97be3b37dc | |
parent | feb990fb2eaa5ce8e2f473db9a581722ce26735a (diff) | |
parent | c44458a1d0c868c92f2301ac56fa8436734f6ea9 (diff) | |
download | lite-xl-plugins-d846b97df5fc82b96f41189a5495422a9cc4979b.tar.gz lite-xl-plugins-d846b97df5fc82b96f41189a5495422a9cc4979b.zip |
Merge branch 'master' of https://github.com/rxi/lite-plugins
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | plugins/language_batch.lua | 61 |
2 files changed, 62 insertions, 0 deletions
@@ -27,6 +27,7 @@ Plugin | Description [`inanimate`](plugins/inanimate.lua?raw=1) | Disables all transition animations [`indentguide`](plugins/indentguide.lua?raw=1) | Adds indent guides *([screenshot](https://user-images.githubusercontent.com/3920290/79640716-f9860000-818a-11ea-9c3b-26d10dd0e0c0.png))* [`language_angelscript`](plugins/language_angelscript.lua?raw=1) | Syntax for the [Angelscript](https://www.angelcode.com/angelscript/) programming language +[`language_batch`](plugins/language_batch.lua?raw=1) | Syntax for Windows [Batch Files](https://en.wikipedia.org/wiki/Batch_file) [`language_cpp`](plugins/language_cpp.lua?raw=1) | Syntax for the [C++](https://isocpp.org/) programming language [`language_csharp`](plugins/language_csharp.lua?raw=1) | Syntax for the [C#](http://csharp.net) programming language [`language_fe`](plugins/language_fe.lua?raw=1) | Syntax for the [fe](https://github.com/rxi/fe) programming language diff --git a/plugins/language_batch.lua b/plugins/language_batch.lua new file mode 100644 index 0000000..8caad59 --- /dev/null +++ b/plugins/language_batch.lua @@ -0,0 +1,61 @@ +local syntax = require "core.syntax" + +-- batch syntax for lite <liqube> + +-- windows batch files use caseless matching for symbols +local symtable = { + ["keyword"] = { + "if", "else", "elsif", "not", "for", "do", "in", + "equ", "neq", "lss", "leq", "gtr", "geq", -- == != < <= > >= + "nul", "con", "prn", "prn", "lpt1", "com1", "com2", "com3", "com4", + "exist", "defined", + "errorlevel", "cmdextversion", + "goto", "call", "verify", + }, + ["function"] = { + "set", "setlocal", "endlocal", "enabledelayedexpansion", + "echo", "type", + "cd", "chdir", + "md", "mkdir", + "pause", "choice", "exit", + "del", "rd", "rmdir", + "copy", "xcopy", + "move", "ren", + "find", "findstr", + "sort", "shift", "attrib", + "cmd", "command", + "forfiles", + }, +} +-- prepare a mixed symbol list +local function prepare_symbols(symtable) + local symbols = { } + for symtype, symlist in pairs(symtable) do + for _, symname in ipairs(symlist) do + symbols[symname:lower()] = symtype + symbols[symname:upper()] = symtype + end + end + return symbols +end + +syntax.add { + files = { "%.bat$", "%.cmd$" }, + comment = "rem", + patterns = { + { pattern = "@echo off\n", type = "keyword" }, + { pattern = "@echo on\n", type = "keyword" }, + { pattern = "rem.-\n", type = "comment" }, -- rem comment line, rem, rem. + { pattern = "REM.-\n", type = "comment" }, + { pattern = "%s*:[%w%-]+", type = "symbol" }, -- :labels + { pattern = "%:%:.-\n", type = "comment" }, -- :: comment line + { pattern = "%%%w+%%", type = "symbol" }, -- %variable% + { pattern = "%%%%?~?[%w:]+", type = "symbol" }, -- %1, %~dpn1, %~1:2, %%i, %%~i + { pattern = "[!=()%>&%^/\\@]", type = "operator" }, -- operators + { pattern = "-?%.?%d+f?", type = "number" }, -- integer numbers + { pattern = { '"', '"', '\\' }, type = "string" }, -- "strings" + { pattern = "[%a_][%w_]*", type = "normal" }, + { pattern = ":eof", type = "keyword" }, -- not quite as intended, but ok for now + }, + symbols = prepare_symbols(symtable), +} |