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/cpp.lua | 2 +- after/ftplugin/html.lua | 71 +++++++++++++++++++++++++++++++++++++++++++++--- after/ftplugin/netrw.lua | 3 ++ 3 files changed, 71 insertions(+), 5 deletions(-) (limited to 'after/ftplugin') diff --git a/after/ftplugin/cpp.lua b/after/ftplugin/cpp.lua index c933d5b..f3bcf24 100644 --- a/after/ftplugin/cpp.lua +++ b/after/ftplugin/cpp.lua @@ -1 +1 @@ -vim.opt.cinoptions = 'l1' +vim.opt.cinoptions = 'l1(0' 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) + + + diff --git a/after/ftplugin/netrw.lua b/after/ftplugin/netrw.lua index 50d4181..3036211 100644 --- a/after/ftplugin/netrw.lua +++ b/after/ftplugin/netrw.lua @@ -1,3 +1,6 @@ +vim.opt.number = true +vim.opt.relativenumber = true + vim.keymap.set('n', "h", "NetrwBrowseUpDir", { buffer = true}) vim.keymap.set('n', "l", "NetrwLocalBrowseCheck", { buffer = true}) -- cgit v1.2.3