quito los print pero sigo sin saber por qué no está usando mi función en enter pero sí acepta el resto de keymaps

pull/1/head
borja 1 year ago
parent a25d2b3a39
commit bb1e89dae2

@ -1,12 +1,9 @@
print("primer keymap")
vim.keymap.set("n", "<leader>t", function() end, { desc = "+Todos" }) vim.keymap.set("n", "<leader>t", function() end, { desc = "+Todos" })
-- add new todo line when previous is already a todo -- add new todo line when previous is already a todo
local function on_enter() local function press_enter()
local current_line = vim.api.nvim_get_current_line() local current_line = vim.api.nvim_get_current_line()
print("entro en onenter")
-- Check if the current line matches the pattern -- Check if the current line matches the pattern
local pattern = "^%- %[[ x]%] .*$" local pattern = "^%- %[[ x]%] .*$"
local match = string.match(current_line, pattern) local match = string.match(current_line, pattern)
@ -26,9 +23,7 @@ local function on_enter()
vim.api.nvim_feedkeys("\n", "n", true) vim.api.nvim_feedkeys("\n", "n", true)
end end
end end
vim.keymap.set("i", "<CR>", on_enter, { desc = "On enter", noremap = false, expr = true }) vim.keymap.set("i", "<CR>", press_enter, { desc = "On enter", noremap = true, expr = true })
print("segundo keymap")
-- 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()
@ -53,7 +48,6 @@ local function toggle_todo()
end end
vim.keymap.set("n", "<leader>tt", toggle_todo, { desc = "Toggle todo" }) vim.keymap.set("n", "<leader>tt", toggle_todo, { desc = "Toggle todo" })
print("tercero")
-- function that checks if the current line doesn't start with the string "- [ ] " and, if it doesn't, adds the string at the beginning of the line -- function that checks if the current line doesn't start with the string "- [ ] " and, if it doesn't, adds the string at the beginning of the line
local function add_todo() local function add_todo()
local line = vim.api.nvim_get_current_line() local line = vim.api.nvim_get_current_line()

Loading…
Cancel
Save