From f24a3ab9744a3f50eb8cacc06d4ef4c5f96875db Mon Sep 17 00:00:00 2001 From: iurii plugatarov Date: Sat, 3 Aug 2024 00:19:11 +0300 Subject: fix --- lua/sketchbook/create_note.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 lua/sketchbook/create_note.lua (limited to 'lua/sketchbook/create_note.lua') diff --git a/lua/sketchbook/create_note.lua b/lua/sketchbook/create_note.lua new file mode 100644 index 0000000..d85e267 --- /dev/null +++ b/lua/sketchbook/create_note.lua @@ -0,0 +1,20 @@ +local M = {} + +function M.create_new_note() + local notes_dir = vim.g.notes_directory or "~/notes/" + local filename = os.date "%Y-%m-%d_%H-%M-%S" .. ".md" + local filepath = vim.fn.expand(notes_dir) .. filename + local title = "Title " .. os.date "%Y-%m-%d %H:%M:%S" + local template = { + "# " .. title, + "", + } + local file = io.open(filepath, "w") + for _, line in ipairs(template) do + file:write(line .. "\n") + end + file:close() + vim.cmd("edit " .. filepath) +end + +return M -- cgit 1.4.1-2-gfad0