aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrxi <rxi@users.noreply.github.com>2020-05-22 23:19:11 +0100
committerrxi <rxi@users.noreply.github.com>2020-05-22 23:19:11 +0100
commit408dc90b6d7e0d05c5170d16189c7557bf1aeb6d (patch)
treecaf9b908812237e147331c282e8e2331fa79b7e4
parent9be88f889536e82a22a304f5a576624f33b9bf10 (diff)
downloadlite-xl-plugins-408dc90b6d7e0d05c5170d16189c7557bf1aeb6d.tar.gz
lite-xl-plugins-408dc90b6d7e0d05c5170d16189c7557bf1aeb6d.zip
Added HTML tag support to `lfautoinsert`
-rw-r--r--plugins/lfautoinsert.lua5
1 files changed, 4 insertions, 1 deletions
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"] = "</$TEXT>",
}
@@ -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")