|
|
|
@ -27,6 +27,22 @@ local function press_enter()
|
|
|
|
|
end
|
|
|
|
|
vim.keymap.set("i", "<CR>", press_enter, { desc = "On enter", noremap = true, expr = true })
|
|
|
|
|
|
|
|
|
|
-- indent line if tab is pressed when line is a todo
|
|
|
|
|
local function press_tab()
|
|
|
|
|
local current_line = vim.api.nvim_get_current_line()
|
|
|
|
|
|
|
|
|
|
-- Check if current line matches the patterns
|
|
|
|
|
local openpattern = "%- %[[ ]%]"
|
|
|
|
|
local closedpattern = "%- %[[x]%]"
|
|
|
|
|
|
|
|
|
|
if string.match(current_line, openpattern) or string.match(current_line, closedpattern) then
|
|
|
|
|
vim.api.nvim_feedkeys(vim.api.nvim_eval('"\\<esc>"'), "n", true)
|
|
|
|
|
vim.api.nvim_feedkeys(">", "n", true)
|
|
|
|
|
vim.api.nvim_feedkeys("A", "n", true)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
vim.keymap.set("i", "<TAB>", press_tab, { desc = "On tab", noremap = true, expr = true })
|
|
|
|
|
|
|
|
|
|
-- function that checks if the current line starts with the string "- [ ]" or "- [x]" and toggles the x
|
|
|
|
|
|
|
|
|
|
local function toggle_todo()
|
|
|
|
|