Open xiaoshihou514 opened 1 week ago
You might have a chance using the SafeState autocommand, that is triggered when neovim finished something and is now in a safe state to do something else. You'd still have to collect each keys manually though 🤔
Note that this is how this multicursor plugin from @jake-stewart works AFAIK (collect, wait for safe state, propagate last inputs to other cursors if it makes sense)
as mentioned in https://github.com/neovim/neovim/issues/30741#issuecomment-2404867582 , this is not implemented yet.
Part of the work to implement "multicursor" support will be to "atomize" input so that its structure is exposed. That seems like a requirement for this, otherwise you end up re-implementing a mapping parser in
on_key
(which doesn't know if a key will resolve to a mapping / builtin normal command)?
You might have a chance using the SafeState autocommand, that is triggered when neovim finished something and is now in a safe state to do something else. You'd still have to collect each keys manually though 🤔
Note that this is how this multicursor plugin from @jake-stewart works AFAIK (collect, wait for safe state, propagate last inputs to other cursors if it makes sense)
It's far from perfect.
vim.fn.feedkeys
and vim.api.nvim_feedkeys
.lj
to something and press l
three times. Despite the l
mapping executing twice, vim never had a chance to enter a safe state.Hmm, vim.fn.state("o")
might help me here, but it's still very vulnerable to internal changes.
Problem
I am trying to collect keystroke statistics like somebody did in emacs, however, there is no way to make actions like
ci[
to be sent tovim.on_key
together. Instead, the function will be triggered 3 times, withc
,i
and[
.Expected behavior
The ability to write
... and get
ci[
sent tof
!