aboutsummaryrefslogtreecommitdiff
path: root/plugins/language_awk.lua
diff options
context:
space:
mode:
authorSamuel <36420837+Samueru-sama@users.noreply.github.com>2024-07-26 10:43:30 -0400
committerGitHub <noreply@github.com>2024-07-26 16:43:30 +0200
commitc1bb563921b9d2610afecadb5760d2ac6189c1d8 (patch)
tree2f51eb0e3261b85580ca739fef5f48683d99d78f /plugins/language_awk.lua
parent280b4829a4f1b12d6a6f5db283f84a74546ac256 (diff)
downloadlite-xl-plugins-c1bb563921b9d2610afecadb5760d2ac6189c1d8.tar.gz
lite-xl-plugins-c1bb563921b9d2610afecadb5760d2ac6189c1d8.zip
Add `language_awk` (#461)
* Add `language_awk` * Update manifest.json to include language awk * Remove "case" from `language_awk.lua` I forgot to delete this when copying the symbols, I left it in place because it was used as reference for how the "=" should be spaced. * Update `language_awk`, remove new line from pattern * Update manifest.json, fix id for `language_awk` * Simplify sheabang pattern in `language_awk` * Update pattern in `language_awk` * Update pattern in `language_awk` * Update pattern in `language_awk` * Update pattern in `language_awk` * Update pattern in `language_awk` * Add more symbols to `language_awk`
Diffstat (limited to 'plugins/language_awk.lua')
-rw-r--r--plugins/language_awk.lua110
1 files changed, 110 insertions, 0 deletions
diff --git a/plugins/language_awk.lua b/plugins/language_awk.lua
new file mode 100644
index 0000000..cc56335
--- /dev/null
+++ b/plugins/language_awk.lua
@@ -0,0 +1,110 @@
+-- mod-version:3
+local syntax = require "core.syntax"
+
+syntax.add {
+ name = "Awk script",
+ files = "%.awk$",
+ headers = "^#!.*bin.*awk",
+ comment = "#",
+ patterns = {
+ -- $# is a awk special variable and the '#' shouldn't be interpreted
+ -- as a comment.
+ { pattern = "%$[%a_@*#][%w_]*", type = "keyword2" },
+ -- Comments
+ { pattern = "#.*", type = "comment" },
+ -- Strings
+ { pattern = { '"', '"', '\\' }, type = "string" },
+ { pattern = { "'", "'", '\\' }, type = "string" },
+ { pattern = { '`', '`', '\\' }, type = "string" },
+ -- Ignore numbers that start with dots or slashes
+ { pattern = "%f[%w_%.%/]%d[%d%.]*%f[^%w_%.]", type = "number" },
+ -- Operators
+ { pattern = "[!<>|&%[%]:=*]", type = "operator" },
+ -- Match parameters
+ { pattern = "%f[%S][%+%-][%w%-_:]+", type = "function" },
+ { pattern = "%f[%S][%+%-][%w%-_]+%f[=]", type = "function" },
+ -- Prevent parameters with assignments from been matched as variables
+ {
+ pattern = "%s%-%a[%w_%-]*()%s+()%d[%d%.]+",
+ type = { "function", "normal", "number" }
+ },
+ {
+ pattern = "%s%-%a[%w_%-]*()%s+()%a[%a%-_:=]+",
+ type = { "function", "normal", "symbol" }
+ },
+ -- Match variable assignments
+ { pattern = "[_%a][%w_]+%f[%+=]", type = "keyword2" },
+ -- Match variable expansions
+ { pattern = "%${.-}", type = "keyword2" },
+ { pattern = "%$[%d%$%a_@*][%w_]*", type = "keyword2" },
+ -- Functions
+ { pattern = "[%a_%-][%w_%-]*()%s*%f[(]", type = { "function", "normal" } },
+ -- Everything else
+ { pattern = "[%a_][%w_]*", type = "symbol" },
+ },
+ symbols = {
+ ["break"] = "keyword",
+ ["continue"] = "keyword",
+ ["do"] = "keyword",
+ ["delete"] = "keyword",
+ ["else"] = "keyword",
+ ["exit"] = "keyword",
+ ["for"] = "keyword",
+ ["function"] = "keyword",
+ ["getline"] = "keyword",
+ ["if"] = "keyword",
+ ["next"] = "keyword",
+ ["nextfile"] = "keyword",
+ ["print"] = "keyword",
+ ["printf"] = "keyword",
+ ["return"] = "keyword",
+ ["while"] = "keyword",
+ ["gsub"] = "keyword",
+ ["index"] = "keyword",
+ ["length"] = "keyword",
+ ["match"] = "keyword",
+ ["split"] = "keyword",
+ ["sprintf"] = "keyword",
+ ["sub"] = "keyword",
+ ["substr"] = "keyword",
+ ["tolower"] = "keyword",
+ ["toupper"] = "keyword",
+ ["atan2"] = "keyword",
+ ["cos"] = "keyword",
+ ["exp"] = "keyword",
+ ["int"] = "keyword",
+ ["log"] = "keyword",
+ ["rand"] = "keyword",
+ ["sin"] = "keyword",
+ ["sqrt"] = "keyword",
+ ["srand"] = "keyword",
+ ["BEGIN"] = "keyword",
+ ["END"] = "keyword",
+ ["ARGC"] = "keyword",
+ ["ARGV"] = "keyword",
+ ["FILENAME"] = "keyword",
+ ["FNR"] = "keyword",
+ ["FS"] = "keyword",
+ ["NF"] = "keyword",
+ ["NR"] = "keyword",
+ ["OFMT"] = "keyword",
+ ["OFS"] = "keyword",
+ ["ORS"] = "keyword",
+ ["RLENGTH"] = "keyword",
+ ["RS"] = "keyword",
+ ["RSTART"] = "keyword",
+ ["SUBSEP"] = "keyword",
+ ["ARGIND"] = "keyword",
+ ["BINMODE"] = "keyword",
+ ["CONVFMT"] = "keyword",
+ ["ENVIRON"] = "keyword",
+ ["ERRNO"] = "keyword",
+ ["FIELDWIDTHS"] = "keyword",
+ ["IGNORECASE"] = "keyword",
+ ["LINT"] = "keyword",
+ ["PROCINFO"] = "keyword",
+ ["RT"] = "keyword",
+ ["RLENGTH"] = "keyword",
+ ["TEXTDOMAIN"] = "keyword"
+ }
+}