Skip to content

feat(keybinds): make command bindings configurable - #28

Open
fede-ciliberti wants to merge 1 commit into
renjfk:mainfrom
fede-ciliberti:pr/keybinds
Open

fede-ciliberti wants to merge 1 commit into
renjfk:mainfrom
fede-ciliberti:pr/keybinds

Conversation

@fede-ciliberti

Copy link
Copy Markdown

What

Plugin commands cannot be remapped from cli.json: a V2 keymap takes the
binding from the command definition (context.keymap.layer({ commands: [{ bind }] })),
and the user config only knows the built-in command ids. Whatever the plugin
hardcodes is what the user gets.

This adds a keybinds plugin option, resolved by resolveKeybinds() in
lib/keybinds.js:

Key Default Command
record ctrl+r /stt-record
submit leader+r /stt-submit
cancelRecording — /stt-stop
mic — /stt-mic
speak leader+s /tts-speak
toggleTts leader+v /tts-mode
stopPlayback escape /tts-stop
voice — /tts-voice

Omitted keys keep the current defaults, so existing configs behave exactly as
before. An empty string or "none" disables a binding.

Why

The defaults collide with built-in bindings (ctrl+r is session.rename in the
default config) and the documented workaround is to disable the built-in one.
Being able to move the plugin's bindings instead is both friendlier and lets
users keep the built-ins.

Changes

  • new lib/keybinds.js with the defaults and the resolver
  • registerTTS() now also receives the plugin options (it read them nowhere
    before), so both modules resolve the same map
  • toCommand() maps an empty binding to undefined instead of ""

Verification

  • 5 new tests: defaults, override, disabling with ""/"none", unknown keys
    and non-string values ignored, non-object option ignored
  • npm test 25/25, npx oxlint . clean, npx oxfmt --check . clean

V2 keymaps take the binding from the command definition, so a plugin command
cannot be remapped from cli.json. Expose the bindings through the `keybinds`
plugin option instead, keeping the upstream defaults when nothing is set and
allowing an empty string or "none" to disable a binding.

Covers stt.record/submit/stop/mic and tts.speak-last/mode/stop/voice. The
registerTTS signature now also receives the plugin options.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant