From 82cafd0c8f59c9599af5f696185ed09f4cc22b84 Mon Sep 17 00:00:00 2001 From: borja Date: Tue, 5 Dec 2023 09:25:02 +0100 Subject: [PATCH] tab y shift tab --- plugin/todoer.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/plugin/todoer.lua b/plugin/todoer.lua index d9e4b9f..bd0e5f0 100644 --- a/plugin/todoer.lua +++ b/plugin/todoer.lua @@ -38,10 +38,26 @@ local function press_tab() if string.match(current_line, openpattern) or string.match(current_line, closedpattern) then print("tab pressed, allegedly") vim.api.nvim_feedkeys(">", "n", true) + vim.api.nvim_feedkeys(">", "n", true) end end vim.keymap.set("n", "", press_tab, { desc = "On tab", noremap = true, expr = true }) +-- indent line if shift tab is pressed when line is a todo +local function press_shift_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 + print("shift tab pressed, allegedly") + vim.api.nvim_feedkeys("<", "n", true) + vim.api.nvim_feedkeys("<", "n", true) + end +end +vim.keymap.set("n", "S-", press_shift_tab, { desc = "On shift 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()