main
borja 1 year ago
parent 4eb596e405
commit 98808b7c0e

@ -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

Loading…
Cancel
Save