|
|
@ -57,15 +57,15 @@ local function add_todo()
|
|
|
|
local closedpattern = "^%s*%- %[[x]%]"
|
|
|
|
local closedpattern = "^%s*%- %[[x]%]"
|
|
|
|
|
|
|
|
|
|
|
|
local line = vim.api.nvim_get_current_line()
|
|
|
|
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 index == 1 and not string.match(line, openpattern) and not string.match(line, closedpattern) then
|
|
|
|
if i == 1 and spaces == 0 then
|
|
|
|
if index == 1 and spaces == 0 then
|
|
|
|
line = spaces .. "- [ ] " .. line
|
|
|
|
line = spaces .. "- [ ] " .. line
|
|
|
|
vim.api.nvim_set_current_line(line)
|
|
|
|
vim.api.nvim_set_current_line(line)
|
|
|
|
elseif i == 1 and spaces ~= 0 then
|
|
|
|
elseif index == 1 and spaces > 0 then
|
|
|
|
local spacestring = ""
|
|
|
|
local spacestring = ""
|
|
|
|
for x = 1, spaces do
|
|
|
|
for x = 1, spaces, 1 do
|
|
|
|
spacestring = spacestring .. " "
|
|
|
|
spacestring = spacestring .. " "
|
|
|
|
end
|
|
|
|
end
|
|
|
|
line = spacestring .. "- [ ] " .. line
|
|
|
|
line = spacestring .. "- [ ] " .. line
|
|
|
|