diff --git a/README.md b/README.md index 45a0dc8..d4095f0 100644 --- a/README.md +++ b/README.md @@ -27,61 +27,7 @@ babashka or Clojure JVM): ### nREPL -To connect to a Scittle nREPL server from your editor, follow these steps: - -In babashka or Clojure JVM, use the -[sci.nrepl](https://github.com/babashka/sci.nrepl) dependency and run: - -``` -(require 'sci.nrepl.browser-server :as nrepl) -(nrepl/start! {:nrepl-port 1339 :websocket-port 1340}) -``` - -This will run an nREPL server on port 1339 and a websocket server on port 1340. -Your editor's nREPL client will connect to port 1339 and your browser, running -scittle, will connect to port 1340. The nREPL server forwards messages to the -browser via the websocket connection. - -In your scittle website, you will need to include the following, in addition to -the normal routine: - -``` - - -``` - -Also include the CLJS file that you want to evaluate with nREPL: - -``` - -``` - -Then visit `cljs/script.cljs` in your editor and connect to the nREPL server, -and start evaluating! - -See the `resources/public/nrepl.html` file for an example. When you run `bb dev` -in this repository, and then open `http://localhost:1341/nrepl.html` you should -be able evaluate expressions in -`resources/public/cljs/nrepl_playground.cljs`. See a demo -[here](https://twitter.com/borkdude/status/1526285565343281159). - -### CIDER - -Currently when connecting from CIDER, you need to use this snippet: - -``` -(cider-register-cljs-repl-type 'sci-js "(+ 1 2 3)") - -(defun mm/cider-connected-hook () - (when (eq 'sci-js cider-cljs-repl-type) - (setq-local cider-show-error-buffer nil) - (cider-set-repl-type 'cljs))) - -(add-hook 'cider-connected-hook #'mm/cider-connected-hook) -``` - -Then choose `cider-connect-cljs`, select port `1339`, followed by the `sci-js` -REPL type. +See [doc/nrepl](doc/nrepl). ## Tasks diff --git a/doc/nrepl/README.md b/doc/nrepl/README.md new file mode 100644 index 0000000..595b86f --- /dev/null +++ b/doc/nrepl/README.md @@ -0,0 +1,61 @@ +# nREPL + +To connect to a Scittle nREPL server from your editor, follow these steps. The +setup described here, can be found in this directory. + +In babashka or Clojure JVM, use the +[sci.nrepl](https://github.com/babashka/sci.nrepl) dependency and run: + +``` +(require 'sci.nrepl.browser-server :as nrepl) +(nrepl/start! {:nrepl-port 1339 :websocket-port 1340}) +``` + +This will run an nREPL server on port 1339 and a websocket server on port 1340. +Your editor's nREPL client will connect to port 1339 and your browser, running +scittle, will connect to port 1340. The nREPL server forwards messages to the +browser via the websocket connection. + +In your scittle website, you will need to include the following, in addition to +the normal routine: + +``` + + +``` + +Also include the CLJS file that you want to evaluate with nREPL: + +``` + +``` + +Then visit `playground.cljs` in your editor and connect to the nREPL server, +and start evaluating! + +See the `index.html` file for an example. + +When you run `bb dev` in this directory, and then open `http://localhost:1341` +you should be able evaluate expressions in `playground.cljs`. See a demo +[here](https://twitter.com/borkdude/status/1526285565343281159). + +Note that the nREPL server connection stays alive even after the browser window +refreshes. + +### CIDER + +Currently when connecting from CIDER, you need to use this snippet: + +``` +(cider-register-cljs-repl-type 'sci-js "(+ 1 2 3)") + +(defun mm/cider-connected-hook () + (when (eq 'sci-js cider-cljs-repl-type) + (setq-local cider-show-error-buffer nil) + (cider-set-repl-type 'cljs))) + +(add-hook 'cider-connected-hook #'mm/cider-connected-hook) +``` + +Then choose `cider-connect-cljs`, select port `1339`, followed by the `sci-js` +REPL type. diff --git a/doc/nrepl/bb.edn b/doc/nrepl/bb.edn new file mode 100644 index 0000000..ddc1105 --- /dev/null +++ b/doc/nrepl/bb.edn @@ -0,0 +1,17 @@ +{:deps {io.github.babashka/sci.nrepl + {:git/sha "c14b5b4ef4390ff206cdb71f763f327799f5e853"} + io.github.babashka/http-server + {:git/sha "b38c1f16ad2c618adae2c3b102a5520c261a7dd3"}} + :tasks {http-server {:doc "Starts http server for serving static files" + :requires ([babashka.http-server :as http]) + :task (do (http/serve {:port 1341 :dir "."}) + (println "Serving static assets at http://localhost:1341"))} + + browser-nrepl {:doc "Start browser nREPL" + :requires ([sci.nrepl.browser-server :as bp]) + :task (bp/start! {})} + + -dev {:depends [http-server browser-nrepl]} + + dev {:task (do (run '-dev {:parallel true}) + (deref (promise)))}}} diff --git a/doc/nrepl/index.html b/doc/nrepl/index.html new file mode 100644 index 0000000..1882a05 --- /dev/null +++ b/doc/nrepl/index.html @@ -0,0 +1,13 @@ + + +
+ + + + + + +