Repository navigation
feat(keybinds): make command bindings configurable - #28
Open
fede-ciliberti wants to merge 1 commit into
Open
fede-ciliberti wants to merge 1 commit into
fede-ciliberti wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Plugin commands cannot be remapped from
cli.json: a V2 keymap takes thebinding 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
keybindsplugin option, resolved byresolveKeybinds()inlib/keybinds.js:recordctrl+r/stt-recordsubmitleader+r/stt-submitcancelRecording/stt-stopmic/stt-micspeakleader+s/tts-speaktoggleTtsleader+v/tts-modestopPlaybackescape/tts-stopvoice/tts-voiceOmitted 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+rissession.renamein thedefault 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
lib/keybinds.jswith the defaults and the resolverregisterTTS()now also receives the plugin options (it read them nowherebefore), so both modules resolve the same map
toCommand()maps an empty binding toundefinedinstead of""Verification
""/"none", unknown keysand non-string values ignored, non-object option ignored
npm test25/25,npx oxlint .clean,npx oxfmt --check .clean