From 43d9f59fda3235227590fdd305e3c0f9e3b80b41 Mon Sep 17 00:00:00 2001 From: Hugo Musso Gualandi Date: Wed, 28 Jul 2021 19:10:43 -0300 Subject: [PATCH 1/7] lua.kak: keyword should have higher priority than function call Currently, the "return" in `return {}` is highlighted as a function call, instead of being highlighted as a keyword --- rc/filetype/lua.kak | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rc/filetype/lua.kak b/rc/filetype/lua.kak index afc812d0..ce992e5a 100644 --- a/rc/filetype/lua.kak +++ b/rc/filetype/lua.kak @@ -46,14 +46,14 @@ add-highlighter shared/lua/double_string region '"' (?=?|\.\.|\.\.\.|#) 0:operator add-highlighter shared/lua/code/builtin regex \b(_G|_E)\b 0:builtin add-highlighter shared/lua/code/module regex \b(_G|_E)\b 0:module add-highlighter shared/lua/code/attribute regex \b(local)\b 0:attribute -add-highlighter shared/lua/code/function_declaration regex \b(?:function\h+)(?:\w+\h*\.\h*)*([a-zA-Z_]\w*)\( 1:function -add-highlighter shared/lua/code/function_call regex \b([a-zA-Z_]\w*)\h*(?=[\(\{]) 1:function # Commands # ‾‾‾‾‾‾‾‾ From ceb3f55f3c26c6fd7bf2951ddb6e5e23d71b42f1 Mon Sep 17 00:00:00 2001 From: Hugo Musso Gualandi Date: Wed, 28 Jul 2021 19:11:56 -0300 Subject: [PATCH 2/7] lua.kak: the builtin is called _ENV, not _E The Lua highlighting was highlighing `_E` instead of `_ENV` --- rc/filetype/lua.kak | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rc/filetype/lua.kak b/rc/filetype/lua.kak index ce992e5a..9155c8a1 100644 --- a/rc/filetype/lua.kak +++ b/rc/filetype/lua.kak @@ -51,8 +51,8 @@ add-highlighter shared/lua/code/function_call regex \b([a-zA-Z_]\w*)\h*(?=[\(\{] add-highlighter shared/lua/code/keyword regex \b(and|break|do|else|elseif|end|for|function|goto|if|in|not|or|repeat|return|then|until|while)\b 0:keyword add-highlighter shared/lua/code/value regex \b(false|nil|true|[0-9]+(:?\.[0-9])?(:?[eE]-?[0-9]+)?|0x[0-9a-fA-F])\b 0:value add-highlighter shared/lua/code/operator regex (\+|-|\*|/|%|\^|==?|~=|<=?|>=?|\.\.|\.\.\.|#) 0:operator -add-highlighter shared/lua/code/builtin regex \b(_G|_E)\b 0:builtin -add-highlighter shared/lua/code/module regex \b(_G|_E)\b 0:module +add-highlighter shared/lua/code/builtin regex \b(_G|_ENV)\b 0:builtin +add-highlighter shared/lua/code/module regex \b(_G|_ENV)\b 0:module add-highlighter shared/lua/code/attribute regex \b(local)\b 0:attribute # Commands From 3621a98170c9168f0d45cb17ac96435634d169f9 Mon Sep 17 00:00:00 2001 From: Hugo Musso Gualandi Date: Wed, 28 Jul 2021 19:14:18 -0300 Subject: [PATCH 3/7] lua.kak: Treat "local" as a normal keyword --- rc/filetype/lua.kak | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rc/filetype/lua.kak b/rc/filetype/lua.kak index 9155c8a1..bfc7a35a 100644 --- a/rc/filetype/lua.kak +++ b/rc/filetype/lua.kak @@ -48,12 +48,11 @@ add-highlighter shared/lua/comment region '--' $ fill com add-highlighter shared/lua/code/function_declaration regex \b(?:function\h+)(?:\w+\h*\.\h*)*([a-zA-Z_]\w*)\( 1:function add-highlighter shared/lua/code/function_call regex \b([a-zA-Z_]\w*)\h*(?=[\(\{]) 1:function -add-highlighter shared/lua/code/keyword regex \b(and|break|do|else|elseif|end|for|function|goto|if|in|not|or|repeat|return|then|until|while)\b 0:keyword +add-highlighter shared/lua/code/keyword regex \b(and|break|do|else|elseif|end|for|function|goto|if|in|local|not|or|repeat|return|then|until|while)\b 0:keyword add-highlighter shared/lua/code/value regex \b(false|nil|true|[0-9]+(:?\.[0-9])?(:?[eE]-?[0-9]+)?|0x[0-9a-fA-F])\b 0:value add-highlighter shared/lua/code/operator regex (\+|-|\*|/|%|\^|==?|~=|<=?|>=?|\.\.|\.\.\.|#) 0:operator add-highlighter shared/lua/code/builtin regex \b(_G|_ENV)\b 0:builtin add-highlighter shared/lua/code/module regex \b(_G|_ENV)\b 0:module -add-highlighter shared/lua/code/attribute regex \b(local)\b 0:attribute # Commands # ‾‾‾‾‾‾‾‾ From d3d3c77ab901f3b40071532e268a610ecbab3da3 Mon Sep 17 00:00:00 2001 From: Hugo Musso Gualandi Date: Wed, 28 Jul 2021 19:22:14 -0300 Subject: [PATCH 4/7] lua.kak: highlight Lua 5.4 variable attributes --- rc/filetype/lua.kak | 1 + 1 file changed, 1 insertion(+) diff --git a/rc/filetype/lua.kak b/rc/filetype/lua.kak index bfc7a35a..2fb0148c 100644 --- a/rc/filetype/lua.kak +++ b/rc/filetype/lua.kak @@ -53,6 +53,7 @@ add-highlighter shared/lua/code/value regex \b(false|nil|true|[0-9]+(:?\.[0-9])? add-highlighter shared/lua/code/operator regex (\+|-|\*|/|%|\^|==?|~=|<=?|>=?|\.\.|\.\.\.|#) 0:operator add-highlighter shared/lua/code/builtin regex \b(_G|_ENV)\b 0:builtin add-highlighter shared/lua/code/module regex \b(_G|_ENV)\b 0:module +add-highlighter shared/lua/code/attribute regex \B(<[a-zA-Z_]\w*>)\B 0:attribute # Commands # ‾‾‾‾‾‾‾‾ From be09ff4680096ac79f88f3e1808fd491704620ca Mon Sep 17 00:00:00 2001 From: Hugo Musso Gualandi Date: Wed, 28 Jul 2021 19:48:09 -0300 Subject: [PATCH 5/7] lua.kak: highlight and/or/not as operators --- rc/filetype/lua.kak | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rc/filetype/lua.kak b/rc/filetype/lua.kak index 2fb0148c..1a9da139 100644 --- a/rc/filetype/lua.kak +++ b/rc/filetype/lua.kak @@ -48,9 +48,9 @@ add-highlighter shared/lua/comment region '--' $ fill com add-highlighter shared/lua/code/function_declaration regex \b(?:function\h+)(?:\w+\h*\.\h*)*([a-zA-Z_]\w*)\( 1:function add-highlighter shared/lua/code/function_call regex \b([a-zA-Z_]\w*)\h*(?=[\(\{]) 1:function -add-highlighter shared/lua/code/keyword regex \b(and|break|do|else|elseif|end|for|function|goto|if|in|local|not|or|repeat|return|then|until|while)\b 0:keyword +add-highlighter shared/lua/code/keyword regex \b(break|do|else|elseif|end|for|function|goto|if|in|local|repeat|return|then|until|while)\b 0:keyword add-highlighter shared/lua/code/value regex \b(false|nil|true|[0-9]+(:?\.[0-9])?(:?[eE]-?[0-9]+)?|0x[0-9a-fA-F])\b 0:value -add-highlighter shared/lua/code/operator regex (\+|-|\*|/|%|\^|==?|~=|<=?|>=?|\.\.|\.\.\.|#) 0:operator +add-highlighter shared/lua/code/operator regex (\+|-|\*|/|%|\^|==?|~=|<=?|>=?|\.\.|\.\.\.|#|\band\b|\bor\b|\bnot\b) 0:operator add-highlighter shared/lua/code/builtin regex \b(_G|_ENV)\b 0:builtin add-highlighter shared/lua/code/module regex \b(_G|_ENV)\b 0:module add-highlighter shared/lua/code/attribute regex \B(<[a-zA-Z_]\w*>)\B 0:attribute From dc88220e4aa98430afadb210c46a6e5b5b9b8e67 Mon Sep 17 00:00:00 2001 From: Hugo Musso Gualandi Date: Wed, 4 Aug 2021 13:19:53 -0300 Subject: [PATCH 6/7] Recognize and/or/not in a separate rule This is the usual style --- rc/filetype/lua.kak | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rc/filetype/lua.kak b/rc/filetype/lua.kak index 1a9da139..7d94e6fe 100644 --- a/rc/filetype/lua.kak +++ b/rc/filetype/lua.kak @@ -50,7 +50,8 @@ add-highlighter shared/lua/code/function_declaration regex \b(?:function\h+)(?:\ add-highlighter shared/lua/code/function_call regex \b([a-zA-Z_]\w*)\h*(?=[\(\{]) 1:function add-highlighter shared/lua/code/keyword regex \b(break|do|else|elseif|end|for|function|goto|if|in|local|repeat|return|then|until|while)\b 0:keyword add-highlighter shared/lua/code/value regex \b(false|nil|true|[0-9]+(:?\.[0-9])?(:?[eE]-?[0-9]+)?|0x[0-9a-fA-F])\b 0:value -add-highlighter shared/lua/code/operator regex (\+|-|\*|/|%|\^|==?|~=|<=?|>=?|\.\.|\.\.\.|#|\band\b|\bor\b|\bnot\b) 0:operator +add-highlighter shared/lua/code/symbolic_operator regex (\+|-|\*|/|%|\^|==?|~=|<=?|>=?|\.\.|\.\.\.|#) 0:operator +add-highlighter shared/lua/code/keyword_operator regex \b(and|or|not)\b 0:operator add-highlighter shared/lua/code/builtin regex \b(_G|_ENV)\b 0:builtin add-highlighter shared/lua/code/module regex \b(_G|_ENV)\b 0:module add-highlighter shared/lua/code/attribute regex \B(<[a-zA-Z_]\w*>)\B 0:attribute From 4f0f3eefd07fccf9e499b82da85eb97cb1dbbe10 Mon Sep 17 00:00:00 2001 From: Hugo Musso Gualandi Date: Wed, 4 Aug 2021 13:21:31 -0300 Subject: [PATCH 7/7] Remove a duplicate highligher rule for _G/_ENV --- rc/filetype/lua.kak | 1 - 1 file changed, 1 deletion(-) diff --git a/rc/filetype/lua.kak b/rc/filetype/lua.kak index 7d94e6fe..090a94f4 100644 --- a/rc/filetype/lua.kak +++ b/rc/filetype/lua.kak @@ -52,7 +52,6 @@ add-highlighter shared/lua/code/keyword regex \b(break|do|else|elseif|end|for|fu add-highlighter shared/lua/code/value regex \b(false|nil|true|[0-9]+(:?\.[0-9])?(:?[eE]-?[0-9]+)?|0x[0-9a-fA-F])\b 0:value add-highlighter shared/lua/code/symbolic_operator regex (\+|-|\*|/|%|\^|==?|~=|<=?|>=?|\.\.|\.\.\.|#) 0:operator add-highlighter shared/lua/code/keyword_operator regex \b(and|or|not)\b 0:operator -add-highlighter shared/lua/code/builtin regex \b(_G|_ENV)\b 0:builtin add-highlighter shared/lua/code/module regex \b(_G|_ENV)\b 0:module add-highlighter shared/lua/code/attribute regex \B(<[a-zA-Z_]\w*>)\B 0:attribute