diff --git a/ftplugin/markdown.lua b/ftplugin/markdown.lua index 9b3432b..89da253 100644 --- a/ftplugin/markdown.lua +++ b/ftplugin/markdown.lua @@ -14,6 +14,13 @@ local function formatted_date() end end +local function formatted_datetime() + local current_datetime = os.date("%Y-%m-%d %HH:%MM") + if type(current_datetime) == "string" then + vim.api.nvim_put({current_datetime}, 'c', true, true) + end +end + local function markdown_headings() local bufnr = vim.api.nvim_get_current_buf() local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false) @@ -56,3 +63,4 @@ end keymap.set("n", "fdh", markdown_headings, { desc = "Grep: Markdown headings" }) keymap.set("n", "icd", formatted_date, { desc = "Insert current date" }) +keymap.set("n", "ict", formatted_datetime, { desc = "Insert current datetime" }) diff --git a/lua/custom/snippets/all.lua b/lua/custom/snippets/all.lua index 67e625c..b83e59d 100644 --- a/lua/custom/snippets/all.lua +++ b/lua/custom/snippets/all.lua @@ -7,5 +7,10 @@ ls.add_snippets("all", { f(function() return os.date("%Y-%m-%d") end) + }), + s("ict", { + f(function() + return os.date("%Y-%m-%d %H:%M") + end) }) })