stdlib-js / stdlib

✨ Standard library for JavaScript and Node.js. ✨
https://stdlib.io
Apache License 2.0
4.42k stars 468 forks source link

[RFC]: add support for custom key bindings in the REPL #2647

Open Snehil-Shah opened 3 months ago

Snehil-Shah commented 3 months ago

Description

This RFC proposes adding support for custom key bindings in the REPL.

Some prior art:

We would also want to support having custom key bindings for current actions like Ctrl+O for inserting a new line, or right arrow for accepting a suggestion, or the TAB key to toggle the completions etc.

Would suggest reading the above lists of actions for further discussion on what we should support

Checklist

kgryte commented 3 months ago

Most of Julia's keybindings seem reasonable. IPython's are a little hard to follow; however, some of the autosuggestion bindings could be useful.

Snehil-Shah commented 3 months ago

Should we allow multiple keybindings for an action?

kgryte commented 3 months ago

Seems fine to me.

Snehil-Shah commented 3 months ago

Should we allow configuring basic actions like backspace and moving left/right (using arrow keys) which are implemented by readline? We would have to override the default readline behavior to make it configurable.

Update: Let's just make it configurable, instead of reimplementing the behavior, we can just "pipe" the new key binding to call the old key binding sequence.

kgryte commented 3 months ago

Whatever you think makes sense. My initial thought was that supporting overriding for those keybindings seems like a rabbit hole if it means overriding readline, but if you think you have a reasonable workaround, seems fine to me.

Snehil-Shah commented 3 months ago

Should I break it into separate PRs, namely: