Thanks! Fabulous questions!
![]()
Seriously, we’ll probably (if Joyride gets any popular) do something for sharing around solutions at some point.
It’s a matter of convenience and leveraging existing tools. nREPL means Calva can be utilized as a REPL client (or CIDER, or any nREPL client). I’m not too familiar with ELisp and the usage patterns there, so can’t really compare.
You can evaluate the script pretty easily. And also evaluate arbitrary code with Joyride, so you don’t need to start the Joyride nREPL server. (Which could be tricky in a Clojure project, because of some Calva limitations.) You can use Joyride to make it more convenient than selecting code and pasting in the Joyride: Run Clojure Code… input box. E.g. if you have this in some library you load from your activate.cljs script:
(defn evaluate-selection []
(p/let [selection vscode/window.activeTextEditor.selection
document vscode/window.activeTextEditor.document
code (.getText document selection)
result (vscode/commands.executeCommand "joyride.runCode" code)]
result))
Then bind a key to it:
{
"key": "cmd+ctrl+enter",
"command": "joyride.runCode",
"args": "(my-lib/evaluate-selection)",
},
Now you can hit cmd+ctrl+enter with any selection. And have it evaluated. Say you have this Rich comment:
(comment
(->> 2
(+ 40)
(str "Th|e answer: ")
(vscode/window.showInformationMessage (str "The question?")))
)
(The vertical bar being the cursor.) Then press: ctrl+alt+w, space, cmd+ctrl+enter to get:
(ctrl+alt+w, space are default Calva bindings for selecting the current top level form.)
We will be adding some API to Calva that will make it more powerful to leverage its structural commands programmatically. But already you could give yourself an Evaluate Top Level Form command by binding some key to:
(defn evaluate-top-level-form []
(p/let [_ (vscode/commands.executeCommand "paredit.rangeForDefun")]
(evaluate-selection)))
You can’t use just any dependencies. The built in ones you can just require. Placing libraries in the classpath (which is either the user or workspace script directories) you can use them as long as they are compatible with SCI and how Joyride uses SCI. (It should even be possible to create your own m2 directory there and write some Joyride code to populate it, afaiut.) I think we need to make some updates to Joyride to get all built-in sci-configs goodness that nbb users enjoy. @borkdude knows more about that. As also the question about npm dependencies. I think that in theory you should be able to do that. It might require some changes on Joyride to enable it. Let’s see what Michiel says about it!.
