Dear Calva-friends: v2.0.186 just out https://github.com/BetterThanTomorrow/calva/releases/tag/v2.0.186, see also #releases for an extract of the last two weeks of changes.
Hello! How to get a ClojureScript REPL in Calva without using Figwheel or shadow-cljs?
I want to connect it to the hello-world project of ClojureScript's "Quick Start" guide (https://clojurescript.org/guides/quick-start).
I can't figure out how to get it working.
(In another project I have Calva with Figwheel working fine, but I would like to have this hello-world project with the minimum and simplest setup.)
@xavi: This is a stupid omission in the default jack-in/connect sequences that should be fixed. Please feel invited to add an issue about it. However, all is not lost, you can define this as a custom sequence. It would look like so in .vscode/settings.json
:
{
"calva.replConnectSequences": [
{
"projectType": "deps.edn",
"name": "plain cljs repl",
"cljsType": {
"dependsOn": "User provided",
"connectCode": "(do (require 'cljs.repl.node) (cider.piggieback/cljs-repl (cljs.repl.node/repl-env)))"
}
}
]
}
Then jack in and select plain cljs repl
as the Project type.Great, thank you! I got the cljs꞉cljs.user꞉>
prompt and it works.
I have another problem now, though it doesn't seem related to Calva...
Ask it anyway 😃
That connect sequence doesn't open a web server, so I'm trying to start one from the command line using
clj -m cljs.main --serve
and i get...WARNING: When invoking clojure.main, use -M
Serving HTTP on localhost port 9000
Exception in thread "Thread-1" java.lang.NullPointerException: Cannot invoke "java.util.concurrent.Future.get()" because "fut" is null
...
Exception in thread "Thread-2" java.lang.NullPointerException: Cannot invoke "java.util.concurrent.Future.get()" because "fut" is null
Any idea ? (this invocation also appears in https://clojurescript.org/guides/quick-start )
The connect sequence doesn’t connect a browser repl either. But that is a later problem for when you have gotten the cljs app running in the browser. I’ll see if I have any idea….
Actually, it seems to be a matter of starting a browser repl. Make the settings look like so
{
"calva.replConnectSequences": [
{
"projectType": "deps.edn",
"name": "plain cljs node repl",
"cljsType": {
"dependsOn": "User provided",
"connectCode": "(do (require 'cljs.repl.node) (cider.piggieback/cljs-repl (cljs.repl.node/repl-env)))"
}
},
{
"projectType": "deps.edn",
"name": "plain cljs browser repl",
"cljsType": {
"dependsOn": "User provided",
"connectCode": "(do (require 'cljs.repl.browser) (cider.piggieback/cljs-repl (cljs.repl.browser/repl-env)))"
}
}
]
}
Then jack in again, choosing the browser project type.Yes! That works for me... and I can get the cljs app running in the browser using "Calva: Load current file and dependencies" with the hello_world/core.cljs file
Awesome.
In a full-stack clj/cljs app with its own web server, this setup would work too? Anyway, i'll try later today. I'll also open an issue to have this "plain cljs browser repl" connect sequence built-in
Thanks!
Anyone know of any pretty-clojure-symbols for VS Code, like pretty-symbol for cursive?
Hi ! I'm using this one: https://marketplace.visualstudio.com/items?itemName=siegebell.prettify-symbols-mode
Nowadays, i'm only using this substitution:
"prettifySymbolsMode.substitutions": [
{
"language": "clojure",
"prettifySymbolsMode.renderOn": "none",
"prettifySymbolsMode.revealOn": "none",
"prettifySymbolsMode.prettyCursor": "none",
"prettifySymbolsMode.adjustCursorMovement": true,
"substitutions": [
{
"ugly": "fn",
"pretty": "λ",
"pre": "\\(",
"post": "\\s\\[",
"style": {
"color": "#B877DBE6"
}
}
]
}
]
thanks, i never found that one when I was looking!
U're welcome ! It's very easy to use 🙂
What does pretty-symbol do?
it replaces some character combinations with single character, e.g.
that gate symbol is let, the f is defn
Yes, full stack should just work. There is both a Clojure and ClojureScript REPL there. If you create a .clj
file it will be using the Clojure REPL. And if you create a .cljc
file you can toggle which REPL it should be connected to. There’s even a button in the status bar for this.
anonymouse functions look like this
fira code does some of it for me, but its general font stuff not clojure specific obviously
Haha, how awful. 😃 There are fonts that do this. Like Tonsky’s FIRA Code. However, last time I checked it didn’t have a lambda symbol, and Tonsky didn’t plan to add it, because it is not wide enough.
😄
I find things that reduce the amnount of code I have to read makes understanding stuff easier for me
I think things like defn / let / fn / set add to the noise
Yeah, that’s the rationale behind FIRA Code as well. I tried it. Got super confused and dropped it. 😃
Let’s see if someone else knows what options there are for this.
@pez, i've switched to calva from cursive / ideaj and won't be going back! Calva really is wonderful. IdeaJ would crash and hang a lot, would struggle if a clojure file got over 1000 lines or so. Support for CLJS was annoying at times. Calva is just great, it all just works and getting repl evals to show inline in the editor, fantastic! Really great job dude, i love it
Thanks! Please consider filing a review. Link in the channel topic.
Hello 👋:skin-tone-2: what is the correct way to configure clj-kondo/clojure-lsp linter with Calva? The clj-kondo and clojure-lsp docs differ a little bit. I want to ignore unused-public-var warning and I tried to place my config {:linters {:unused-public-var {:exclude #{prode.extension/reload}}}}
under ./lsp/config.edn
./clj-kondo/config.edn
but that didn’t seem to help
You should follow this section: https://clojure-lsp.github.io/clojure-lsp/settings/#diagnostics-linter
@janne.sauvala That linter is not a clj-kondo thing, it's implemented by LSP
Damn, you are fast :)
@janne.sauvala the unused-public-var is the only linter implmenented on clojure-lsp side, the rest is from clj-kondo, so you just need to change your .lsp/config.edn
if you want to change its behaviour
Thanks! Are you both just chilling here waiting for newbies to ask questions? 😄
hahaha I have configured my slack to warn about any metion to clojure-lsp or lsp 😄
probably borkdude did the same for clj-kondo haha
you got me
Great, this feels like some paid support service 🙂
It makes you wonder, if clj-kondo is free and our support is free, you must be paying with something else...
And you pay with love. 😃
Ah, that must be it then ;)
okay I have my config in the .lsp/config.edn
but I still see the linter warning… Does Calva automagically pick the config up or do I need to do something?
John Lennon was right!
I think you need to reload the VS Code window.
@janne.sauvala You need to restart clojure-lsp, closing/re-opening vscode will do that, not sure there is a command for that
So, you don’t need to restart vscode, just FYI.
right! I reloaded the window and now the warning went away like it should 🙂
thanks all 3 of you!
I have an idea to remove that need to restart clojure-lsp in the future :)
You can pay with an issue on Calva to support reloading of clojure-lsp w/o reloading the vscode window. 😃
Reloading clojure-lsp is quick though. It is losing your REPL session that is the too high price, imo.
Here you go: https://github.com/BetterThanTomorrow/calva/issues/1113 🙂
Thank you!
Oh, thanks for this issue. And super that you found that old issue. I pasted the node repl config there and closed it. (Since the reporter hasn’t been heard from in a while, we can’t really hope for a confirmation.)
Dear Calva friends. I hope the new Calva version (2.0.186) is treating you well. Now it is time to help me test a new VSIX again. It adds built in jack-in/connect sequences for plain CLJS REPLs (Browser and Node). It makes it much easier to follow the steps in the https://clojurescript.org/guides/quick-start using Calva. • VSIX: https://12811-125431277-gh.circle-artifacts.com/0/tmp/artifacts/calva-2.0.187-1114-add-vanilla-cljs-repl-sequences-3d416bdd.vsix • Issue addressed: https://github.com/BetterThanTomorrow/calva/issues/1114 • PR: https://github.com/BetterThanTomorrow/calva/pull/1115
Successfully tested the latest one (not the linked above), which changes "plain" with "built-in"...
(i don't like that macOS hides filename extensions... i couldn't install the .vsix
at first because although i thought i changed the .zip
extension to .vsix
, VS Code wouldn't allow me to install it... until I realized that macOS was hiding the real extension and now I had a .vsix.zip
. oh well )
Awesome. Thanks!
np, thanks to you!
Ping, @xavi, can you help test this for me?