From f90a28a62d9fd5e2bba0f3ed25b0aa846a92dfc4 Mon Sep 17 00:00:00 2001 From: Francesco La Camera Date: Wed, 18 Sep 2024 23:05:39 +0200 Subject: [PATCH] highlight: add support for java (#244) --- highlight/java.v | 65 +++++++++++++++++++++++++++++++++++++++++++++++ highlight/langs.v | 3 ++- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 highlight/java.v diff --git a/highlight/java.v b/highlight/java.v new file mode 100644 index 00000000..a66da95c --- /dev/null +++ b/highlight/java.v @@ -0,0 +1,65 @@ +// Designed for Java 5.0+ +module highlight + +fn init_java() Lang { + return Lang{ + name: 'Java' + lang_extensions: ['java'] + line_comments: '//' + mline_comments: ['/*', '*/'] + string_start: ['"', "'"] + color: '#f1e05a' + keywords: [ + 'abstract', + 'continue', + 'for', + 'new', + 'switch', + 'assert', + 'default', + 'goto', + 'package', + 'synchronized', + 'boolean', + 'do', + 'if', + 'private', + 'this', + 'break', + 'double', + 'implements', + 'protected', + 'throw', + 'byte', + 'else', + 'import', + 'public', + 'throws', + 'case', + 'enum', + 'instanceof', + 'return', + 'transient', + 'catch', + 'extends', + 'int', + 'short', + 'try', + 'char', + 'final', + 'interface', + 'static', + 'void', + 'class', + 'finally', + 'long', + 'strictfp', + 'volatile', + 'const', + 'float', + 'native', + 'super', + 'while', + ] + } +} diff --git a/highlight/langs.v b/highlight/langs.v index 6de4a6df..3e211998 100644 --- a/highlight/langs.v +++ b/highlight/langs.v @@ -33,7 +33,7 @@ pub fn extension_to_lang(ext string) !Lang { } fn init_langs() []Lang { - mut langs_ := []Lang{cap: 10} + mut langs_ := []Lang{cap: 16} langs_ << init_c() langs_ << init_v() langs_ << init_js() @@ -41,6 +41,7 @@ fn init_langs() []Lang { langs_ << init_go() langs_ << init_cpp() langs_ << init_d() + langs_ << init_java() langs_ << init_py() langs_ << init_ts() return langs_