|
|
@ -1,3 +1,4 @@
|
|
|
|
|
|
|
|
-- Empty keymap for the menu
|
|
|
|
vim.keymap.set("n", "<leader>t", function() end, { desc = "+Todos" })
|
|
|
|
vim.keymap.set("n", "<leader>t", function() end, { desc = "+Todos" })
|
|
|
|
|
|
|
|
|
|
|
|
-- add new todo line when previous is already a todo
|
|
|
|
-- add new todo line when previous is already a todo
|
|
|
@ -59,9 +60,14 @@ local function add_todo()
|
|
|
|
local line = vim.api.nvim_get_current_line()
|
|
|
|
local line = vim.api.nvim_get_current_line()
|
|
|
|
|
|
|
|
|
|
|
|
if not string.match(line, openpattern) and not string.match(line, closedpattern) then
|
|
|
|
if not string.match(line, openpattern) and not string.match(line, closedpattern) then
|
|
|
|
line = "- [ ] " .. line
|
|
|
|
if not string.sub(line, 1, 1) == " " then
|
|
|
|
vim.api.nvim_set_current_line(line)
|
|
|
|
line = "- [ ] " .. line
|
|
|
|
vim.api.nvim_feedkeys("A", "n", true)
|
|
|
|
vim.api.nvim_set_current_line(line)
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
line = "- [ ]" .. line
|
|
|
|
|
|
|
|
vim.api.nvim_set_current_line(line)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
-- vim.api.nvim_feedkeys("A", "n", true) -- move cursor to the end of the line
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
vim.keymap.set("n", "<leader>ta", add_todo, { desc = "Add todo" })
|
|
|
|
vim.keymap.set("n", "<leader>ta", add_todo, { desc = "Add todo" })
|
|
|
@ -77,9 +83,5 @@ local function remove_todo()
|
|
|
|
line = string.gsub(line, closedpattern, "")
|
|
|
|
line = string.gsub(line, closedpattern, "")
|
|
|
|
vim.api.nvim_set_current_line(line)
|
|
|
|
vim.api.nvim_set_current_line(line)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
-- if string.sub(line, 1, 6) == "- [ ] " or string.sub(line, 1, 6) == "- [x] " then
|
|
|
|
|
|
|
|
-- line = string.sub(line, 7, -1)
|
|
|
|
|
|
|
|
-- vim.api.nvim_set_current_line(line)
|
|
|
|
|
|
|
|
-- end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
vim.keymap.set("n", "<leader>td", remove_todo, { desc = "Remove todo" })
|
|
|
|
vim.keymap.set("n", "<leader>td", remove_todo, { desc = "Remove todo" })
|
|
|
|