diff options
Diffstat (limited to 'after/ftplugin')
-rw-r--r-- | after/ftplugin/html.lua | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/after/ftplugin/html.lua b/after/ftplugin/html.lua new file mode 100644 index 0000000..e3ff637 --- /dev/null +++ b/after/ftplugin/html.lua @@ -0,0 +1,37 @@ +-- html snippets +function Snippets(snipType, value) + snippet = "" + if snipType == "comment" then + snippet = [[<!-- -->]] + elseif snipType == "tag" then + snippet = string.format("<%s> </%s>", value, value) + end + return snippet +end + +function JumpInTag() + vim.cmd("normal! f>w") +end + +-- keymaps to insert snippets +vim.keymap.set('i', "<M-s><M-c>", function() + WriteText(Snippets("comment")) + jumpInTag() +end, {noremap=true}) + +vim.keymap.set('i', "<M-s><M-i>", function() + WriteText(Snippets("tag", "i")) + JumpInTag() +end, {noremap=true}) + +vim.keymap.set('i', "<M-s><M-b>", function() + WriteText(Snippets("tag", "b")) + vim.cmd("normal! f>w") + JumpInTag() +end, {noremap=true}) + +vim.keymap.set('i', "<M-s><M-t>", function() + inp = vim.fn.input("Tag: ", "", "file") + WriteText(Snippets("tag", inp)) + JumpInTag() +end, {remap=true}) |