diff options
author | iurii plugatarov <[email protected]> | 2024-08-02 23:01:35 +0200 |
---|---|---|
committer | iurii plugatarov <[email protected]> | 2024-08-02 23:01:35 +0200 |
commit | f4a1319352d466308cd85eb1263aef9fd2c54293 (patch) | |
tree | 335eac92b9f9f47cec3d9bf60d7699d9fa8d66d7 /create_note.lua | |
download | sketchbook.nvim-f4a1319352d466308cd85eb1263aef9fd2c54293.tar.gz |
init
Diffstat (limited to '')
-rw-r--r-- | create_note.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/create_note.lua b/create_note.lua new file mode 100644 index 0000000..d85e267 --- /dev/null +++ b/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 |