update
This commit is contained in:
parent
9a4fe793de
commit
55e68aca38
1 changed files with 18 additions and 0 deletions
18
init.lua
18
init.lua
|
|
@ -826,6 +826,24 @@ vim.api.nvim_create_autocmd('BufEnter', {
|
||||||
vim.opt_local.formatoptions:append("t")
|
vim.opt_local.formatoptions:append("t")
|
||||||
end,
|
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
|
-- Comments
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue