From 5e6077acc26844659298d8ed78c5b7941de82f04 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 30 Oct 2017 16:52:07 +1100 Subject: [PATCH] html.kak: Change align hook to only run after inserting '>' Improve the hook to support nesting of tags as well. --- rc/base/html.kak | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rc/base/html.kak b/rc/base/html.kak index ca7132f2..cd43e66d 100644 --- a/rc/base/html.kak +++ b/rc/base/html.kak @@ -44,12 +44,12 @@ def -hidden html-filter-around-selections %{ try %{ exec -draft -itersel s \h+$ d } } -def -hidden html-indent-on-char %{ - eval -draft -itersel %{ +def -hidden html-indent-on-greater-than %[ + eval -draft -itersel %[ # align closing tag to opening when alone on a line - try %{ exec -draft s ^\h+$ 1 s \A|.\z 1 } - } -} + try %[ exec -draft s ^\h+/(\w+)$ {c1,/1 s \A|.\z 1 ] + ] +] def -hidden html-indent-on-new-line %{ eval -draft -itersel %{ @@ -69,7 +69,7 @@ hook -group html-highlight global WinSetOption filetype=(?:html|xml) %{ add-high hook global WinSetOption filetype=(?:html|xml) %{ hook window InsertEnd .* -group html-hooks html-filter-around-selections - hook window InsertChar .* -group html-indent html-indent-on-char + hook window InsertChar '>' -group html-indent html-indent-on-greater-than hook window InsertChar \n -group html-indent html-indent-on-new-line }