diff --git a/lua/todoer/init.lua b/lua/todoer/init.lua index 34b8632..7d969e0 100644 --- a/lua/todoer/init.lua +++ b/lua/todoer/init.lua @@ -245,6 +245,9 @@ local function setup_buffer_keymaps() else -- Line is not indented, terminate the list + -- ===== DEBUGGING START ===== + vim.notify(string.format("[Todoer Debug] Terminating list on line %d. Setting line to empty string.", lnum), vim.log.levels.WARN) + -- ===== DEBUGGING END ===== -- Replace the line with an empty string vim.api.nvim_buf_set_lines(0, lnum - 1, lnum, false, { "" }) -- Now, manually insert a newline below using the API @@ -266,11 +269,10 @@ local function setup_buffer_keymaps() -- indent line if tab is pressed when line is a todo (Will be refactored in Step 4) local function press_tab() local current_line = vim.api.nvim_get_current_line() - -- Check if current line matches the patterns (Only checks '-' marker currently) - -- TODO: Update pattern to match *, + as well - local pattern = "^%s*%- %[[ x]%]" + -- Updated pattern to match -, *, + markers + local pattern = "^%s*[%-%*%+]%s+%[[ x]%]" if string.match(current_line, pattern) then - -- print("tab pressed, allegedly") -- Removed print + -- Still using feedkeys for now, will be refactored later vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("", true, false, true), "i", false) return "" -- Action handled by feedkeys else @@ -282,11 +284,10 @@ local function setup_buffer_keymaps() -- indent line if shift tab is pressed when line is a todo (Will be refactored in Step 4) local function press_shift_tab() local current_line = vim.api.nvim_get_current_line() - -- Check if current line matches the patterns (Only checks '-' marker currently) - -- TODO: Update pattern to match *, + as well - local pattern = "^%s*%- %[[ x]%]" + -- Updated pattern to match -, *, + markers + local pattern = "^%s*[%-%*%+]%s+%[[ x]%]" if string.match(current_line, pattern) then - -- print("shift tab pressed, allegedly") -- Removed print + -- Still using feedkeys for now, will be refactored later vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("", true, false, true), "i", false) return "" -- Action handled by feedkeys else @@ -302,6 +303,7 @@ local function setup_buffer_keymaps() -- 1: Prefix (indentation, marker '-', '*', '+', or '#', and whitespace) -- 2: State (' ' or 'x') -- 3: Rest of the line (after ']') + -- Adjusted pattern slightly to ensure it captures # correctly too if needed local prefix, state, rest = string.match(line, "^([%s]*[%-#%*%+]%s*)%[([ x])%](.*)") if prefix then -- Check if the pattern matched (i.e., it's a toggleable line)