nvim: Add mapping to insert todo item into markdown
Use <C-x> when in insert mode and it will prepend the line with an empty todo item.
This commit is contained in:
parent
27ef79391c
commit
c26ef032d2
1 changed files with 13 additions and 0 deletions
|
|
@ -11,6 +11,19 @@ if require("core.util").is_available("which-key") then
|
|||
})
|
||||
end
|
||||
|
||||
-- add tasks w/ <C-x>
|
||||
map({ "i" }, "<C-x>", function()
|
||||
local line = vim.api.nvim_get_current_line()
|
||||
local cursor = vim.api.nvim_win_get_cursor(0)
|
||||
-- remove existing prefixes if any
|
||||
-- TODO: Improved matching for e.g. '- [ ]' already on line, or indented '-'
|
||||
-- and add task on line below if line is already populated
|
||||
local updated_line = line:gsub("^%s*[-*]%s*", "", 1)
|
||||
vim.api.nvim_set_current_line(updated_line)
|
||||
vim.api.nvim_win_set_cursor(0, { cursor[1], #updated_line })
|
||||
vim.api.nvim_put({ "- [ ] " }, "c", true, true)
|
||||
end)
|
||||
|
||||
if require("core.util").is_available("zk") and require("zk.util").notebook_root(vim.fn.expand("%:p")) ~= nil then
|
||||
map("n", "<CR>", "<cmd>lua vim.lsp.buf.definition()<cr>", { silent = true })
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue