I’ve started working on an extension that emulates Kakoune (think Vim) keybindings, and part of what’s necessary for that to work properly is to only allow writing while the user is in input mode. There is currently no way to do this aside from re-binding all alphanumeric characters, symbols, punctuation marks, etc. That would be extremely tedious, and bloat the extension.json a lot.
I’m wondering if you have something in mind for mitigating this? Solutions that come to my mind are:
Allow an extension to take over all input handling
The extensions would then be responsible for delegating input handling to Nova when some condition is fulfilled
Allow an extension to selectively disable writing, but still receive input events
Make modal editing a more integrated part of Nova
Here Nova would have to ship with a core ‘Insert’ mode
Extensions would define other modes and handle inputs while in those other modes
I’m sure there’s a good way to do this, but I’m not sure what the best way to solve this is . I’d love to hear your thoughts.
I haven’t done much work on the extension itself so far, but if you’re curious to see what I’ve done so far you can have a look here.
The API is currently intended to work as you mentioned: You’ll need to rebind the keys you want to handle. But we can definitely consider adding a way to say “do not allow inserting any characters” while your extension is in a command mode and / or to delegate all keyboard input into the extension if a certain condition is met!
Thank you for being willing to consider it! I do, however, think a way to turn off regular input handling will be necessary. Well, maybe not necessary, but not having that capability will make working on an extension like this extremely tedious
Just to take an example:
If I’m writing on an Icelandic keyboard layout there are letters on the keyboard I can press that are not handled by Kakoune (i.e. no reason to rebind them in the context of a Kakoune emulation extension). Examples of such keys: þæðö.
Rebinding those characters to some type of no-op while in any mode other than insert mode will be extremely tedious once you factor in other layouts with keys like this. Danish, Swedish, Norwegian, and German layouts all have different characters that would need to be rebound to no-ops, and that’s just counting the layouts I know of.
Not impossible by any means, but I’m pretty sure about half the keybindings will just be a “this key does nothing except when you’re in insert mode”.