How to use neorg.itero.next-iteration
in normal mode?
#1605
Replies: 1 comment
-
I think that function is only available in insert mode. I was messing around with this last week and got something like the following to work: vim.keymap.set("i", "<Enter>", "<Plug>(neorg.itero.next-iteration)", { silent = true, buffer = true}) This ended up being a bit annoying, however, and I ended up writing a more complicated function to check if the cursor is on a list item before doing vim.keymap.set("n", "o", "i<Plug>(neorg.itero.next-iteration)", { silent = true, buffer = true }) The trick is to go into insert mode before calling Edit: I just realized you want the regular "o" functionality in some cases. Thus we have a similar use case. It's fairly complicated right now because local function auto_continue_list()
local node = vim.treesitter.get_node()
local nt = node:type()
while not string.find(nt, "_list") and nt ~= "document" do
node = node:parent()
nt = node:type()
end
if nt ~= "document" then
vim.api.nvim_input("<M-CR>")
else
local keys = vim.api.nvim_replace_termcodes("<Enter>", true, false, true)
vim.api.nvim_feedkeys(keys, "n", false)
end
end
vim.keymap.set('i', '<Enter>', auto_continue_list, { silent = true, buffer = true }) It's very hacky. |
Beta Was this translation helpful? Give feedback.
-
I want to map it to
o
in normal mode with the following functionality:1.When the
neorg.itero.next-iteration
is available, go to insert mode in the next line with the iteration.2. When itero is not available, just function like normal
o
: insert mode in the next line.But now I can't even make it work when I map it to normal mode. when I press
o
in normal mode, nothing happened.Beta Was this translation helpful? Give feedback.
All reactions