From 12d2371cb15350ab8e211afde2e41513909267f9 Mon Sep 17 00:00:00 2001 From: Jack Clarke Date: Mon, 11 Apr 2022 17:37:55 +0000 Subject: [PATCH] Add syntax highlighting for Kakoune (#240) --- highlighters/gwion.kak | 73 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 highlighters/gwion.kak diff --git a/highlighters/gwion.kak b/highlighters/gwion.kak new file mode 100644 index 00000000..b0974bb2 --- /dev/null +++ b/highlighters/gwion.kak @@ -0,0 +1,73 @@ +# Gwion syntax highlighting for kakoune + +provide-module -override gwion %{ + add-highlighter shared/gwion regions + add-highlighter shared/gwion/other default-region group + + # comment + add-highlighter shared/gwion/comment region '#!' '$' group + add-highlighter shared/gwion/comment/ fill comment + + # preprocessor + add-highlighter shared/gwion/preproc region '#' '$' group + add-highlighter shared/gwion/preproc/ fill module + + evaluate-commands %sh{ + keywords=' + operator extends global abstract + final + default late if else + break continue return while do + until repeat for foreach match + where when case varloop + defer try perform handle retry + fun function typedef distinct funptr + new spork fork' + + attributes='const var static private public protect variadic template samp ms second minute delay' + types='auto int float void Object Shred Event' + values='true false none this now me adc dac maybe' + builtins='__file__ __line__ __func__' + entities='class struct trait union enum' + operators='\\\? : \$ @ \\\+ - \\\* / % \~ \< \> \\\^ \\\| \& ! =' + + join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } + + printf %s\\n "declare-option str-list gwion_static_words $(join "${keywords} ${attributes} ${types} ${values} ${decorators}" ' ')" + + printf %s " + add-highlighter shared/gwion/other/ regex \b($(join "${keywords}" '|'))\b 0:keyword + add-highlighter shared/gwion/other/ regex \b($(join "${attributes} ${entities}" '|'))\b 0:attribute + add-highlighter shared/gwion/other/ regex \b($(join "${types}" '|'))\b 0:type + add-highlighter shared/gwion/other/ regex \b($(join "${values}" '|'))\b 0:value + add-highlighter shared/gwion/other/ regex \b($(join "${builtins}" '|'))\b 0:builtin + add-highlighter shared/gwion/other/ regex ($(join "${operators}" '|')) 0:operator + " + } + + # literals + add-highlighter shared/gwion/other/ regex "\d*" 0:value + add-highlighter shared/gwion/other/ regex "\B'((\\.)|[^'\\])'\B" 0:value + + # string + add-highlighter shared/gwion/string region '"' (?