Modify your editor by executing ClojureScript code in your REPL and/or run scripts via keyboard shortcuts you choose. The Visual Studio Code API is at your command!
A.Joyride.Example.-.Ignore.Form.Command.mp4
The video in much better quality on Youtube (CalvaTV)
Joyride is Powered by SCI (Small Clojure Interpreter).
You are entering a construction yard. Things are going to change and break your configs while we are searching for good APIs and UI/Ux.
Your feedback is highly welcome!
- Bring up the VS Code Command Palette (
cmd/ctrl+shift+p
) - Execute Joyride: Run Clojure Code
- Type in some code into the prompt, e.g.
(require '["vscode" :as vscode]) (vscode/window.showInformationMessage "Hello World!")`
- Submit
While developing Joyride scripts you should of course do it leveraging Interactive Programming (see this video demonstrating it). With Calva it is very quick to start a Joyride REPL and connect Calva to it. This video demonstrates starting from scratch, including installing Joyride.
Calva.Start.a.Joyride.REPL.and.Connect.-.Jack-in.mp4
The demo ”project” used here is only a directory with this file hello_joyride.cljs
. Here's the code, if you want to try it out yourself:
(ns hello-joyride
(:require ["vscode" :as vscode]
[promesa.core :as p]))
(comment
(+ 1 2 3 4 5 6 7 8 6)
(-> (vscode/window.showInformationMessage
"Come on, Join the Joyride!"
"Be a Joyrider")
(p/then
(fn [choice]
(println "You choose to:" choice)))))
"Hello World"
Joyride lets you bind keyboard shortcuts to its User and Workspace scripts.
- User Scripts:
<user home>/.config/joyride/scripts
- Workspace scripts:
<workspace root>.joyride/scripts
Let's go with a Workspace script:
Create a script in your workspace, e.g .joyride/scripts/example.cljs
:
(ns example
(:require ["fs" :as fs]
["path" :as path]
["vscode" :as vscode]
[clojure.string :as str]))
(defn info [& xs]
(vscode/window.showInformationMessage (str/join " " xs)))
(info "The root path of this workspace:" vscode/workspace.rootPath)
(fs/writeFileSync (path/resolve vscode/workspace.rootPath "test.txt") "written!")
This script gives one information message and writes to a file test.txt
in
your workspace.
Then in your keyboard shortcuts, add:
{
"key": "cmd+1",
"command": "joyride.runWorkspaceScript",
"args": "example.cljs"
}
Now you can run the example.cljs
script by just hitting Cmd+1!
See doc/configuration.md for full configuration options.
See the examples for examples including:
- Creating an interactive Webview
- Terminal creation and control
- Fontsize manipulation
- Calva Structural Editing enhancements
- Opening and showing project files
- Workspace activation script
- The Joyride Extension API
- The
joyride.core
namespace
You'll find us in the #joyride
channel on the Clojurians Slack
Follow the #vsjoyride hashtag on Twitter!