From 219cbfebffa3d90f5750b12006a5c8c9b57e0b62 Mon Sep 17 00:00:00 2001 From: talha <-> Date: Tue, 22 Jul 2025 14:35:04 +0500 Subject: Updated config with some ergonomic changes and html snippets --- after/ftplugin/html.lua | 71 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 4 deletions(-) (limited to 'after/ftplugin/html.lua') diff --git a/after/ftplugin/html.lua b/after/ftplugin/html.lua index e3ff637..3a318c8 100644 --- a/after/ftplugin/html.lua +++ b/after/ftplugin/html.lua @@ -4,19 +4,48 @@ function Snippets(snipType, value) if snipType == "comment" then snippet = [[]] elseif snipType == "tag" then - snippet = string.format("<%s> ", value, value) + snippet = string.format("<%s>", value, value) + elseif snipType == "linebreak" then + snippet = [[
]] + elseif snipType == "hrline" then + snippet = [[
]] + elseif snipType == "link" then + snippet = string.format([[%s]], + value["url"], value["label"] + ) + elseif snipType == "pieces" then + if value == "document" then + snippet = [[ + + + + + + + + + + ]] + elseif value == "paper" then + snippet = [[ + + ]] + end end return snippet end function JumpInTag() - vim.cmd("normal! f>w") + vim.cmd("normal! f>l") end -- keymaps to insert snippets vim.keymap.set('i', "", function() WriteText(Snippets("comment")) - jumpInTag() end, {noremap=true}) vim.keymap.set('i', "", function() @@ -26,12 +55,46 @@ end, {noremap=true}) vim.keymap.set('i', "", function() WriteText(Snippets("tag", "b")) - vim.cmd("normal! f>w") JumpInTag() end, {noremap=true}) +vim.keymap.set('i', "", function() + WriteText(Snippets("linebreak")) +end, {noremap=true}) + +vim.keymap.set('i', "", function() + WriteText(Snippets("hrline")) +end, {noremap=true}) + vim.keymap.set('i', "", function() inp = vim.fn.input("Tag: ", "", "file") WriteText(Snippets("tag", inp)) JumpInTag() end, {remap=true}) + +vim.keymap.set('i', "", function() + url = vim.fn.input("URL: ", "", "file") + label = vim.fn.input("label: ", "", "file") + value = {} + value.url = url + value.label = label + WriteText( + Snippets("link", value) + ) + JumpInTag() +end, {remap=true}) + +vim.keymap.set('i', "", function() + dt = os.date("%Y/%m/%d") + WriteText(dt) +end) + +vim.keymap.set('i', "", function() + name = vim.fn.input("name: ", "", "file") + WriteLines( + StrSplit(Snippets("pieces", name), '\n') + ) +end) + + + -- cgit v1.2.3