Coder Social home page Coder Social logo

Comments (9)

jefffriesen avatar jefffriesen commented on September 1, 2024 2

Thanks @pedrorgirardi! I got both working.

shadow-cljs: I added [cider/cider-nrepl "0.17.0"] to shadow-cljs.edn, restarted everything and it worked.

figwheel: I added the :profiles map you suggested into project.clj. Ran lein clean & lein deps and restarted everything.

Hover, Peek and Go to all work.

I wonder how we can make this easier and clearer to set up. You've spent a lot of time on documentation and I looked at it carefully, but I still missed it. I'm willing to look at docs again tomorrow or you might have some ideas.

Thanks again.

from calva.

pedrorgirardi avatar pedrorgirardi commented on September 1, 2024

Hi @jefffriesen ! Could you please try to run the command Calva: Evaluate current file and then see if Go to Definition works (hovering should work too)?
Calva 'asks' the nREPL server for information about the symbol, but until you've loaded the file, the nREPL server doesn't have any information about it.

Let us know if that doesn't work for you :)

from calva.

jefffriesen avatar jefffriesen commented on September 1, 2024

Hmmm.... evaluating the file didn't fix it. But more intestinally, it didn't seem to do anything. It doesn't show inline values, it doesn't send results to the REPL. I even have a

(js/console.log "xoxo")

In the file and executing Calva: evaluate current file it doesn't show up in the console of the running browser with the app. However, saving the file prints xoxo to the browser console. So does executing Calva: evaluate selection or current form. So AFAICT, the cljs REPL is hooked up properly.

I looked at the Output pane after evaluating a file:

No results from file evaluation.
Evaluating file: /Users/jeffers/git/jefffriesen/radiant-permits/src/cljs/radiant_permits/views/header.cljs
=> nil

Where the file is this:

(ns radiant-permits.views.header)

(defn header []
  [:div.ui.header.inverted
    [:h3.lightfont "subtitle: "
      [:span.heavyfont "title"]]])

(apply map vector [[:a :b :c]
                   [:d :e :f]
                   [:g :h :i]])

But evaluating core.cljs gives an error:

Evaluating file: /Users/jeffers/git/jefffriesen/radiant-permits/src/cljs/radiant_permits/core.cljs
Error, unable to evaluate file: clojure.lang.ExceptionInfo: radiant-permits.views does not exist {:cljs.repl/error :invalid-ns}

No results from file evaluation.

With this as the file:

(ns radiant-permits.core
  (:require
   [reagent.core :as reagent]
   [re-frame.core :as re-frame]
   [radiant-permits.events :as events]
   [radiant-permits.views :as views]
   [radiant-permits.config :as config]))

(defn dev-setup []
  (when config/debug?
    (enable-console-print!)
    (println "dev mode")))

(defn mount-root []
  (re-frame/clear-subscription-cache!)
  (reagent/render [views/main-panel]
                  (.getElementById js/document "app")))

(defn ^:export init []
  (re-frame/dispatch-sync [::events/initialize-db])
  (dev-setup)
  (mount-root))

(defn tester []
  (+ 1 11))

(tester)

(js/console.log "xoxo")

(apply map vector [[:a :b :c]
                   [:d :e :f]
                   [:g :h :i]])

from calva.

jefffriesen avatar jefffriesen commented on September 1, 2024

I forgot to mention, Joker is hooked up and seems to lints properly when there are errors.

from calva.

PEZ avatar PEZ commented on September 1, 2024

I think this could be a dependancy issue. Calva is still very sensitive to all middleware being setup correctly. Are you using Figwheel or shadow-cljs?

I have this in my profiles.clj which sets up things for Clojure and Figwheel projects (and shadow-cljs brings in all middleware it needs once it sees the cider-nrepl dependency):

{:repl {:plugins [[cider/cider-nrepl "0.17.0"]]
        :dependencies [[org.clojure/tools.nrepl "0.2.13"]
                       [cider/piggieback "0.3.5"]
                       [figwheel-sidecar "0.5.16"]]
        :repl-options {:nrepl-middleware [cider.piggieback/wrap-cljs-repl]}}}

from calva.

jefffriesen avatar jefffriesen commented on September 1, 2024

Ok, this may be in part due to my lack of Clojure experience. I can't tell if your :repl config above is actually suppose to be inside {:user {:repl .... in profiles.clj or if it's adjacent to it. This was my original profiles.cljs

