Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,10 @@ When you create a new note, **dotmd.nvim**:
When you create a new todo file, **dotmd.nvim**:

1. Checks if today's todo file exists (e.g. `todo/2025-04-09.md`).
2. If not, rolls over unfinished `- [ ] tasks from the previous file` from the nearest previous todo file (if any).
3. Applies the todo template.
4. Opens the file for editing.
2. If the file doesn't exist, prompt for create confirmation.
3. If confirm, rolls over unfinished `- [ ] tasks from the previous file` from the nearest previous todo file (if any).
4. Applies the todo template.
5. Opens the file for editing.

### Inbox

Expand All @@ -370,8 +371,9 @@ The inbox is a special file that is used to dump thoughts, tasks, and references

When you create a new journal file, **dotmd.nvim**:

1. Builds today's journal path (e.g. `journal/2025-04-09.md`).
2. If the file doesn’t exist, creates it using the journal template.
1. Checks if today's journal file exists (e.g. `journal/2025-04-09.md`).
2. If the file doesn't exist, prompt for create confirmation.
2. If confirm, creates it using the journal template.
3. Opens it for editing.

### Picker
Expand Down
14 changes: 8 additions & 6 deletions doc/dotmd.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,10 @@ TODO FILES ~
When you create a new todo file, **dotmd.nvim**

1. Checksif today’s todo file exists (e.g. `todo/2025-04-09.md`).
2. If not, rolls over unfinished `- [ ] tasks from the previous file` from the nearest previous todo file (if any).
3. Applies the todo template.
4. Opens the file for editing.
2. If the file doesn’t exist, prompt for create confirmation.
3. If confirm, rolls over unfinished `- [ ] tasks from the previous file` from the nearest previous todo file (if any).
4. Applies the todo template.
5. Opens the file for editing.


INBOX ~
Expand All @@ -378,9 +379,10 @@ JOURNAL FILES ~

When you create a new journal file, **dotmd.nvim**

1. Buildstoday’s journal path (e.g. `journal/2025-04-09.md`).
2. If the file doesn’t exist, creates it using the journal template.
3. Opens it for editing.
1. Checksif today’s journal file exists (e.g. `journal/2025-04-09.md`).
2. If the file doesn’t exist, prompt for create confirmation.
3. If confirm, creates it using the journal template.
4. Opens it for editing.


PICKER ~
Expand Down
97 changes: 69 additions & 28 deletions lua/dotmd/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,29 +66,50 @@ function M.create_todo_today(opts)
local todo_path = todo_dir .. today .. ".md"

if vim.fn.filereadable(todo_path) == 0 then
utils.write_file(todo_path, "Todo for " .. today, config.templates.todo)

local unchecked_tasks, source_path =
todos.rollover_previous_todo_to_today(todo_dir, today)
if unchecked_tasks and source_path then
local today_lines = vim.fn.readfile(todo_path)
if #today_lines > 0 and today_lines[#today_lines] ~= "" then
table.insert(today_lines, "")
vim.ui.select({ "yes", "no" }, {
prompt = "Create todo for today?",
}, function(input)
if not input or input == "" then
return
end
vim.list_extend(today_lines, unchecked_tasks)
utils.safe_writefile(today_lines, todo_path)
vim.notify(
string.format(
"Rolled over %d unchecked todo(s) from %s",
#unchecked_tasks,
vim.fn.fnamemodify(source_path, ":t")
)

if input == "no" then
vim.notify("Aborted todo creation", vim.log.levels.INFO)
return
end

utils.write_file(
todo_path,
"Todo for " .. today,
config.templates.todo
)
end
end

if opts.open then
utils.open_file(todo_path, opts)
local unchecked_tasks, source_path =
todos.rollover_previous_todo_to_today(todo_dir, today)
if unchecked_tasks and source_path then
local today_lines = vim.fn.readfile(todo_path)
if #today_lines > 0 and today_lines[#today_lines] ~= "" then
table.insert(today_lines, "")
end
vim.list_extend(today_lines, unchecked_tasks)
utils.safe_writefile(today_lines, todo_path)
vim.notify(
string.format(
"Rolled over %d unchecked todo(s) from %s",
#unchecked_tasks,
vim.fn.fnamemodify(source_path, ":t")
)
)
end

if opts.open then
utils.open_file(todo_path, opts)
end
end)
else
if opts.open then
utils.open_file(todo_path, opts)
end
end
end

Expand All @@ -109,15 +130,35 @@ function M.create_journal(opts)
local journal_path = journal_dir .. today .. ".md"

if vim.fn.filereadable(journal_path) == 0 then
utils.write_file(
journal_path,
"Journal Entry for " .. today,
config.templates.journal
)
end
vim.ui.select({ "yes", "no" }, {
prompt = "Create journal entry for today?",
}, function(input)
if not input or input == "" then
return
end

if opts.open then
utils.open_file(journal_path, opts)
if input == "no" then
vim.notify(
"Aborted journal entry creation",
vim.log.levels.INFO
)
return
end

utils.write_file(
journal_path,
"Journal Entry for " .. today,
config.templates.journal
)

if opts.open then
utils.open_file(journal_path, opts)
end
end)
else
if opts.open then
utils.open_file(journal_path, opts)
end
end
end

Expand Down