From f272768544e42b69014983c7cc114d98786e997c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Rubinstein?= Date: Sun, 3 May 2020 13:54:48 +0200 Subject: [PATCH 1/4] Elixir: Fix triple-string, add support for Eex This adds support for the Eex templating that is used in the Phoenix web framework. Eex files include HTML and Elixir code, and Elixir files can include Eex in string literals marked with the `~L` prefix. Additionally this unbreaks `"""` string literals, which did not work because `"` was matched before `"""` --- rc/filetype/elixir.kak | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/rc/filetype/elixir.kak b/rc/filetype/elixir.kak index 9395acb2..de754b5c 100644 --- a/rc/filetype/elixir.kak +++ b/rc/filetype/elixir.kak @@ -8,6 +8,10 @@ hook global BufCreate .*[.](ex|exs) %{ set-option buffer filetype elixir } +hook global BufCreate .*[.]html[.]l?eex %{ + set-option buffer filetype eex +} + # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ @@ -25,18 +29,39 @@ hook -group elixir-highlight global WinSetOption filetype=elixir %{ hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/elixir } } +hook global WinSetOption filetype=eex %{ + require-module eex + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window eex-.+ } +} + +hook -group eex-highlight global WinSetOption filetype=eex %{ + add-highlighter window/eex ref eex + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/eex } +} + +provide-module eex %{ +require-module html +require-module elixir + +add-highlighter shared/eex regions +add-highlighter shared/eex/html default-region ref html +add-highlighter shared/eex/code region '<%=' '%>' ref elixir +} provide-module elixir %[ +require-module eex # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/elixir regions add-highlighter shared/elixir/code default-region group -add-highlighter shared/elixir/double_string region '"' (? Date: Sun, 3 May 2020 13:54:50 +0200 Subject: [PATCH 2/4] Elixir: add support for <% in addition to <%= --- rc/filetype/elixir.kak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc/filetype/elixir.kak b/rc/filetype/elixir.kak index de754b5c..2cff6097 100644 --- a/rc/filetype/elixir.kak +++ b/rc/filetype/elixir.kak @@ -46,7 +46,7 @@ require-module elixir add-highlighter shared/eex regions add-highlighter shared/eex/html default-region ref html -add-highlighter shared/eex/code region '<%=' '%>' ref elixir +add-highlighter shared/eex/code region '<%=?' '%>' ref elixir } provide-module elixir %[ From c5bd4a37ee43d14f5d7c0db5aba2872ed6c94d99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Rubinstein?= Date: Sun, 3 May 2020 13:54:51 +0200 Subject: [PATCH 3/4] Elixir: add support for Eex comments and quotation --- rc/filetype/elixir.kak | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rc/filetype/elixir.kak b/rc/filetype/elixir.kak index 2cff6097..8d345309 100644 --- a/rc/filetype/elixir.kak +++ b/rc/filetype/elixir.kak @@ -46,6 +46,8 @@ require-module elixir add-highlighter shared/eex regions add-highlighter shared/eex/html default-region ref html +add-highlighter shared/eex/comment region '<%#' '%>' fill comment +add-highlighter shared/eex/quote region '<%%' '%>' ref html add-highlighter shared/eex/code region '<%=?' '%>' ref elixir }