summaryrefslogtreecommitdiff
path: root/after/ftplugin/markdown.lua
diff options
context:
space:
mode:
Diffstat (limited to 'after/ftplugin/markdown.lua')
-rw-r--r--after/ftplugin/markdown.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/after/ftplugin/markdown.lua b/after/ftplugin/markdown.lua
new file mode 100644
index 0000000..fe9be18
--- /dev/null
+++ b/after/ftplugin/markdown.lua
@@ -0,0 +1,14 @@
+local function toggle_tick(buf, lnum, line, to)
+ local beg, tick, rest = line:match("^(%s*)- %[([x ])%](.*)")
+end
+
+vim.keymap.set("n", "<CR>", function()
+ local curline = vim.fn.getline(".")
+ local lnum = vim.fn.getpos(".")[2]
+ local beg, tick, rest = curline:match("^(%s*)- %[([x ])%](.*)")
+ if beg == nil then return end
+
+ local new_tick = (tick == " " and "x" or " ")
+ local new_line = beg .. "- [" .. new_tick .. "]" .. rest
+ vim.api.nvim_buf_set_lines(0, lnum - 1, lnum, false, { new_line })
+end, { buffer = true })