This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-06-20
Channels
- # ai (4)
- # aleph (1)
- # babashka (127)
- # beginners (89)
- # calva (44)
- # cider (22)
- # clerk (74)
- # clj-commons (5)
- # clj-kondo (3)
- # cljs-dev (51)
- # clojure (117)
- # clojure-europe (22)
- # clojure-nl (2)
- # clojure-norway (100)
- # clojure-uk (2)
- # clojurescript (64)
- # data-science (26)
- # datalevin (3)
- # datascript (2)
- # emacs (10)
- # events (5)
- # figwheel-main (12)
- # helix (2)
- # honeysql (15)
- # hoplon (3)
- # jobs-discuss (32)
- # malli (3)
- # polylith (3)
- # re-frame (2)
- # reitit (15)
- # releases (2)
- # sci (14)
- # shadow-cljs (14)
- # specter (2)
- # tools-build (7)
- # xtdb (16)
Hello, I am brand new so apologies if I am doing something wrong, I read the dos as best I can 🙂 I have a ClojureScript project and am using Visual Studio code with figwheel-main. I tried running the command "Start a project REPL and connect" but can't get it to work. I get the following error message:
⚡️ Starting the REPL ⚡️ using the below command line:
pushd /Users/nsadeh/Desktop/clj-projects/evolved-pcb ; clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"1.0.0"},cider/cider-nrepl {:mvn/version,"0.28.5"},cider/piggieback {:mvn/version,"0.5.3"}}}' -M:build ; popd
Exception in thread "main"
java.io.FileNotFoundException: Could not locate figwheel/main__init.class, figwheel/main.clj or figwheel/main.cljc on classpath.
at clojure.lang.RT.load(RT.java:466)
at clojure.lang.RT.load(RT.java:428)
at clojure.core$load$fn__6824.invoke(core.clj:6126)
at clojure.core$load.invokeStatic(core.clj:6125)
at clojure.core$load.doInvoke(core.clj:6109)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invokeStatic(core.clj:5908)
at clojure.core$load_one.invoke(core.clj:5903)
at clojure.core$load_lib$fn__6765.invoke(core.clj:5948)
at clojure.core$load_lib.invokeStatic(core.clj:5947)
at clojure.core$load_lib.doInvoke(core.clj:5928)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$load_libs.invokeStatic(core.clj:5985)
at clojure.core$load_libs.doInvoke(core.clj:5969)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$require.invokeStatic(core.clj:6007)
at clojure.main$main_opt.invokeStatic(main.clj:491)
at clojure.main$main_opt.invoke(main.clj:487)
at clojure.main$main.invokeStatic(main.clj:598)
at clojure.main$main.doInvoke(main.clj:561)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:705)
at clojure.main.main(main.java:37)
Jack-in process exited. Status: 1
When I run clj -A:fig:build
I build just fine.When you start the REPL, does it show you a select list of aliases you can enable for Calva to use? It seems like you've selected :build
but not :fig
?
If :fig
has :main-opts
, you'll want to do something like copy :fig
as :fig-main
in your deps.edn
file, then remove the :main-opts
option from :fig
.
Then you can select :build
and :fig
in Calva, and use clojure -A:fig-main:build
from the command-line.
omg that's exactly it I am still at the stage where I mostly copy and paste build commands from the internet without understanding what they do. I learned something, thank you!
Follow up: how do I evaluate in line after I start Calva? That's why I wanted it do it in the first place
Hard to say without a bit more information. Is the repl connected at this point? The word REPL should be highlighted in a different color. Your cursor/focus should be in a Clojure file (`.clj`).
Apparently the correct lauch sequence was to check :fig but not :build. Now it works like a charm!
FWIW, I got frustrated in the middle and tried bootstrapping a shadow-cljs project instead of the figwheel and it was much quicker to get setup than figwheel so I might go with that for my next cljs project (a mobile app)
I believe Calva has better support for shadow than figwheel. I personally like the simplicity of figwheel but shadow is definitely way more popular and seems much more actively maintained because of that...
There are lots of ClojureScript tutorials out there, all different. Some use the older version of Figwheel (before figwheel-main). The older the tutorial, the less likely it is to still work. There have been lots of changes in the cljs ecosystem and tooling over the years 😐
This is the bootstrap command:
clj -X:new :template figwheel-main :name learn-cljs/weather :args '["+deps" "--reagent"]'
so I am inclined to believe it just uses figwheel-main’s current templateThat is only a couple of years old so it should be pretty up-to-date, so you should be good with that.
Separately: I started the figwheel process in my terminal successfully with clj -A:fig:build
. In VSCode I run the command "Start or connect to a Clojure REPL" with port 9500, which is the port that the cljs app is on. However, this just hang without connecting. What am I doing wrong?
Maybe 9500 is the web-serving port that you're meant to visit with a web browser? In that case, the Clojure REPL port will be different. Its number might be different every time you start a REPL, and might be written to a hidden file in the project directory.
However, clj
should create an nrepl port file and Calva should find it, so you should have the correct port pre-filled in. Are you starting the repl in the right directory?
Is there a way to easily collapse the metadata block of function definitions with calva? I tend to write my tests as metadata and as they grow it'd be neat if I could easily collapse/expand them with a little chevron-like-thingy in the gutter.
VS Code has a code folding feature. It has no API, so we can’t automatically fold or expand the meta data, but you get that chevron thingy.
Manually folding each section still works all right for my use case though, thanks 🙂
Hello again! In this thread I learnt that there is an API for the folding: https://clojurians.slack.com/archives/CBE668G4R/p1687640798948849 It doesn’t look like what I was searching for, but that’s probably because the VS Code team are better at designing API:s than I am. The API is in the form of a https://code.visualstudio.com/api/references/vscode-api#FoldingRangeProvider, and I think that Calva already does most of the work for figuring those out, so shouldn’t be too much work to add support.
The folding ranges returned can have a type attached: comment
and region
. I’m thinking that if we use comment
for Rich comments (and possibly line comments too) and region
for the attribute map of functions. Then you could use the Fold all Regions command to fold those inline tests.
It will make me more willing to go back to using inline tests too, because I find them a bit distracting when they are always visible. I say, even though I find myself doing things like this:
(defn ms->minutes
"NB: Assumes zero is plural"
{:rcf (comment [(ms->minutes (* 60 1000))
(ms->minutes (* 120 1000))
(ms->minutes (* 59 1000))])}
[ms]
(let [m (quot ms 60000)]
(apply tr
(if (= 1 m)
[:date-time/minute [m]]
[:date-time/minutes [m]]))))
😃
CC:
• @U9A1RLFNV
• @U09K620SG, because always good at reasoning around things like this
• @UKFSJSM38 because maybe this should be provided by #lsp @U0ETXRFEW https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_foldingRange indeed a folding request in LSP spec which is not supported by clojure-lsp yet, feel free to open an issue so we can discuss what foldings make sense, I feel like we would like to support folding functions and top-level forms, this meta folding could be something more
Cool! Here’s a feature request: https://github.com/clojure-lsp/clojure-lsp/issues/1602
Is it possible to have the customJackInCommandLine
code-workspace option to only execute the command as supplied instead of always starting in cmd.exe and using pushd and popd?
I want to use pwsh to start Calva etc with logging, which I have working in a separate shell but cant get to work inside VSCode.
Okay, thats something 😀 I run the pushd and popd in the pwsh command, but since it always starts in cmd.exe it wont work
Yeah thats not working out, it stops printing to console. Thing is that leiningen is a batch file so it always starts in cmd
I guess I don’t quite understand the precise problem here. It is also that Jack-in does have its limitations, and starting the repl yourself and connecting it is always an option. That’s what I do in many projects because I like to be able to reload the VS Code window without killing the app I am working with.
good point, I wanted to log the jackin output window due to long log outputs racing by 🙂 thats all
This works 🙂 pwsh -ExecutionPolicy ByPass -NoExit -Command {pushd path\to\project\folder ; lein update-in :dependencies conj '[nrepl,\"1.0.0\"]' -- update-in :plugins conj '[cider/cider-nrepl,\"0.28.5\"]' -- update-in [:repl-options,:nrepl-middleware] conj '["cider.nrepl/cider-middleware"]' -- with-profile +dev repl :headless | Tee-Object -FilePath ".\.pwsh\output.log" ; popd}