diff options
| author | Robert Günzler <r@gnzler.io> | 2022-09-21 18:55:48 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2022-09-21 18:55:48 +0200 |
| commit | f49a20176b8f18bc464451bc3da769c181388752 (patch) | |
| tree | 9592f4997a7a8ca5ed898213cb6f77a633eb43ee /.vim/after | |
| parent | a06e1a1c64831718a0247a5b405a27385a273308 (diff) | |
vim: markdown, conceal and toggle checkbox
Diffstat (limited to '.vim/after')
| -rw-r--r-- | .vim/after/ftplugin/markdown.lua | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/.vim/after/ftplugin/markdown.lua b/.vim/after/ftplugin/markdown.lua index 1b299e2..d07e131 100644 --- a/.vim/after/ftplugin/markdown.lua +++ b/.vim/after/ftplugin/markdown.lua @@ -1,17 +1,35 @@ require('spell') vim.opt.foldlevel = 1 --- vim.fn.matchadd('Conceal', '\\[ \\]', 0, -1, { conceal = '☐' }) --- vim.fn.matchadd('Conceal', '\\[x\\]', 0, -1, { conceal = '☑' }) --- vim.fn.matchadd('Conceal', '\\[-\\]', 0, -1, { conceal = '☒' }) --- vim.fn.matchadd('Conceal', '\\[\\]', 0, -1, { conceal = '🞕' }) +vim.fn.matchadd('Conceal', '- \\[ \\]\\&- \\zs\\[ ', 0, -1, { conceal = '☐ ' }) +-- vim.fn.matchadd('Conceal', '\\[x\\]', 0, -1, { conceal = '☑ ' }) +-- vim.fn.matchadd('Conceal', '\\[-\\]', 0, -1, { conceal = '☒ ' }) +vim.fn.matchadd('Conceal', '- \\[x\\]\\&- \\zs\\[x', 0, -1, { conceal = '🞕 ' }) +vim.fn.matchadd('Conceal', '- \\[[ x]\\zs\\]', 0, -1, { conceal = ' ' }) vim.keymap.set('n', '<Plug>Markdown_OpenUrlUnderCursor', - function() require('misc').open_under_cursor('url-launcher') end, -) + function() require('misc').open_under_cursor('url-launcher') end) vim.keymap.set('n', '<localleader>l', require('misc').link_preview, {desc='link preview'}) +local function toggle_checkbox() + local ln, n = vim.api.nvim_get_current_line(), 0 + ln, n = string.gsub(ln, '%[ %]', '[x]', 1) + if n > 0 then goto set_line end + ln, n = string.gsub(ln, '%[x%]', '[ ]', 1) + if n > 0 then goto set_line end + ln, n = string.gsub(ln, 'TODO', 'DONE', 1) + if n > 0 then goto set_line end + ln, n = string.gsub(ln, 'DONE', 'TODO', 1) + if n > 0 then goto set_line end + +::set_line:: + vim.api.nvim_set_current_line(ln) +end +vim.keymap.set('n', '<space><space>', toggle_checkbox, {desc='toggle checkbox'}) +vim.keymap.set('n', '<tab><tab>', toggle_checkbox, {desc='toggle checkbox'}) +vim.keymap.set('i', '<c-tab>', toggle_checkbox, {desc='toggle checkbox'}) + -- vim.keymap.set('n', '<leader>zn', function() require('zk').new() end) -- vim.keymap.set('n', '<leader>zi', function() require('zk').index() end) -- vim.cmd [[ command! -nargs=* ZettelkastenNew lua require('zk').new(nil, <f-args>) ]] |