Fiddling around with my config I ended up writing a function to toggle (check/uncheck) a checkbox (- [ ]).
It might be useful to add the functionality to this plugin, currently my function looks something like this:
local function toggle_checkbox()
local line = vim.api.nvim_get_current_line()
local line_has_checkbox = string.match(line, "^%s*- %[[%sXx]%]")
if line_has_checkbox then
local is_checked = string.match(line, "%[[xX]%]")
if is_checked then
local new_line = string.gsub(line, "%[[xX]%]", "[ ]", 1)
vim.api.nvim_set_current_line(new_line)
else
local new_line = string.gsub(line, "%[%s%]", "[x]", 1)
vim.api.nvim_set_current_line(new_line)
end
end
end
It's not pretty and doesn't handle visual mode.
There is surely a better implementation but it might be a good starting point.
Hello!
Fiddling around with my config I ended up writing a function to toggle (check/uncheck) a checkbox (
- [ ]
).It might be useful to add the functionality to this plugin, currently my function looks something like this:
It's not pretty and doesn't handle visual mode. There is surely a better implementation but it might be a good starting point.