aboutsummaryrefslogtreecommitdiff
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
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>
-rw-r--r--manifest.json11
-rw-r--r--plugins/language_groovy.lua108
2 files changed, 118 insertions, 1 deletions
diff --git a/manifest.json b/manifest.json
index 6a3d0ea..d14268f 100644
--- a/manifest.json
+++ b/manifest.json
@@ -99,6 +99,7 @@
"language_go": {},
"language_graphql": {},
"language_gravity": {},
+ "language_groovy": {},
"language_hare": {},
"language_haxe": {},
"language_hlsl": {},
@@ -161,7 +162,7 @@
"id": "meta_languages",
"mod_version": "3",
"type": "meta",
- "version": "0.1.12"
+ "version": "0.1.13"
},
{
"description": "Align multiple carets and selections *([clip](https://user-images.githubusercontent.com/2798487/165631951-532f8d24-d596-4dd0-9d21-ff53c71ed32f.mp4))*",
@@ -1018,6 +1019,14 @@
"version": "0.1"
},
{
+ "description": "Syntax for the [Groovy](https://en.wikipedia.org/wiki/Apache_Groovy",
+ "version": "0.1",
+ "path": "plugins/language_groovy.lua",
+ "id": "language_groovy",
+ "mod_version": "3",
+ "tags": ["language"]
+ },
+ {
"description": "Syntax for the [Hare](https://harelang.org) programming language",
"id": "language_hare",
"mod_version": "3",
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",
+ },
+}