dance
dance copied to clipboard
[Discussion] Overriding the `type` command
I've been thinking about a few features that could be added to Dance, but that would require the VS Code type
command to be overridden at all times (rather than only when awaiting user input after a specific command, like now).
One such feature would be to map commands to characters, rather than key combinations, which would help for supporting non-Qwerty keyboard layouts. It could also allow custom commands in normal mode down the line, without having to modify the particularly verbose VS Code keybindings. I haven't tested it, but I also think it would slightly decrease the time when switching from Normal
to Insert
.
Any thoughts on such a change? Any obvious drawbacks or improvements?
If it makes it easier to implement something like LeaderMode, then I'm in favor. Your comment on "custom commands in normal mode" sounds interesting. LeaderMode doesn't currently work because of the same conflict over type
.
I'm not sure I understand. The fact that right now we don't override the type
command by default should not cause conflicts with LeaderMode (and that's the one significant advantage of using keybindings rather than type
, like Vim does).
I'm probably mixed up, so I'm sorry for side-tracking the discussion. If I trigger LeaderMode, Dance keys intercept LeaderMode keys, so that's probably not a type
issue. Your comment on "custom keys" made it sound like overriding type
would make it easier to implement something like LeaderMode more easily.
@tshort Oh I see now, my bad. If we override type
, then we'll definitely have conflicts. The problem here is that the normal
Dance keybindings take precedence over type
when LeaderMode is invoked.
This is an easy fix: just add the condition !leadermode.isActive
to all Dance keybindings. However it's pretty tedious to do by hand, and I'd rather not do that to the default keybindings.
I think adding a way to programmatically set keybindings would greatly help here, but VS Code doesn't allow this.
Will this help to squash some normal mode bugs? Or will this just help in defining new keybindings?
I don't mind the verbose VSCode way of defining keybindings. Important for me is that they work and don't complicate the current implementation. If introducing plugin specific ways of defining keybindings will expand the code base and imply more maintainer time squashing bugs introduced by it, I'd vote for fixing current bugs first.
I'm all for this change for the flexibility. Two additional problems I think we can tackle with global type
override:
- In normal mode, I sometimes fat finger and hit keys that are unmapped (or not yet implemented by Dance). I would expect those things to give me a warning and leave the buffer unchanged (like Kakoune) but right now it messes up the buffer (especially with a selection) and I have to figure out how to undo.
- Right now it's super tricky to remap
g d
to go to definition -- adding a new key sequence binding in VSCode will makeg
wait on the next key instead of open thego to
menu in Dance. I think globaltype
will enable Dance to implement a Kak-like configurable "mode" for this.
@yuchenshi The first point is valid and I often think about it. We would either have to add keybindings that do nothing for the rest of the keys or not override type
for this. As for the second point, can't it be implemented using keybindings as well, assuming we add support for it in Dance?
@timjs I think it could lead to new features or improving some behaviors (like @yuchenshi's first point), but I don't think it will help that much regarding bugs.
@71 Fair enough, I've extracted my second point into #86 and we can discuss about it there.
Mapping commands to characters, rather than key codes, will be a problem for people who use multiple keyboard layouts.
I use both Bulgarian and English keyboard layout. Sometimes I need to write some Bulgarian text in vscode. With key codes everything works fine, because they are the same across layouts.
However if characters are used then all normal mode commands will stop working in Bulgarian layout, because pressing keys will produce Cyrillic characters. For example pressing i
will produce и
.