From 98808b7c0ea7ba5b1d1f6c1b875176df7cf253d1 Mon Sep 17 00:00:00 2001 From: borja Date: Mon, 27 Nov 2023 23:48:14 +0100 Subject: [PATCH] ni idea --- plugin/todoer.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugin/todoer.lua b/plugin/todoer.lua index beb2cbe..cd3c14b 100644 --- a/plugin/todoer.lua +++ b/plugin/todoer.lua @@ -57,15 +57,15 @@ local function add_todo() local closedpattern = "^%s*%- %[[x]%]" local line = vim.api.nvim_get_current_line() - local i, spaces = string.find(line, "^%s*") + local index, spaces = string.find(line, "^%s*") - if not string.match(line, openpattern) and not string.match(line, closedpattern) then - if i == 1 and spaces == 0 then + if index == 1 and not string.match(line, openpattern) and not string.match(line, closedpattern) then + if index == 1 and spaces == 0 then line = spaces .. "- [ ] " .. line vim.api.nvim_set_current_line(line) - elseif i == 1 and spaces ~= 0 then + elseif index == 1 and spaces > 0 then local spacestring = "" - for x = 1, spaces do + for x = 1, spaces, 1 do spacestring = spacestring .. " " end line = spacestring .. "- [ ] " .. line