aboutsummaryrefslogtreecommitdiff
path: root/plugins/language_groovy.lua
diff options
context:
space:
mode:
authorPerilousBooklet <raffaele.orabona@protonmail.com>2024-04-15 19:35:53 +0200
committerGitHub <noreply@github.com>2024-04-15 19:35:53 +0200
commitc8f9e091ba6ce2d3e9ecc94138187748152ac336 (patch)
tree68478baea22772baa53b61386a1d36a88ea6b1a9 /plugins/language_groovy.lua
parentbbd7e44d6183cf37b62df4497edcfebf58853953 (diff)
downloadlite-xl-plugins-c8f9e091ba6ce2d3e9ecc94138187748152ac336.tar.gz
lite-xl-plugins-c8f9e091ba6ce2d3e9ecc94138187748152ac336.zip
Add Groovy syntax highlighting support. (#410)
* WIP: added groovy keywords and some other things. * Tidied up some things. * Added block comment. * Added some more comments. * Added a few patterns. * Fixed big types. * Added entry to meta-languages package. * Bumped meta_languages version. * Removed shebang pattern. * Update manifest.json --------- Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
Diffstat (limited to 'plugins/language_groovy.lua')
-rw-r--r--plugins/language_groovy.lua108
1 files changed, 108 insertions, 0 deletions
diff --git a/plugins/language_groovy.lua b/plugins/language_groovy.lua
new file mode 100644
index 0000000..8a3c5b8
--- /dev/null
+++ b/plugins/language_groovy.lua
@@ -0,0 +1,108 @@
+-- mod-version:3
+local syntax = require "core.syntax"
+
+syntax.add {
+ name = "Groovy",
+ files = { "%.groovy$" },
+ comment = "//",
+ block_comment = { "/*", "*/" },
+ patterns = {
+ { pattern = "//.*", type = "comment" }, -- Single-line comment
+ { pattern = { "/%*", "%*/" }, type = "comment" }, -- Multi-line comment
+ { pattern = { '"', '"', '\\' }, type = "string" }, -- String, double quotes
+ { pattern = { "'", "'", '\\' }, type = "string" }, -- String, apices
+ { pattern = { "%/", "%/", '\\' }, type = "string" }, -- Slashy string
+ { pattern = { "%$%/", "%/%$", '\\' }, type = "string" }, -- Dollar slashy string
+ { pattern = "'\\x%x?%x?%x?%x'", type = "string" }, -- character hexadecimal escape sequence
+ { pattern = "'\\u%x%x%x%x'", type = "string" }, -- character unicode escape sequence
+ { pattern = "'\\?.'", type = "string" }, -- character literal
+ { pattern = "-?0x%x+", type = "number" }, -- ?
+ { pattern = "-?%d+[%d%.eE]*[a-zA-Z]?", type = "number" }, -- ?
+ { pattern = "-?%.?%d+", type = "number" }, -- ?
+ { pattern = "-?[%d_+]+[a-zA-Z]?", type = "number" }, -- ?
+ { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, -- Operators
+ { pattern = "[%a_][%w_]*%f[(]", type = "function" }, -- Function/Class/Method/...
+ { pattern = "[%a_][%w_]*%f[%[]", type = "function" }, -- Custom Type
+ { regex = "[A-Z]+_?[A-Z]+", type = "keyword2" }, -- Constants
+ { pattern = "[%a_][%w_]*", type = "symbol" }, -- ?
+ { pattern = "[a-zA-Z]+%.+", type = "function" }, -- Lib path
+ -- TODO: .class.
+ },
+ symbols = {
+ -- Reserved keywords
+ ["abstract"] = "keyword",
+ ["assert"] = "keyword",
+ ["break"] = "keyword",
+ ["case"] = "keyword",
+ ["catch"] = "keyword",
+ ["class"] = "keyword",
+ ["const"] = "keyword",
+ ["continue"] = "keyword",
+ ["def"] = "keyword",
+ ["default"] = "keyword",
+ ["do"] = "keyword",
+ ["else"] = "keyword",
+ ["enum"] = "keyword",
+ ["extends"] = "keyword",
+ ["final"] = "keyword",
+ ["finally"] = "keyword",
+ ["for"] = "keyword",
+ ["goto"] = "keyword",
+ ["if"] = "keyword",
+ ["implements"] = "keyword",
+ ["import"] = "keyword",
+ ["instanceof"] = "keyword",
+ ["interface"] = "keyword",
+ ["native"] = "keyword",
+ ["new"] = "keyword",
+ ["non-sealed"] = "keyword",
+ ["package"] = "keyword",
+ ["public"] = "keyword",
+ ["protected"] = "keyword",
+ ["private"] = "keyword",
+ ["return"] = "keyword",
+ ["static"] = "keyword",
+ ["strictfp"] = "keyword",
+ ["super"] = "keyword",
+ ["switch"] = "keyword",
+ ["synchronizedthis"] = "keyword",
+ ["threadsafe"] = "keyword",
+ ["throw"] = "keyword",
+ ["throws"] = "keyword",
+ ["transient"] = "keyword",
+ ["try"] = "keyword",
+ ["while"] = "keyword",
+
+ -- Contextual keywords
+ ["as"] = "keyword",
+ ["in"] = "keyword",
+ ["permitsrecord"] = "keyword",
+ ["sealed"] = "keyword",
+ ["trait"] = "keyword",
+ ["var"] = "keyword",
+ ["yields"] = "keyword",
+
+ -- ?
+ ["true"] = "literal",
+ ["false"] = "literal",
+ ["null"] = "literal",
+ ["boolean"] = "literal",
+
+ -- Types
+ ["char"] = "keyword",
+ ["byte"] = "keyword",
+ ["short"] = "keyword",
+ ["int"] = "keyword",
+ ["long"] = "keyword",
+ ["float"] = "keyword",
+ ["double"] = "keyword",
+
+ ["Integer"] = "keyword",
+ ["BigInteger"] = "keyword",
+ ["Long"] = "keyword",
+ ["Float"] = "keyword",
+ ["BigDecimal"] = "keyword",
+ ["Double"] = "keyword",
+ ["String"] = "keyword",
+ },
+}