From 4eb596e4058371d227794ab24e524e0ae967d844 Mon Sep 17 00:00:00 2001 From: borja Date: Mon, 27 Nov 2023 23:44:01 +0100 Subject: [PATCH] a ver si ahora respeta los espacios --- plugin/todoer.lua | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/plugin/todoer.lua b/plugin/todoer.lua index aea0416..beb2cbe 100644 --- a/plugin/todoer.lua +++ b/plugin/todoer.lua @@ -58,11 +58,19 @@ local function add_todo() local line = vim.api.nvim_get_current_line() local i, spaces = string.find(line, "^%s*") - print(i, 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.match(line, openpattern) and not string.match(line, closedpattern) then + if i == 1 and spaces == 0 then + line = spaces .. "- [ ] " .. line + vim.api.nvim_set_current_line(line) + elseif i == 1 and spaces ~= 0 then + local spacestring = "" + for x = 1, spaces do + spacestring = spacestring .. " " + end + line = spacestring .. "- [ ] " .. line + end + end -- if not string.sub(line, 1, 1) == " " then -- line = "- [ ] " .. line -- vim.api.nvim_set_current_line(line)