Skip to content

Commit 50c7635

Browse files
committed
feat: add keymap for creating and opening daily tracker file
1 parent 7e7201f commit 50c7635

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

nvim/lua/config/keymaps.lua

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
11
-- Keymaps are automatically loaded on the VeryLazy event
22
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
33
-- Add any additional keymaps here
4+
5+
-- daily note
6+
vim.keymap.set("n", "<leader>td", function()
7+
-- Get current date in YYYY-MM-DD format
8+
local date = os.date("%Y-%m-%d")
9+
local dir_path = "/Users/khoah/anzx/trackers"
10+
local file_path = dir_path .. "/" .. date .. ".md"
11+
12+
-- Create directory if it doesn't exist
13+
local dir_exists = vim.fn.isdirectory(dir_path)
14+
if dir_exists == 0 then
15+
vim.fn.mkdir(dir_path, "p")
16+
end
17+
18+
-- Open the file (creates if it doesn't exist)
19+
vim.cmd("edit " .. file_path)
20+
end, { desc = "Create and open daily tracker file" })

0 commit comments

Comments
 (0)