Repeating some moves gives "Vim(normal):E523: Not allowed here" error on main
Describe the bug
In the main branch, now you need to set {expr = true} when mapping the ;, , repeat functions, so that you can also configure repeat for builtins f,F,t,T.
-- Repeat movement with ; and ,
-- ensure ; goes forward and , goes backward regardless of the last direction
vim.keymap.set({ "n", "x", "o" }, ";", ts_repeat_move.repeat_last_move_next, { expr = true })
vim.keymap.set({ "n", "x", "o" }, ",", ts_repeat_move.repeat_last_move_previous, { expr = true })
By doing this, moves that make use of :normal commands return error.
To Reproduce Steps to reproduce the behavior:
- configure mapping for
repeat_last_move_nextandrepeat_last_move_previous - try a repeatable action, for example "go to next start of
@function.outer" (e.g.]m) - try to repeat with
;,,
Expected behavior The action should be repeated without errors.
** What happens **
E5108: Error executing lua: vim/_editor.lua:0: nvim_exec2(), line 1: Vim(normal):E523: Not allowed here
stack traceback:
[C]: in function 'nvim_exec2'
vim/_editor.lua: in function 'cmd'
...ter-textobjects/lua/nvim-treesitter-textobjects/move.lua:16: in function 'goto_node'
...ter-textobjects/lua/nvim-treesitter-textobjects/move.lua:135: in function <...ter-textobjects/lua/nvim-treesitter-textobjects/move.lua:41>
Output of nvim --version
NVIM v0.11.1
Build type: Release
LuaJIT 2.1.1744318430
** Additional info **
When I was trying to make my own repetable function work, I noticed that wrapping with vim.schedule() bypasses the issue:
local diag_move = require('nvim-treesitter-textobjects.repeatable_move').make_repeatable_move(function(opts)
if opts.forward then
-- schedule() prevents Vim(normal):E523: Not allowed here
-- that would arise because ; , are mapped with { expr = true }
vim.schedule(function() vim.diagnostic.jump({count = 1}) end)
else
vim.schedule(function() vim.diagnostic.jump({count = -1}) end)
end
end)
I'm using this workaround at the moment, which reuses some of the old code from the master branch, and doesn't need to set {expr = true} when you map ; and ,.