diary: create year folder if missing
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
local diary_open = function(opts)
|
||||
local date = opts.args ~= '' and opts.args or os.date('%Y-%m-%d')
|
||||
local year, month = date:match('(%d%d%d%d)-(%d%d)')
|
||||
local file = string.format('~/.diary/asciidoc/%s/diary-%s-%s.adoc', year, year, month)
|
||||
local folder = string.format('~/.diary/asciidoc/%s', year)
|
||||
vim.fn.mkdir(folder, "p")
|
||||
local file = string.format('%s/diary-%s-%s.adoc', folder, year, month)
|
||||
print("file is:", file)
|
||||
vim.cmd('e ' .. file)
|
||||
vim.cmd('normal! G')
|
||||
vim.cmd('normal! G') -- go to end of file
|
||||
|
||||
-- NOTE.2025-06-08 [1] and [2] should be replaced with snippet name, but I
|
||||
-- don't know how -- neither do grok nor chatgpt ...
|
||||
|
||||
Reference in New Issue
Block a user