Comments (9)
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.
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.
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.
I forgot to mention, Joker is hooked up and seems to lints properly when there are errors.
from calva.
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.
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:
-
Open VSCode at the root of the project (where
project.clj
is located). From terminal, typecode .
. -
Open REPL terminal inside VSCode using cmd-shift-p: "Calva: Open REPL Terminal"
-
Lein projects: Start REPL from this new terminal:
lein repl
-
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.
The issue seems to be related to Piggieback. The shadom-re-frame
project 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.
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 repl
and 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.
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)
- Getting Started REPL fails when there is no folder open HOT 4
- Always include the project creation commands in the REPL menu
- Automatically reveal the configured result output destination on REPL connect
- Do not open auto open the jack-in terminal by default
- Send load/evaluate current file results to the inspector
- Don't show Calva says output channel by default
- Default to reveal the Calva inspector on repl connect
- Add configuration for automatically starting and connecting the project REPL
- add devcontainer setup to mini-project creation
- Powershell sometimes used for jack-in on windows, and it doesn't work
- Remove remaining references to the Output Window HOT 1
- Stop offering to use existing temp files when creating a project
- Joyride jack-in/connect warns about `cljs.repl` not found
- Version 2.0.461 of Calva breaks deps.edn jack-in on some Windows machines HOT 3
- Stop the test runner from loading the test namespace before running tests HOT 1
- Make the user aware about errors during jack-in
- Report progress waiting for shadow-cljs runtimes without printing to output
- Only alert if the Jack-in process is interrupted before the repl is started
- Refactorings not working from Command Palette or shortcut - when the file URL includes embedded spaces
- Connecting to running REPL fails if project has never had Calva REPL file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from calva.