[Feature Request] Offer to connect when evaluating forms while disconnected
Often when switching branches or restarting the REPL or restarting VSCode that hosts the REPL, I will forget that Calva is not connected to the REPL, so I will merrily evaluate forms until I realise to look at the status bar and see that the REPL is disconnected.
Since Calva knows that it's not connected, it could offer a suggestion to connect, perhaps remembering previous selections or even the previous command (e.g. if I jacked-in, it should offer to jack-in, if I connected to a running REPL, offer to do that, etc).
It's worth breaking this into 2 endeavors, with the latter being the supplemental or follow-up task.
- Offer REPL connection if REPL-less evals are attempted
- New Command, default for the above (maybe): "Reattempt most recent REPL connection type" or something.
I wonder how hard the first would really be... 🤔
I wonder how hard the first would really be
It's pretty easy. The users can do it themselves, even. Bind the evaluation command shortcuts to the command Start or Connect to a Clojure REPL with the same when clause as they have now, only with a bang before calva:connected. Here's the keybindings.json snippet for evaluate current and top level forms:
{
"key": "ctrl+enter",
"command": "calva.startOrConnectRepl",
"when": "!calva:connected && calva:keybindingsEnabled && editorTextFocus && !suggestWidgetVisible && editorLangId == 'clojure'"
},
{
"key": "alt+enter",
"command": "calva.startOrConnectRepl",
"when": "!calva:connected && calva:keybindingsEnabled && editorTextFocus && !suggestWidgetVisible && editorLangId == 'clojure'"
}
Calva will remember the different choices in the connect sequence menus, so it will basically be some enter presses in a row and you are connected.
@riotrah as for your suggestion to making a re-connect to last project type the default, we think we know how to do it somewhat cleanly. Stay tuned! 😄