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] 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 '"' (?