|
|
|
@ -1,10 +1,12 @@
|
|
|
|
|
print("primer keymap")
|
|
|
|
|
|
|
|
|
|
vim.keymap.set("n", "<leader>t", function() end, { desc = "+Todos" })
|
|
|
|
|
|
|
|
|
|
-- add new todo line when previous is already a todo
|
|
|
|
|
|
|
|
|
|
local function on_enter()
|
|
|
|
|
local current_line = vim.api.nvim_get_current_line()
|
|
|
|
|
|
|
|
|
|
print("entro en onenter")
|
|
|
|
|
-- Check if the current line matches the pattern
|
|
|
|
|
local pattern = "^%- %[[ x]%] .*$"
|
|
|
|
|
local match = string.match(current_line, pattern)
|
|
|
|
@ -26,6 +28,8 @@ local function on_enter()
|
|
|
|
|
end
|
|
|
|
|
vim.keymap.set("i", "<CR>", on_enter, { desc = "On enter", noremap = true, expr = true })
|
|
|
|
|
|
|
|
|
|
print("segundo keymap")
|
|
|
|
|
|
|
|
|
|
-- function that checks if the current line starts with the string "- [ ]" or "- [x]" and toggles the x
|
|
|
|
|
local function toggle_todo()
|
|
|
|
|
local line = vim.api.nvim_get_current_line()
|
|
|
|
@ -49,6 +53,7 @@ local function toggle_todo()
|
|
|
|
|
end
|
|
|
|
|
vim.keymap.set("n", "<leader>tt", toggle_todo, { desc = "Toggle todo" })
|
|
|
|
|
|
|
|
|
|
print("tercero")
|
|
|
|
|
-- function that checks if the current line doesn't start with the string "- [ ] " and, if it doesn't, adds the string at the beginning of the line
|
|
|
|
|
local function add_todo()
|
|
|
|
|
local line = vim.api.nvim_get_current_line()
|
|
|
|
|