From b4a9d65bba32ab33e9ffb922f57276615fe28463 Mon Sep 17 00:00:00 2001 From: PerilousBooklet Date: Sat, 20 Jul 2024 01:21:14 +0200 Subject: Add syntax highlighting for Java constants and class names when creating objects. (#385) * Added pattern for java constants. * Added regex pattern for java constants in language_java. * Updated constants pattern. * Fixed class name pattern and tidied up some things. * Fixed redundant pattern. * Updated single-line comment pattern. * Bumped language_java version. * Updated some patterns. * Updated class name for object instance syntax. * Removed limit on number of spaces before/after the = . * Fixed previous commit. --- manifest.json | 2 +- plugins/language_java.lua | 32 +++++++++++++++++--------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/manifest.json b/manifest.json index dbabbcc..9006dc2 100644 --- a/manifest.json +++ b/manifest.json @@ -1138,7 +1138,7 @@ "tags": [ "language" ], - "version": "0.1" + "version": "0.1.1" }, { "description": "Syntax for the [jiyu](https://github.com/machinamentum/jiyu) programming language", diff --git a/plugins/language_java.lua b/plugins/language_java.lua index 30c1249..9fc5b7d 100644 --- a/plugins/language_java.lua +++ b/plugins/language_java.lua @@ -6,19 +6,21 @@ syntax.add { files = { "%.java$" }, comment = "//", patterns = { - { pattern = "//.-\n", type = "comment" }, - { pattern = { "/%*", "%*/" }, type = "comment" }, - { pattern = { '"', '"', '\\' }, type = "string" }, - { pattern = { "'", "'", '\\' }, type = "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]*f?", type = "number" }, - { pattern = "-?%.?%d+f?", type = "number" }, - { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, - { pattern = "[%a_][%w_]*%f[(]", type = "function" }, - { pattern = "[%a_][%w_]*", type = "symbol" }, + { pattern = "//.*", type = "comment" }, + { pattern = { "/%*", "%*/" }, type = "comment" }, + { pattern = { '"', '"', '\\' }, type = "string" }, + { pattern = { "'", "'", '\\' }, type = "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]*f?", type = "number" }, + { pattern = "-?%.?%d+f?", type = "number" }, + { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, + { pattern = "[%a_][%w_]*%f[(]", type = "function" }, + { regex = "(?:\\w+\\.?)+(?=\\s+\\w++\\s*\\=\\s*)", type = "function" }, -- Class name when creating an object + { regex = "[A-Z][A-Z_]+", type = "keyword2" }, -- Constants + { pattern = "[%a_][%w_]*", type = "symbol" }, }, symbols = { ["abstract"] = "keyword", @@ -80,6 +82,6 @@ syntax.add { ["true"] = "literal", ["false"] = "literal", - ["null"] = "literal", - }, + ["null"] = "literal" + } } -- cgit v1.2.3