|  |  | @ -1,140 +1,165 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | -- Create the module table |  |  |  | -- Create the module table | 
			
		
	
		
		
			
				
					
					|  |  |  | local M = {} |  |  |  | local M = {} | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | -- add new todo line when previous is already a todo |  |  |  | -- Default configuration | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | local function press_enter() |  |  |  | local defaults = { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	local current_line = vim.api.nvim_get_current_line() |  |  |  | 	filetypes = { "markdown", "text", "norg" }, -- Filetypes to activate the plugin for | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	local index, spaces = string.find(current_line, "^%s*") |  |  |  | } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	-- Check if the current line matches the pattern |  |  |  | -- Internal function to set up buffer-local keymaps | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	local pattern = "^%- %[[ x]%] .*$" |  |  |  | local function setup_buffer_keymaps() | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	local match = string.match(current_line, pattern) |  |  |  | 	-- add new todo line when previous is already a todo | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 	local function press_enter() | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	if match then |  |  |  | 		local current_line = vim.api.nvim_get_current_line() | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		if string.len(current_line) >= 7 then |  |  |  | 		local index, spaces = string.find(current_line, "^%s*") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 			vim.api.nvim_feedkeys("\n- [ ] ", "n", true) |  |  |  | 
 | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		-- Check if the current line matches the pattern | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		local pattern = "^%- %[[ x]%] .*$" | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		local match = string.match(current_line, pattern) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		if match then | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			if string.len(current_line) >= 7 then | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				vim.api.nvim_feedkeys("\n- [ ] ", "n", true) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			else | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				-- go to normal mode before removing the content of the line | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				vim.api.nvim_feedkeys(vim.api.nvim_eval('"\\<esc>"'), "n", true) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				vim.api.nvim_feedkeys("_", "n", true) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				vim.api.nvim_feedkeys("C", "n", true) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				vim.api.nvim_feedkeys("\n", "n", true) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				-- vim.api.nvim_set_current_line("") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			end | 
			
		
	
		
		
			
				
					
					|  |  |  | 		else |  |  |  | 		else | 
			
		
	
		
		
			
				
					
					|  |  |  | 			-- go to normal mode before removing the content of the line |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 			vim.api.nvim_feedkeys(vim.api.nvim_eval('"\\<esc>"'), "n", true) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 			vim.api.nvim_feedkeys("_", "n", true) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 			vim.api.nvim_feedkeys("C", "n", true) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 			vim.api.nvim_feedkeys("\n", "n", true) |  |  |  | 			vim.api.nvim_feedkeys("\n", "n", true) | 
			
		
	
		
		
			
				
					
					|  |  |  | 			-- vim.api.nvim_set_current_line("") |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		end |  |  |  | 		end | 
			
		
	
		
		
			
				
					
					|  |  |  | 	else |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		vim.api.nvim_feedkeys("\n", "n", true) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	end |  |  |  | 	end | 
			
		
	
		
		
			
				
					
					|  |  |  | end |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | -- indent line if tab is pressed when line is a todo |  |  |  | 	-- indent line if tab is pressed when line is a todo | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | local function press_tab() |  |  |  | 	local function press_tab() | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	local current_line = vim.api.nvim_get_current_line() |  |  |  | 		local current_line = vim.api.nvim_get_current_line() | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	-- Check if current line matches the patterns |  |  |  | 		-- Check if current line matches the patterns | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	local openpattern = "%- %[[ ]%]" |  |  |  | 		local openpattern = "%- %[[ ]%]" | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	local closedpattern = "%- %[[x]%]" |  |  |  | 		local closedpattern = "%- %[[x]%]" | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	if string.match(current_line, openpattern) or string.match(current_line, closedpattern) then |  |  |  | 		if string.match(current_line, openpattern) or string.match(current_line, closedpattern) then | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		print("tab pressed, allegedly") |  |  |  | 			print("tab pressed, allegedly") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		vim.api.nvim_feedkeys("C-t", "i", true) |  |  |  | 			vim.api.nvim_feedkeys("C-t", "i", true) | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		end | 
			
		
	
		
		
			
				
					
					|  |  |  | 	end |  |  |  | 	end | 
			
		
	
		
		
			
				
					
					|  |  |  | end |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | -- indent line if shift tab is pressed when line is a todo |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | local function press_shift_tab() |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	local current_line = vim.api.nvim_get_current_line() |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	-- Check if current line matches the patterns |  |  |  | 	-- indent line if shift tab is pressed when line is a todo | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	local openpattern = "%- %[[ ]%]" |  |  |  | 	local function press_shift_tab() | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	local closedpattern = "%- %[[x]%]" |  |  |  | 		local current_line = vim.api.nvim_get_current_line() | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	if string.match(current_line, openpattern) or string.match(current_line, closedpattern) then |  |  |  | 		-- Check if current line matches the patterns | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		print("shift tab pressed, allegedly") |  |  |  | 		local openpattern = "%- %[[ ]%]" | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		vim.api.nvim_feedkeys("C-d", "i", true) |  |  |  | 		local closedpattern = "%- %[[x]%]" | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	end |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | end |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | -- function that checks if the current line starts with the string "- [ ]" or "- [x]" and toggles the x |  |  |  | 		if string.match(current_line, openpattern) or string.match(current_line, closedpattern) then | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | local function toggle_todo() |  |  |  | 			print("shift tab pressed, allegedly") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	local openpattern = "%- %[[ ]%]" |  |  |  | 			vim.api.nvim_feedkeys("C-d", "i", true) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	local closedpattern = "%- %[[x]%]" |  |  |  | 		end | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	local titleopenpattern = "# %[[ ]%]" |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	local titleclosedpattern = "# %[[x]%]" |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	local line = vim.api.nvim_get_current_line() |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	if string.match(line, openpattern) then |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		line = string.gsub(line, openpattern, "- [x]") |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		vim.api.nvim_set_current_line(line) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	elseif string.match(line, closedpattern) then |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		line = string.gsub(line, closedpattern, "- [ ]") |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		vim.api.nvim_set_current_line(line) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	elseif string.match(line, titleopenpattern) then |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		line = string.gsub(line, titleopenpattern, "# [x]") |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		vim.api.nvim_set_current_line(line) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	elseif string.match(line, titleclosedpattern) then |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		line = string.gsub(line, titleclosedpattern, "# [ ]") |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 		vim.api.nvim_set_current_line(line) |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 	end |  |  |  | 	end | 
			
		
	
		
		
			
				
					
					|  |  |  | end |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | -- 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 |  |  |  | 	-- function that checks if the current line starts with the string "- [ ]" or "- [x]" and toggles the x | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | local function add_todo() |  |  |  | 	local function toggle_todo() | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	local openpattern = "^%s*%- %[[ ]%]" |  |  |  | 		local openpattern = "%- %[[ ]%]" | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	local closedpattern = "^%s*%- %[[x]%]" |  |  |  | 		local closedpattern = "%- %[[x]%]" | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		local titleopenpattern = "# %[[ ]%]" | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		local titleclosedpattern = "# %[[x]%]" | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	local line = vim.api.nvim_get_current_line() |  |  |  | 		local line = vim.api.nvim_get_current_line() | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	local index, spaces = string.find(line, "^%s*") |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	if index == 1 and not string.match(line, openpattern) and not string.match(line, closedpattern) then |  |  |  | 		if string.match(line, openpattern) then | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		if index == 1 and spaces == 0 then |  |  |  | 			line = string.gsub(line, openpattern, "- [x]") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 			line = "- [ ] " .. line |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 			vim.api.nvim_set_current_line(line) |  |  |  | 			vim.api.nvim_set_current_line(line) | 
			
		
	
		
		
			
				
					
					|  |  |  | 			vim.api.nvim_feedkeys("A", "n", true) |  |  |  | 		elseif string.match(line, closedpattern) then | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		elseif index == 1 and spaces > 0 then |  |  |  | 			line = string.gsub(line, closedpattern, "- [ ]") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 			local trimedline = string.sub(line, spaces + 1) |  |  |  | 			vim.api.nvim_set_current_line(line) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 			local spacestring = "" |  |  |  | 		elseif string.match(line, titleopenpattern) then | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 			for x = 1, spaces, 1 do |  |  |  | 			line = string.gsub(line, titleopenpattern, "# [x]") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 				spacestring = spacestring .. " " |  |  |  | 			vim.api.nvim_set_current_line(line) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 			end |  |  |  | 		elseif string.match(line, titleclosedpattern) then | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 			line = spacestring .. "- [ ] " .. trimedline |  |  |  | 			line = string.gsub(line, titleclosedpattern, "# [ ]") | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 			vim.api.nvim_set_current_line(line) |  |  |  | 			vim.api.nvim_set_current_line(line) | 
			
		
	
		
		
			
				
					
					|  |  |  | 		end |  |  |  | 		end | 
			
		
	
		
		
			
				
					
					|  |  |  | 	end |  |  |  | 	end | 
			
		
	
		
		
			
				
					
					|  |  |  | end |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | -- function that checks if the current line starts with the string "- [ ]" or "- [x]" and, if it does, removes that string from the line |  |  |  | 	-- 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 remove_todo() |  |  |  | 	local function add_todo() | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	local openpattern = "%- %[[ ]%]" |  |  |  | 		local openpattern = "^%s*%- %[[ ]%]" | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	local closedpattern = "%- %[[x]%]" |  |  |  | 		local closedpattern = "^%s*%- %[[x]%]" | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	local line = vim.api.nvim_get_current_line() |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	-- local index, spaces = string.find(line, "^%s*") |  |  |  | 		local line = vim.api.nvim_get_current_line() | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 		local index, spaces = string.find(line, "^%s*") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	if string.match(line, openpattern) or string.match(line, closedpattern) then |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		print("encontrado") |  |  |  | 		if index == 1 and not string.match(line, openpattern) and not string.match(line, closedpattern) then | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		line = string.gsub(line, openpattern, "") |  |  |  | 			if index == 1 and spaces == 0 then | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		line = string.gsub(line, closedpattern, "") |  |  |  | 				line = "- [ ] " .. line | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		vim.api.nvim_set_current_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 = "" | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				for x = 1, spaces, 1 do | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					spacestring = spacestring .. " " | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				end | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				line = spacestring .. "- [ ] " .. trimedline | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				vim.api.nvim_set_current_line(line) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			end | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		end | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	end | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	-- function that checks if the current line starts with the string "- [ ]" or "- [x]" and, if it does, removes that string from the line | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	local function remove_todo() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		local openpattern = "%- %[[ ]%]" | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		local closedpattern = "%- %[[x]%]" | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		local line = vim.api.nvim_get_current_line() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		-- local index, spaces = string.find(line, "^%s*") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		if string.match(line, openpattern) or string.match(line, closedpattern) then | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			print("encontrado") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			line = string.gsub(line, openpattern, "") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			line = string.gsub(line, closedpattern, "") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			vim.api.nvim_set_current_line(line) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		end | 
			
		
	
		
		
			
				
					
					|  |  |  | 	end |  |  |  | 	end | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	-- Set up buffer-local keymaps | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	-- Use buffer = 0 to target the current buffer | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	local map_opts = { noremap = true, silent = true, buffer = 0 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	local expr_map_opts = { noremap = true, expr = true, silent = true, buffer = 0 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	vim.keymap.set("n", "<leader>t", function() end, { desc = "+TODOs", buffer = 0 }) -- Placeholder, keep silent=false if needed | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	vim.keymap.set("i", "<CR>", press_enter, { desc = "Todoer: Handle Enter", expr = true, buffer = 0 }) -- Keep expr=true, noremap=true is default | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	vim.keymap.set("i", "<TAB>", press_tab, { desc = "Todoer: Handle Tab", expr = true, buffer = 0 }) -- Keep expr=true | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	vim.keymap.set("i", "<S-Tab>", press_shift_tab, { desc = "Todoer: Handle Shift-Tab", expr = true, buffer = 0 }) -- Keep expr=true | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	vim.keymap.set("n", "<leader>tt", toggle_todo, { desc = "Todoer: Toggle TODO", buffer = 0 }) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	vim.keymap.set("n", "<leader>ta", add_todo, { desc = "Todoer: Add TODO", buffer = 0 }) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	vim.keymap.set("n", "<leader>td", remove_todo, { desc = "Todoer: Remove TODO", buffer = 0 }) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	-- Optional: Notify that keymaps are set for this buffer | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	-- vim.notify("Todoer keymaps activated for this buffer", vim.log.levels.INFO) | 
			
		
	
		
		
			
				
					
					|  |  |  | end |  |  |  | end | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | -- Setup function |  |  |  | -- Setup function: Called by the user in their config | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | -- This function will be called by the user to configure and activate the plugin |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | -- For now, it just sets up the default keymaps |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | function M.setup(opts) |  |  |  | function M.setup(opts) | 
			
		
	
		
		
			
				
					
					|  |  |  | 	-- opts is a placeholder for future configuration options |  |  |  | 	-- Merge user options with defaults | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	opts = opts or {} |  |  |  | 	local config = vim.tbl_deep_extend("force", {}, defaults, opts or {}) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	-- Set up the keymaps |  |  |  | 	-- Create an autocommand group to ensure we can clear it later if needed | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	vim.keymap.set("n", "<leader>t", function() end, { desc = "+TODOs" }) |  |  |  | 	local group = vim.api.nvim_create_augroup("TodoerUserSetup", { clear = true }) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	vim.keymap.set("i", "<CR>", press_enter, { desc = "On enter", noremap = true, expr = true }) |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	vim.keymap.set("i", "<TAB>", press_tab, { desc = "On tab", noremap = true, expr = true }) |  |  |  | 	-- Create the autocommand | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	vim.keymap.set("i", "S-Tab", press_shift_tab, { desc = "On shift tab", noremap = true, expr = true }) |  |  |  | 	vim.api.nvim_create_autocmd("FileType", { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	vim.keymap.set("n", "<leader>tt", toggle_todo, { desc = "Toggle TODO" }) |  |  |  | 		group = group, | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	vim.keymap.set("n", "<leader>ta", add_todo, { desc = "Add TODO" }) |  |  |  | 		pattern = config.filetypes, -- Use filetypes from config | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	vim.keymap.set("n", "<leader>td", remove_todo, { desc = "Remove TODO" }) |  |  |  | 		desc = "Setup Todoer keymaps for specific filetypes", | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 		callback = function() | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	print("Todoer setup complete!") -- Added a print statement for confirmation |  |  |  | 			-- Call the function that sets up buffer-local keymaps | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			setup_buffer_keymaps() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		end, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	}) | 
			
		
	
		
		
			
				
					
					|  |  |  | end |  |  |  | end | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | -- Return the module table |  |  |  | -- Return the module table | 
			
		
	
	
		
		
			
				
					|  |  | 
 |