From 70fe2441aa025243e29d47aabe1b6674c4e0ed71 Mon Sep 17 00:00:00 2001
From: talha
Date: Thu, 23 Jul 2026 21:12:35 +0500
Subject: Updated config
---
after/ftplugin/html.lua | 138 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 138 insertions(+)
create mode 100644 after/ftplugin/html.lua
(limited to 'after')
diff --git a/after/ftplugin/html.lua b/after/ftplugin/html.lua
new file mode 100644
index 0000000..bfc21d4
--- /dev/null
+++ b/after/ftplugin/html.lua
@@ -0,0 +1,138 @@
+-- html snippets
+function Snippets(snipType, value)
+ snippet = ""
+ if snipType == "comment" then
+ snippet = [[]]
+ elseif snipType == "tag" then
+ snippet = string.format("<%s>%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 == "init" then
+ snippet = [[
+
+
+
+
+
+
+
+
+
+ ]]
+ elseif value == "paper" then
+ snippet = [[
+
+ ]]
+ elseif value == "cjHeader" then
+ snippet = string.format([[
+
+
+ ]], os.date("%Y/%m/%d"))
+ end
+ end
+ return snippet
+end
+
+function JumpInTag()
+ vim.cmd("normal! f>l")
+end
+
+-- keymaps to insert snippets
+vim.keymap.set('i', "", function()
+ WriteText(Snippets("comment"))
+end, {noremap=true})
+
+vim.keymap.set('i', "", function()
+ WriteText(Snippets("tag", "i"))
+ JumpInTag()
+end, {noremap=true})
+
+vim.keymap.set('i', "", function()
+ WriteText(Snippets("tag", "b"))
+ 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)
+
+function WriteText(toWrite)
+ if not toWrite then
+ return
+ end
+ local posYX = vim.api.nvim_win_get_cursor(0)
+ vim.api.nvim_buf_set_text(0, posYX[1]-1, posYX[2], posYX[1]-1, posYX[2], { toWrite })
+end
+
+function WriteLines(toWrite)
+ if not toWrite then
+ return
+ end
+ local posYX = vim.api.nvim_win_get_cursor(0)
+ print(posYX[0], posYX[1], posYX[2])
+ vim.api.nvim_buf_set_lines(0, posYX[1]-1, posYX[1]-1, true, toWrite)
+end
+
+function StrSplit(inpstr, sep)
+ if not sep then
+ sep = "%s"
+ end
+ local str_list = {}
+ for str in string.gmatch(inpstr, "([^"..sep.."]+)") do
+ table.insert(str_list, str)
+ end
+ return str_list
+end
--
cgit v1.2.3