añade tab

main
borja 1 year ago
parent 4c8b17569e
commit 599d0524f7

@ -1,4 +1,4 @@
# TODO # TODO
- [ ] Fix press_enter when line is indented - [ ] Fix press_enter when line is indented
- [ ] When line is a todo, tab indents

@ -27,6 +27,22 @@ local function press_enter()
end end
vim.keymap.set("i", "<CR>", press_enter, { desc = "On enter", noremap = true, expr = true }) 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 -- function that checks if the current line starts with the string "- [ ]" or "- [x]" and toggles the x
local function toggle_todo() local function toggle_todo()

Loading…
Cancel
Save