diff --git a/plugin/todoer.lua b/plugin/todoer.lua index f6bcabb..0d0827b 100644 --- a/plugin/todoer.lua +++ b/plugin/todoer.lua @@ -4,6 +4,8 @@ vim.keymap.set("n", "t", function() end, { desc = "+Todos" }) local function press_enter() local current_line = vim.api.nvim_get_current_line() + local index, spaces = string.find(current_line, "^%s*") + -- Check if the current line matches the pattern local pattern = "^%- %[[ x]%] .*$" local match = string.match(current_line, pattern) @@ -63,6 +65,7 @@ local function add_todo() if index == 1 and spaces == 0 then line = "- [ ] " .. line vim.api.nvim_set_current_line(line) + vim.api.nvim_feedkeys("A", "n", true) elseif index == 1 and spaces > 0 then local trimedline = string.sub(line, spaces + 1) local spacestring = ""