{:user {:aliases {"slamhound" ["run" "-m" "slam.hound"]}
        :plugins [[lein-pprint "1.1.1"]
                  [lein-bikeshed "0.5.1"]
                  [lein-auto "0.1.2"]
                  [lein-ancient "0.6.7"
                   :exclusions [com.fasterxml.jackson.dataformat/jackson-dataformat-smile
                                org.clojure/clojure
                                cheshire com.fasterxml.jackson.core/jackson-core]]]

        :dependencies [[org.clojure/tools.namespace "0.2.11"]
                       [org.clojure/tools.nrepl "0.2.12"]
                       [org.clojure/tools.trace "0.7.8"]
                       [pjstadig/humane-test-output "0.8.0"]
                       [slamhound "1.5.5"]
                       [spyscope "0.1.6"]]

        :injections [(require 'spyscope.core)]

        :repl {:plugins [[cider/cider-nrepl "0.17.0"]]}}}

I also tried this:

{:user {:aliases {"slamhound" ["run" "-m" "slam.hound"]}
        :plugins [[lein-pprint "1.1.1"]
                  [lein-bikeshed "0.5.1"]
                  [lein-auto "0.1.2"]
                  [lein-ancient "0.6.7"
                   :exclusions [com.fasterxml.jackson.dataformat/jackson-dataformat-smile
                                org.clojure/clojure
                                cheshire com.fasterxml.jackson.core/jackson-core]]]

        :dependencies [[org.clojure/tools.namespace "0.2.11"]
                       [org.clojure/tools.nrepl "0.2.12"]
                       [org.clojure/tools.trace "0.7.8"]
                       [pjstadig/humane-test-output "0.8.0"]
                       [slamhound "1.5.5"]
                       [spyscope "0.1.6"]]

        :injections [(require 'spyscope.core)]

        :repl {:plugins [[cider/cider-nrepl "0.17.0"]]}}}

{:repl {:plugins [[cider/cider-nrepl "0.17.0"]]
        :dependencies [[org.clojure/tools.nrepl "0.2.13"]
                       [cider/piggieback "0.3.5"]
                       [figwheel-sidecar "0.5.16"]]
        :repl-options {:nrepl-middleware [cider.piggieback/wrap-cljs-repl]}}}

Now I get a new error when trying to start the cljs repl. Steps:

  1. Open VSCode at the root of the project (where project.clj is located). From terminal, type code ..

  2. Open REPL terminal inside VSCode using cmd-shift-p: "Calva: Open REPL Terminal"

  3. Lein projects: Start REPL from this new terminal: lein repl

  4. Start figwheel from REPL

 (use 'figwheel-sidecar.repl-api)
 (start-figwheel!)
 (cljs-repl)

The error I get when running (cljs-repl):

...
Results: Stored in vars *1, *2, *3, *e holds last exception object
Prompt will show when Figwheel connects to your application
!!! Unable to load a ClojureScript nREPL middleware library

Exception Failed to launch Figwheel CLJS REPL: nREPL connection found but unable to load piggieback.
This is commonly caused by
 A) not providing piggieback as a dependency and/or
 B) not adding piggieback middleware into your nrepl middleware chain.

example profile.clj code:
-----
:profiles {:dev {:dependencies [[cider/piggieback <current-version>]
                                [org.clojure/tools.nrepl  <current-version>]]
                 :repl-options {:nrepl-middleware [cider.piggieback/wrap-cljs-repl]}}}
-----
Please see the documentation for piggieback here https://github.com/clojure-emacs/piggieback#installation

Note: Cider will inject this config into your project.clj.
This can cause confusion when your are not using Cider.  figwheel-sidecar.repl/eval21243/fn--21244 (repl.clj:182)

shadow-cljs

I've cloned this repo and ran it successfully: https://github.com/mhuebert/shadow-re-frame. Similarly, the cljs repl seems to work. From the code, I can send (js/console.log "hi") to the running re-frame app by executing Calva: evaluate selection or current form. I can also send it from the REPL to the browser console and it works. That indicates the REPL is working properly?

Peek and goto definition still do not work though ("No definition found for ..." error).

Another clue: "or current form"

When executing Calva: evaluate selection or current form it will only work if the entire sexp is selected. If the cursor is only in the middle of a sexp with nothing selected, it won't evaluate. Maybe that is another indication that Calva isn't actually parsing the code?

Thanks for your help. I can try more suggestions if you have them.

from calva.

pedrorgirardi avatar pedrorgirardi commented on September 1, 2024

The issue seems to be related to Piggieback. The shadom-re-frameproject works because Shadow CLJS has its own ClojureScript REPL, BUT the 'Go to Definition' doesn't work because you don't have the cider/cider-nrepl dependency - without CIDER there is no nREPL middleware to handle the symbol information operation.
Could you try to add the cider/cider-nrepl dependency to the shadow-re-frame project?

from calva.

pedrorgirardi avatar pedrorgirardi commented on September 1, 2024

Funny, I've seen the Exception Failed to launch Figwheel CLJS REPL: nREPL connection found but unable to load piggieback. error before, but I could't reproduce now.

This is what my project.clj looks like:

:profiles {:repl {:plugins      [[cider/cider-nrepl "0.17.0"]]

                    :dependencies [[org.clojure/tools.nrepl "0.2.13"]
                                   [cider/piggieback "0.3.5"]]

                    :repl-options {:timeout          300000
                                   :nrepl-middleware [cider.piggieback/wrap-cljs-repl]}}

             :dev  {:dependencies [[binaryage/devtools "0.9.10"]
                                   [figwheel-sidecar "0.5.16"]
                                   [re-frisk "0.5.4" :exclusions [re-com]]
                                   [devcards "0.2.5" :exclusions [cljsjs/react com.cognitect/transit-clj]]]}}

I started a REPL from the terminal with lein repland then the same as you did:

(start-figwheel! "dev")
(cljs-repl)

I have that in my user.clj so it actually looks like:

(ns user
  (:require [figwheel-sidecar.repl-api :refer [start-figwheel! cljs-repl]]))


(defn start-cljs! []
  (start-figwheel! "dev")
  (cljs-repl))

from calva.

pedrorgirardi avatar pedrorgirardi commented on September 1, 2024

That's great @jefffriesen, I'm very glad that you got it working!

You're right, we really need to find a better way to document the nREPL integration. Peter has been thinking about it as well and it would be great to hear your suggestions & feedback.

from calva.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.