This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-21
Channels
- # announcements (1)
- # beginners (20)
- # biff (5)
- # calva (43)
- # cider (5)
- # clj-commons (7)
- # clj-kondo (11)
- # clojure (58)
- # clojure-brasil (1)
- # clojure-denmark (1)
- # clojure-europe (27)
- # clojure-nl (1)
- # clojure-norway (13)
- # clojure-uk (2)
- # clojurescript (71)
- # data-science (32)
- # datalevin (6)
- # datomic (19)
- # emacs (1)
- # gratitude (3)
- # honeysql (8)
- # hoplon (15)
- # hyperfiddle (3)
- # introduce-yourself (1)
- # lsp (19)
- # malli (4)
- # nbb (7)
- # other-lisps (5)
- # practicalli (1)
- # re-frame (14)
- # releases (1)
- # ring-swagger (1)
- # squint (118)
- # xtdb (9)
- # yada (2)
Is it possible to configure what browser to start, not just default one, on Clojurescript app start?
Denis, I don't know, but this Ask Clojure page https://ask.clojure.org/index.php/751/clojure-java-shell-sh-hangs-calling-xdg-open refers to using xdg-open "on some platforms", in which case it would be an OS configuration.
Calva has a setting for wether the Figwheel app should be opened automatically or not. It defaults to true
. So you can at least stop it from opening in the wrong browser. There are probably OS apps that let you configure which app is opened for some URL pattern. On Mac I use Choosy.
I sometimes work on non-Clojure projects in Visual Studio Code. For example, JavaScript or TypeScript codebases. Whenever I open one of these non-Clojure projects, the .clj-kondo
and .lsp
directories are created. I don't know exactly what creates those (is it Calva?). Is it possible to configure Calva (or clj-kondo
or clojure-lsp
) not to create those directories for non-Clojure projects? For example, check whether a deps.edn
, bb.edn
, or any .clj[s]
files exist in the project directory tree before "activating."
FWIW clj-kondo never creates unwanted .clj-kondo directories, so I think it's lsp
Yes, clojure-lsp creates that on purpose so hooks and other things can be copied so your experience with your project is smooth and with no false positives
It’s Calva responsible for starting clojure-lsp, so our investigation should start there. Calva shouldn’t activate in non-Clojure projects. It doesn’t for me. A Clojure project is here defined as some Clojure file is found.
Oh! Interesting. Maybe there is something funky with my installation or environment. checking stuff
Oooh! I found out it was actually #C03DPCLCV9N and not #CBE668G4R creating those dirs.
Hmmm, not really. But Joyride could trigger Calva to start maybe. Has this started to happen recently? I’ve been updating how Joyride creates clojure-lsp config the last few days.
I believe it's always behaved like that on my system, but it didn't bother me enough to ask until recently, because I just started using VS Code for non-Clojure stuff this week.
But when I disable the Joyride extension, then those dirs are no longer created in non-Clojure projects.
Oh! Interesting. When I disable Calva, but leave Joyride enabled, then those dirs are also not created.
Sounds strange. I always have Joyride enabled and never see it trigger Calva to start in non-Clojure projects.
Yes, so the order that things are happening in is: 1. Something triggers Calva to start 2. Calva starts clojure-lsp 3. clojure-lsp creates those directories.
Hmmm. Maybe I've borked some VS Code or extension setting somewhere. looking for evidence
Well, you sort of proved that on your machine Joyride triggers Calva to start. So we need to find out how that happns.
Here is the output from a clean startup of VS Code (using code .
in the project root dir):
Welcome to Calva. Happy Clojure and ClojureScript coding! :heart:
Please check these resources out:
Calva Documentation:
#calva at the Clojurians Slack:
Bug reports:
If you like Calva, please consider how you can contribute:
Calva is utilizing cider-nrepl and clojure-lsp to create this VS Code experience.
nREPL dependencies configured:
nrepl: 1.0.0
cider-nrepl: 0.28.5
cider/piggieback: 0.5.3
clojure-lsp version configured: latest
If you are new to Calva, please see:
And please consider the command: **Calva: Fire up the Getting Started REPL**
Calva version used: v2.0.399
clojure-lsp version used: 2023.10.30-21.15.51-nightly
clj-kondo version used: 2023.10.21-SNAPSHOT
It also happens when I open the project dir via the graphical user interface instead of the command line, so the method for launching VS Code seems unrelated.
It actually happens in any dir, even an empty one.
pwd
/Users/leif/Code/empty-dir
tree -a .
.
├── .clj-kondo
│ └── .cache
│ └── v1
│ └── lock
└── .lsp
└── .cache
└── db.transit.json
Side note: I do have the Calva and Joyride codebases themselves cloned under ~/Code/
and I was experimenting a bit with those, so there is a nonzero chance that I've messed something up locally.
I have these joyride scripts:
pwd
/Users/leif/.config/joyride/scripts
tree -a .
.
├── activate.cljs
├── hello_joyride_user_script.cljs
├── hello_joyride_user_script.js
├── my_lib.cljs
└── user_activate.cljs
Checking them now…Aha! Found it. It was indeed my user_activate.cljs
that caused the issue. Interestingly, I can't recall making any changes to that file myself. I believe it's the default. If I were to venture a guess, I think it's this that causes it:
(defn- my-main []
(println "Hello World, from my-main in user_activate.cljs script")
(clear-disposables!) ;; Any disposables add with `push-disposable!`
;; will be cleared now. You can push them anew.
;;; MARK require VS Code extensions
;; In an activation.cljs script it can't be guaranteed that a
;; particular extension is active, so we can't safely `(:require ..)`
;; in the `ns` form. Here's what you can do instead, using Calva
;; as the example. To try it for real, copy the example scripts from:
;;
;; Then un-ignore the forms in the promise handler and run
;; *Joyride; Run User Script* -> activate.cljs
;; (Or reload the VS Code window.)
(-> (vscode/extensions.getExtension "betterthantomorrow.calva")
;; Force the Calva extension to activate
(.activate)
;; The promise will resolve with the extension's API as the result
(p/then (fn [_api]
(.appendLine (joyride/output-channel) "Calva activated. Requiring dependent namespaces.")
;; In `my-lib` and `z-joylib.calva-api` the Calva extension
;; is required, which will work fine since now Calva is active.
#_(require '[my-lib])
#_(require '[z-joylib.calva-api])
;; Code in your keybindings can now use the `my-lib` and/or
;; `z-joylib.calva-api` namespace(s)
;; Registering a symbols provider
#_(require '[z-joylib.clojure-symbols :as clojure-symbols])
;; Entering the Gilardi scenario.
#_(push-disposable! ((resolve 'clojure-symbols/register-provider!)))))
(p/catch (fn [error]
(vscode/window.showErrorMessage (str "Requiring Calva failed: " error))))))
I see https://github.com/BetterThanTomorrow/joyride/blob/6c6c0c287e7372ab5e258322311946ef4795c92a/assets/getting-started-content/user/scripts/user_activate.cljs#L89-L103 looks a bit different now, so maybe I had an old version hanging around.
Yeah, I may well have done that a long time ago and forgotten about it. Thanks for the help, and sorry for wasting your time on my human error.
I attempted to use Calva with a Clojure/ClojureScript project without figwheel or shadow and faced unexpected challenges. While I can access a REPL via command-line, Calva in VS Code fails to connect to its REPL upon jack-in. Is there any special handling for shadow-cljs and figwheel that I also need to do for this scenario?
Hi! Yes, you need to start the repl such that an nrepl server is started. Easiest way to do this is to use the Jack-in command and select the project type deps.edn + ClojureScript built in (browser or node, depending on your project. For this you need a deps.edn
file in the project root. Minimum content is something like
{:deps {org.clojure/clojurescript {:mvn/version "1.11.54"}}}
I've tried that, but I get: Exception in thread "Thread-119" java.net.SocketException and something like: An established connection was aborted by the software in your host machine.
This is not a problem when using shadow-cljs or when booting this project from the command-line
I wonder at what part in the process this happens. If you use the command for copying the jack-in command line, and then 1. use that command line to start the repl. 2. connect Calva Does it happen at 1? At 2? And if at the connect step, is there an attempt to open a web browser made, or does it crash before that? Also: When you start the project from the command line, how do you start the repl? How do you confirm that it is working?
It crashes at basically everything. VS code is probably doing something clever to make nix commands work on windows. Stripping away &
's and such, I get the error:
Error while parsing option "--config-data {:deps {nrepl/nrepl {:mvn/version,1.0.0},cider/cider-nrepl {:mvn/version,0.28.5},cider/piggieback {:mvn/version,0.5.3}}}": java.lang.NumberFormatException: Invalid number: 1.0.0