Skip to content

Allow leader commands to be bound directly to keys in action_keys #321

Closed

Description

@fclef819

Some leader commands are used often enough that the two-keystroke path (leader → key) becomes friction. edit_query_in_editor is my case — I reach for it constantly and would like it on ctrl+g in the query editor.

Today this doesn't seem possible. action_keys only accepts actions that already have a default binding in that scope, so adding edit_query_in_editor there fails with "unknown action". leader_commands lets me change which key follows the leader, but not remove the leader step. So a leader command can be re-keyed, but never promoted to a direct binding.

I'd like action_keys to accept leader command names as well. If a user writes:

{ "keymap": { "action_keys": { "query_normal": { "edit_query_in_editor": "ctrl+g" } } } }

the action would be reachable both from the leader menu and from ctrl+g.

This isn't specific to my case — format_query, telescope, and change_theme are all plausible candidates for a direct key depending on how someone works. Rather than adding default bindings for each, letting users promote any leader command keeps the default keymap as small as it is now.

Two things I'm unsure about and would like your view on before attempting a PR:

  1. Whether leader commands and action_keys actions share a dispatch shape, or whether an adapter layer would be needed.
  2. How conflicts should behave — ideally this would go through the existing conflict detection from Additive custom keymaps with conflict detection #225, but promoting a command into a scope that already uses that key needs a defined outcome.

Happy to implement this if you think the direction is right.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions