From eb05f300a125b12022a9021df12c18ab60566a5b Mon Sep 17 00:00:00 2001 From: borja Date: Mon, 27 Nov 2023 23:32:21 +0100 Subject: [PATCH] test --- plugin/todoer.lua | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/plugin/todoer.lua b/plugin/todoer.lua index e4f8ace..5c058a4 100644 --- a/plugin/todoer.lua +++ b/plugin/todoer.lua @@ -1,4 +1,3 @@ - vim.keymap.set("n", "t", function() end, { desc = "+Todos" }) -- add new todo line when previous is already a todo @@ -58,20 +57,19 @@ 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 - local templine = spaces .. "- [ ] " - line = templine .. 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 - end + local spaces = string.find(line, "%S") + print(spaces) + -- if not string.match(line, openpattern) and not string.match(line, closedpattern) then + -- 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 + -- end end vim.keymap.set("n", "ta", add_todo, { desc = "Add todo" })