From 0137f9a286ac53d46b2d294ee6481ad296570d11 Mon Sep 17 00:00:00 2001 From: borja Date: Mon, 27 Nov 2023 23:27:20 +0100 Subject: [PATCH] =?UTF-8?q?a=C3=B1ade=20todo=20contando=20con=20la=20inden?= =?UTF-8?q?taci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/todoer.lua | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/plugin/todoer.lua b/plugin/todoer.lua index eb16fc9..0cd80a1 100644 --- a/plugin/todoer.lua +++ b/plugin/todoer.lua @@ -1,4 +1,4 @@ --- Empty keymap for the menu + vim.keymap.set("n", "t", function() end, { desc = "+Todos" }) -- add new todo line when previous is already a todo @@ -58,16 +58,18 @@ local function add_todo() local closedpattern = "^%s*%- %[[x]%]" local line = vim.api.nvim_get_current_line() + local spaces = string.match(line, "^%s*") if not string.match(line, openpattern) and not string.match(line, closedpattern) then - if not string.sub(line, 1, 1) == " " then - line = "- [ ] " .. line - vim.api.nvim_set_current_line(line) - else - line = "- [ ]" .. line - vim.api.nvim_set_current_line(line) + line = spaces .. "- [ ] " .. line + vim.api.nvim_set_current_line(line) + -- if not string.sub(line, 1, 1) == " " then + -- line = "- [ ] " .. line + -- 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 vim.keymap.set("n", "ta", add_todo, { desc = "Add todo" })