This commit is contained in:
Jaroslaw Konik 2026-05-19 09:10:43 +02:00
parent 9a4fe793de
commit 55e68aca38

View file

@ -826,6 +826,24 @@ vim.api.nvim_create_autocmd('BufEnter', {
vim.opt_local.formatoptions:append("t")
end,
})
local function toggle_checkbox()
local line = vim.api.nvim_get_current_line()
local new
if line:match('%[ %]') then
new = line:gsub('%[ %]', '[x]', 1)
elseif line:match('%[x%]') then
new = line:gsub('%[x%]', '[ ]', 1)
elseif line:match('^(%s*[-*+])%s+(.*)') then
-- bare list item → promote to checkbox
new = line:gsub('^(%s*[-*+])%s+', '%1 [ ] ', 1)
else
return
end
vim.api.nvim_set_current_line(new)
end
vim.keymap.set('n', '<leader>tc', toggle_checkbox,
{ desc = 'Toggle markdown checkbox', buffer = false })
-------------------------------------------------------------------------------
-- Comments