commit e970221b52bfa323db0e48fc1692c4ac31319497
parent 01e37f815be84264dfb8d126dbfdffba342cd516
Author: Chris Bracken <chris@bracken.jp>
Date: Thu, 14 May 2026 16:14:51 +0900
nvim: <leader>cd now emits current date title and newlines
Also drops me into insert mode.
Diffstat:
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/.config/nvim/lua/config/snippets.lua b/.config/nvim/lua/config/snippets.lua
@@ -5,14 +5,15 @@ local function get_current_date()
if fname:match(date_pattern) then
local fdate = vim.fn.strptime('%Y-%m-%d', fname)
- return vim.fn.strftime('%Y-%m-%d (%a)', fdate)
+ return vim.fn.strftime('%Y-%m-%d(%a)', fdate)
else
- return vim.fn.strftime('%Y-%m-%d (%a)')
+ return vim.fn.strftime('%Y-%m-%d(%a)')
end
end
--- Key mapping to insert the current date in 'YYYY-mm-dd (Day)' format
+-- Key mapping to insert the current date as a markdown header
vim.keymap.set('n', '<Leader>cd', function()
local date_str = get_current_date()
- vim.api.nvim_put({date_str}, 'c', true, true)
+ vim.api.nvim_put({ '# ' .. date_str, '', '' }, 'c', true, true)
+ vim.cmd('startinsert')
end)