From 408dc90b6d7e0d05c5170d16189c7557bf1aeb6d Mon Sep 17 00:00:00 2001 From: rxi Date: Fri, 22 May 2020 23:19:11 +0100 Subject: Added HTML tag support to `lfautoinsert` --- plugins/lfautoinsert.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'plugins/lfautoinsert.lua') diff --git a/plugins/lfautoinsert.lua b/plugins/lfautoinsert.lua index e395eac..067b414 100644 --- a/plugins/lfautoinsert.lua +++ b/plugins/lfautoinsert.lua @@ -17,6 +17,7 @@ config.autoinsert_map = { ["%f[%w]else%s*\n"] = "end", ["%f[%w]repeat%s*\n"] = "until", ["%f[%w]function.*%)%s*\n"] = "end", + ["^%s*<([^/][^%s>]*)[^>]*>%s*\n"] = "", } @@ -35,11 +36,13 @@ command.add("core.docview", { local text = doc.lines[line - 1] for ptn, close in pairs(config.autoinsert_map) do - if text:find(ptn) then + local s, _, str = text:find(ptn) + if s then if close and col == #doc.lines[line] and indent_size(doc, line + 1) <= indent_size(doc, line - 1) then + close = str and close:gsub("$TEXT", str) or close command.perform("doc:newline") core.active_view:on_text_input(close) command.perform("doc:move-to-previous-line") -- cgit v1.2.3