From 11878a8d6afb6c7f47e57c75bb88aece347dfa61 Mon Sep 17 00:00:00 2001 From: "wgooch2000@gmail.com" Date: Tue, 27 Apr 2021 22:09:14 -0400 Subject: [PATCH 1/8] Added Basic Vlang Highlighter --- rc/v.kak | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 rc/v.kak diff --git a/rc/v.kak b/rc/v.kak new file mode 100644 index 0000000..86687ca --- /dev/null +++ b/rc/v.kak @@ -0,0 +1,54 @@ +## +## v.kak by Conscat +## + +# https://vlang.io +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +# Detection +# ‾‾‾‾‾‾‾‾‾ + +hook global BufCreate .+\.(v|vsh) %{ + set-option buffer filetype v +} + +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=v %{ + require-module v + add-highlighter window/v ref v +} + +hook global WinSetOption filetype=(?!v).* %{ + remove-highlighter window/v +} + +hook global BufSetOption filetype=v %{ + set-option buffer comment_line '//' +} + +provide-module v %§ + +# Highlighters +# ‾‾‾‾‾‾‾‾‾‾‾‾ + +add-highlighter shared/v regions +add-highlighter shared/v/code default-region group + +add-highlighter shared/v/back_string region '`' '`' fill string +add-highlighter shared/v/double_string region '"' (?|=|\+|-|\*|/|%|~|&|\|||\^|!|\?|:=) 0:operator + +§ From 6e84122969fe0d6ce12ee55364ae77443f2ba9fe Mon Sep 17 00:00:00 2001 From: "wgooch2000@gmail.com" Date: Wed, 28 Apr 2021 15:20:32 -0400 Subject: [PATCH 2/8] Added Static Keywords --- rc/v.kak | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/rc/v.kak b/rc/v.kak index 86687ca..60a6c19 100644 --- a/rc/v.kak +++ b/rc/v.kak @@ -17,6 +17,7 @@ hook global BufCreate .+\.(v|vsh) %{ hook global WinSetOption filetype=v %{ require-module v + set-option window static_words %opt{v_static_words} add-highlighter window/v ref v } @@ -42,13 +43,28 @@ add-highlighter shared/v/single_string region "'" (?|=|\+|-|\*|/|%|~|&|\|||\^|!|\?|:=) 0:operator +evaluate-commands %sh{ + keywords='if as asm assert atomic break const continue else embed enum fn for go import in interface is lock match module mut or pub return rlock select shared sizeof static struct type typeof union __offsetof free unsafe strlen strncmp malloc goto defer' + attributes='deprecated inline heap manualfree live direct_array_access typedef windows_stdcall console json: raw' + comptime='if else for' + + join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } + + # Add the language's grammar to the static completion list + printf %s\\n "declare-option str-list v_static_words $(join "${keywords} ${attributes} ${comptime}" ' ')" + + # Highlight keywords + printf %s " + add-highlighter shared/v/code/ regex (\b($(join "${keywords}" '|'))\b|(\[($(join "${attributes}" '|')([^\]|(^\n)]*))\])|([\$]($(join "${comptime}" '|')))(?:(?![\s+|\{|\}]))*) 0:keyword + " +} + § From 57081c8f8cd33f04deceaefe6a9076d9b0265736 Mon Sep 17 00:00:00 2001 From: "wgooch2000@gmail.com" Date: Wed, 28 Apr 2021 15:22:39 -0400 Subject: [PATCH 3/8] Decl Comment Line --- rc/v.kak | 1 + 1 file changed, 1 insertion(+) diff --git a/rc/v.kak b/rc/v.kak index 60a6c19..227a7f8 100644 --- a/rc/v.kak +++ b/rc/v.kak @@ -25,6 +25,7 @@ hook global WinSetOption filetype=(?!v).* %{ remove-highlighter window/v } +decl str comment_line hook global BufSetOption filetype=v %{ set-option buffer comment_line '//' } From 8bb74e0823738c82d71151c6857cb764eb7abe09 Mon Sep 17 00:00:00 2001 From: "wgooch2000@gmail.com" Date: Wed, 28 Apr 2021 15:27:33 -0400 Subject: [PATCH 4/8] Updated Value Regex --- rc/v.kak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc/v.kak b/rc/v.kak index 227a7f8..eb88e36 100644 --- a/rc/v.kak +++ b/rc/v.kak @@ -44,7 +44,7 @@ add-highlighter shared/v/single_string region "'" (? Date: Wed, 28 Apr 2021 15:47:12 -0400 Subject: [PATCH 5/8] Added Types and Builtins to Static Keywords --- rc/v.kak | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rc/v.kak b/rc/v.kak index eb88e36..0668239 100644 --- a/rc/v.kak +++ b/rc/v.kak @@ -46,25 +46,25 @@ add-highlighter shared/v/comment_line region '//' $ fill comment add-highlighter shared/v/code/ regex %{-?([0-9]*\.(?!0[xX]))?\b([0-9_]+|0[xX][0-9a-fA-F]+)\.?([eE][+-]?[0-9]+)?\.*\b|(none|true|false)\b} 0:value -add-highlighter shared/v/code/ regex \b(chan|err|i8|u8|byte|i16|u16|int|u32|i64|u64|f32|f64|ptr|voidptr|r|size_t|map|rune|string)\b 0:type - -add-highlighter shared/v/code/ regex \b(print|println|eprint|eprintln|exit|panic|print_backtrace|dump|rmdir_all|mkdir|exec|ls|mv)\b 0:builtin - add-highlighter shared/v/code/ regex (<|>|=|\+|-|\*|/|%|~|&|\|||\^|!|\?|:=) 0:operator evaluate-commands %sh{ keywords='if as asm assert atomic break const continue else embed enum fn for go import in interface is lock match module mut or pub return rlock select shared sizeof static struct type typeof union __offsetof free unsafe strlen strncmp malloc goto defer' attributes='deprecated inline heap manualfree live direct_array_access typedef windows_stdcall console json: raw' comptime='if else for' + types='chan err i8 u8 byte i16 u16 int u32 i64 u64 f32 f64 ptr voidptr r size_t map rune string' + functions='print println eprint eprintln exit panic print_backtrace dump' join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } # Add the language's grammar to the static completion list - printf %s\\n "declare-option str-list v_static_words $(join "${keywords} ${attributes} ${comptime}" ' ')" + printf %s\\n "declare-option str-list v_static_words $(join "${keywords} ${attributes} ${comptime} ${types} ${functions}" ' ')" # Highlight keywords printf %s " add-highlighter shared/v/code/ regex (\b($(join "${keywords}" '|'))\b|(\[($(join "${attributes}" '|')([^\]|(^\n)]*))\])|([\$]($(join "${comptime}" '|')))(?:(?![\s+|\{|\}]))*) 0:keyword + add-highlighter shared/v/code/ regex \b($(join "${types}" '|'))\b 0:type + add-highlighter shared/v/code/ regex \b($(join "${functions}" '|'))\b 0:builtin " } From 0f81c86a76b041fffa018c1afa982924c51afb29 Mon Sep 17 00:00:00 2001 From: "wgooch2000@gmail.com" Date: Sun, 2 May 2021 00:33:13 -0400 Subject: [PATCH 6/8] Various Improvements --- rc/v.kak | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rc/v.kak b/rc/v.kak index 0668239..4454041 100644 --- a/rc/v.kak +++ b/rc/v.kak @@ -50,9 +50,9 @@ add-highlighter shared/v/code/ regex (<|>|=|\+|-|\*|/|%|~|&|\|||\^|!|\?|:=) 0:op evaluate-commands %sh{ keywords='if as asm assert atomic break const continue else embed enum fn for go import in interface is lock match module mut or pub return rlock select shared sizeof static struct type typeof union __offsetof free unsafe strlen strncmp malloc goto defer' - attributes='deprecated inline heap manualfree live direct_array_access typedef windows_stdcall console json: raw' + attributes='deprecated inline heap manualfree live direct_array_access typedef windows_stdcall console json: raw required' comptime='if else for' - types='chan err i8 u8 byte i16 u16 int u32 i64 u64 f32 f64 ptr voidptr r size_t map rune string' + types='chan err i8 u8 byte i16 u16 int u32 i64 u64 f32 f64 ptr voidptr r size_t map rune string bool' functions='print println eprint eprintln exit panic print_backtrace dump' join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } @@ -62,7 +62,7 @@ evaluate-commands %sh{ # Highlight keywords printf %s " - add-highlighter shared/v/code/ regex (\b($(join "${keywords}" '|'))\b|(\[($(join "${attributes}" '|')([^\]|(^\n)]*))\])|([\$]($(join "${comptime}" '|')))(?:(?![\s+|\{|\}]))*) 0:keyword + add-highlighter shared/v/code/ regex (\b((? Date: Sun, 2 May 2021 15:14:04 -0400 Subject: [PATCH 7/8] More Minor Improvements --- rc/v.kak | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rc/v.kak b/rc/v.kak index 4454041..f73666f 100644 --- a/rc/v.kak +++ b/rc/v.kak @@ -8,7 +8,7 @@ # Detection # ‾‾‾‾‾‾‾‾‾ -hook global BufCreate .+\.(v|vsh) %{ +hook global BufCreate .+\.(v|vv|vsh) %{ set-option buffer filetype v } @@ -50,9 +50,9 @@ add-highlighter shared/v/code/ regex (<|>|=|\+|-|\*|/|%|~|&|\|||\^|!|\?|:=) 0:op evaluate-commands %sh{ keywords='if as asm assert atomic break const continue else embed enum fn for go import in interface is lock match module mut or pub return rlock select shared sizeof static struct type typeof union __offsetof free unsafe strlen strncmp malloc goto defer' - attributes='deprecated inline heap manualfree live direct_array_access typedef windows_stdcall console json: raw required' + attributes='deprecated inline heap manualfree live direct_array_access typedef windows_stdcall console json: raw required export if keep_args_alive unsafe' comptime='if else for' - types='chan err i8 u8 byte i16 u16 int u32 i64 u64 f32 f64 ptr voidptr r size_t map rune string bool' + types='chan err i8 u8 byte i16 u16 int u32 i64 u64 f32 f64 ptr voidptr size_t map rune string bool' functions='print println eprint eprintln exit panic print_backtrace dump' join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } From 4c35dd6d05f71f5a67906148253b2d669227933c Mon Sep 17 00:00:00 2001 From: "wgooch2000@gmail.com" Date: Tue, 4 May 2021 22:17:05 -0400 Subject: [PATCH 8/8] Fixed Comments --- rc/v.kak | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rc/v.kak b/rc/v.kak index f73666f..fa02adb 100644 --- a/rc/v.kak +++ b/rc/v.kak @@ -1,4 +1,5 @@ ## + ## v.kak by Conscat ## @@ -25,9 +26,11 @@ hook global WinSetOption filetype=(?!v).* %{ remove-highlighter window/v } -decl str comment_line +declare-option str comment_line hook global BufSetOption filetype=v %{ set-option buffer comment_line '//' + set-option buffer comment_block_begin '/*' + set-option buffer comment_block_end '*/' } provide-module v %§