calva icon indicating copy to clipboard operation
calva copied to clipboard

[Feature Request] Offer to connect when evaluating forms while disconnected

Open orestis opened this issue 3 years ago • 2 comments

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).

orestis avatar Jan 20 '22 11:01 orestis

It's worth breaking this into 2 endeavors, with the latter being the supplemental or follow-up task.

  1. Offer REPL connection if REPL-less evals are attempted
  2. New Command, default for the above (maybe): "Reattempt most recent REPL connection type" or something.

I wonder how hard the first would really be... 🤔

riotrah avatar Apr 14 '22 22:04 riotrah

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.

PEZ avatar Apr 15 '22 14:04 PEZ

@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! 😄

PEZ avatar Jan 09 '24 17:01 PEZ