summaryrefslogtreecommitdiff
path: root/after/ftplugin/html.lua
blob: e3ff6375018909f5442ce14484e44b7a9a3adbb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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})