bhauman / figwheel-main

Figwheel Main provides tooling for developing ClojureScript applications
https://figwheel.org
Eclipse Public License 1.0
640 stars 93 forks source link

Docs request - Cursive integration via nREPL #112

Open tslocke opened 6 years ago

tslocke commented 6 years ago

I notice the old :nrepl-port options is not there in figwheel-main. Is nREPL supported?

I got Cursive integration going in no time with the current docs, but right now the clojure.main REPL integration in Cursive is lacking compared to nREPL. e.g. no formatting/coloring of result values.

Failing that, is there any way to have a regular figwheel REPL in a terminal window, and still have the Cursive integration? e.g. so I can send forms from my source code directly to the REPL.

Thanks!

ghost commented 6 years ago

Might be related to #24.

yogthos commented 5 years ago

I'd be interested to know this as well. Currently, I start Figwheel and connect to the nREPL port from Cusrve, then run figwheel-sidecar.repl-api/cljs-repl to switch to the ClojureScript REPL. What's the Figwheel Main alternative to that?

kwladyka commented 5 years ago

Current solution: image

It works with only this and regular Cursive version (not alpha).

https://figwheel.org/docs/cursive.html makes even more confusion. It needs update.

blak3mill3r commented 4 years ago

Ouch, just discovering this after trying to start a new project using figwheel-main.

Lacking a way to run with nREPL and piggieback makes this a poor substitute for the venerable figwheel... it seems like a major shortcoming to me, since I won't have CIDER+cljs and figwheel at the same time. I suppose I am in a minority of figwheel users here, but I know I'm not alone in wanting piggieback+nREPL+figwheel.

Would anyone who knows more about this care to comment on what would be involved in adding this, or why it is not supported in figwheel-main?

ivarref commented 4 years ago

Hi,

and thanks to @bhauman for a very fine project!

Here is my take on figwheel.main + Cursive:

  1. Add a nrepl alias to deps.edn:
...
           :nrepl {:extra-paths ["dev"]
                   :extra-deps  {nrepl/nrepl      {:mvn/version "0.7.0"}
                                 cider/piggieback {:mvn/version "0.5.0"}}
                   :main-opts   ["--main" "nrepl.cmdline"
                                 "--middleware" "[cider.piggieback/wrap-cljs-repl]"
                                 "--port" "5600"
                                 "--headless"]}
  1. dev/user.clj should look like the following:
(ns user
  (:require [figwheel.main.api :as fig]))

(defn cljs-repl []
  (fig/start "app")) ; "app" is the build profile
  1. Launch the headless nREPL server in the terminal: clj -A:dev:nrepl

  2. Connect to remote nREPL://localhost:5600 in Cursive.

  3. Evaluate (cljs-repl) in the REPL.

Output should be something like:

Connecting to remote nREPL server...
Clojure 1.10.1
(cljs-repl)
Prompt will show when REPL connects to evaluation environment (i.e. a REPL hosting webpage)
Figwheel Main Controls:
          (figwheel.main/stop-builds id ...)  ;; stops Figwheel autobuilder for ids
          (figwheel.main/start-builds id ...) ;; starts autobuilder focused on ids
          (figwheel.main/reset)               ;; stops, cleans, reloads config, and starts autobuilder
          (figwheel.main/build-once id ...)   ;; builds source one time
          (figwheel.main/clean id ...)        ;; deletes compiled cljs target files
          (figwheel.main/status)              ;; displays current state of system
Figwheel REPL Controls:
          (figwheel.repl/conns)               ;; displays the current connections
          (figwheel.repl/focus session-name)  ;; choose which session name to focus on
In the cljs.user ns, controls can be called without ns ie. (conns) instead of (figwheel.repl/conns)
    Docs: (doc function-name-here)
    Exit: :cljs/quit
 Results: Stored in vars *1, *2, *3, *e holds last exception object
Opening URL http://localhost:9500
To quit, type: :cljs/quit
=> nil

In the headless nREPL server terminal you should see something like:

2020-05-11 11:35:20.533:INFO::main: Logging initialized @4062ms to org.eclipse.jetty.util.log.StdErrLog
[Figwheel] Compiling build app to "target/public/cljs-out/app-main.js"
[Figwheel] Successfully compiled build app to "target/public/cljs-out/app-main.js" in 1.175 seconds.
[Figwheel] Watching paths: ("src" "example/src") to compile build - app
[Figwheel] Starting Server at http://localhost:9500
[Figwheel] Starting REPL

Thoughts or comments?

Kind regards.

antonmos commented 3 years ago

For Leiningen: