-
Notifications
You must be signed in to change notification settings - Fork 239
Description
Feature description
This feature is inspired by abbr in Vim and in the fish shell as well as Vim's map commands, e.g. imap or nnoremap. It also makes use of Vim's <leader> key concept that's used in the map commands.
Without the fake keys feature, this was not feasible because the keyberon library is used to process actions. To easily generate an arbitrary action, a key needs to be pressed since kanata doesn't have any knowledge of how to process non-Custom actions. Now that fake keys are added, this feature seems feasible since a fake key is guaranteed to not interact with physical keypresses and thus a tap of a fake key is a good way to execute arbitrary actions.
The proposed changes are:
- add a new definition item
defseq- this will take a fake key name as the first parameter
- the following parameter is a list of normal keys (e.g.
(lctl a b c))
- add a new special action similar to live reload's
lrld: sequence leadersldr. - If
sldris pressed and followed by normal keys in the correct order, the fake key gets tapped
Example configuration entries:
(defseq git-status (g s t))
(deffakekeys git-status (macro g i t spc s t a t u s)
(defalias als (tap-hold 200 200 sldr ralt))
Tapping the keys in order: ralt g s t will result in git status being typed by kanata.
Implementation details
- all
defseqsequences are parsed into a trie - for simplicity, a non-leaf node is not allowed to have an action associated with it
- this is not how Vim
*mapcommands work - e.g.
(defseq fk1 a b c)and(defseq fk2 a b)will be rejected
- this is not how Vim
- when a sequence leader key
sldris pressed, switch the processing loop mode to a sequence mode where it does not send key inputs and instead traverse the trie using key inputs- when a sequence not in the trie is encountered, exit sequence mode
- when a sequence in the trie ends up on a leaf node, tap the fake key and exit sequence mode
- defcfg configurable timeout for sequence timeout?