Fork me on GitHub
#calva
<
2021-11-17
>
danieroux07:11:19

First time Calva user, Loading Current file and Dependencies for a .cljs file errors:

danieroux07:11:41

I have (only this) in dev/portal.cljs :

(ns tooling.portal
  (:require
   [portal.web :as p]))
Sending the file errors, with the screenshot. How do I debug/get to the bottom of this? This loads in Cursive. • It is a Generic connected REPL • From which I start Figwheel manually, once connected to the CLJ REPL • That starts a CLJS REPL that I can evaluate it happily. • If I copy and paste that snippet to the CLJS REPL, it works. And switches to the ns. • From there I can open a Web Portal too, so that all works.

pez07:11:52

Does the generic connected REPL have cider-nrepl and piggieback dependencies? Currently Calva does a bad job at checking this, but it is needed.

danieroux07:11:32

I found the CLJ/CLJS toggle. And toggling that I get new behaviour:

danieroux07:11:14

It seems to be evaluating in the CLJ context?

danieroux07:11:12

The nrepl alias:

danieroux07:11:13

Got it. Running “Select CLJS Build Connection” made it work.

danieroux08:11:49

Now I need to figure out how make this much smoother for the future Calva newbie on our project. Steps I take: • Start an nREPL with piggieback and cider-nrepl • Connect to that via Generic, In Project. • Start figwheel, which drops into a CLJS REPL • Run “Select CLJS Build Connection” • Load dev/portal.cljs successfully.

danieroux08:11:01

Is there any way to minimise those steps?

pez08:11:05

I had forgotten about the “Select CLJS Build Connection” command. 😃 Is it a Figwheel Main project?

pez08:11:21

And connecting with Figwheel Main option doesn’t work?

danieroux09:11:32

When prompted for which builds to start, I chose “common” and “local”. When it started and asked which build to connect to, I chose “local” and got “Build local isn’t registered. Did you start it?”

danieroux09:11:33

(defn start-cljs-repl []
  (let [read-build (figwheel.main.api/read-build "common" "local")
        build-id   (:id read-build)]
    (try
      (figwheel.main.api/start {:mode :serve} read-build)
      (figwheel.main.api/cljs-repl build-id)
      (catch RuntimeException _e
        (println "The build is already running, connection to the REPL only")
        (figwheel.main.api/cljs-repl build-id)))))

danieroux09:11:54

I merge my builds, so I am not sure if Calva deals with that

pez09:11:24

Probably not, I didn’t know merging builds was a thing even.

pez09:11:10

Do you think you can create a small reproduction repo I can have a look at?

danieroux10:11:44

For now, this seems to be true: • When connected via Generic • And starting a figwheel manually • I have to manually “Toggle the REPL connection” for both output.calva-repl and my portal.cljs. Is there a hook somewhere that I can hook into?

danieroux10:11:53

And only after Toggling, can I “Select CLJS Build connection”, which chooses “generic” as the only one.

pez10:11:23

I am super impressed you found that way of doing it.

pez10:11:54

We should try to see if we can get the Figwheel Main connection sequence to work, I think.

pez10:11:11

Sorry, not answering your question. The way to automatically toggle the connection is to use the connect sequence. A custom connect sequence might work, but the error you get indicates that you will end up in the same place.

danieroux11:11:31

Thank you for taking the time in this conversation!

pez11:11:29

You are welcome!

pez11:11:31

Right back at you for the repro. Can you add some info to it about what a merged build is?

👍 1
pez13:11:29

I pushed a PR to the repro repo. Think I moved things forward a bit. Will try to find some more time tonight to look at it.

lance.paine14:11:18

Fun with linter. I'm not sure if #calva is the right place to ask this, but I'm starting here as it's the bit I interact with. I'm using vs code. I've got calva v2.0.225. I'm in a project with fulcro (forked from https://github.com/fulcrologic/fulcro-rad-demo) Fulcro's macros like defresolver do NOT get recognised (should be resolved as defn). I have been having trouble with actions from the quick actions menu doing anything - for instance, move to let doesn't work from ctrl+. but it DOES work from ctrl+p. For resolve macro as I started with trying the quick action 'resolve macro <...> as' from ctrl+., but it did nothing, per the more general problem I'm having. Then I tried from ctrl+p, and get this dialog. I've now tried looking at the clj-kondo config more directly using the import instructions here, https://github.com/clj-kondo/clj-kondo/blob/master/doc/config.md#introduction but the 'to activate' instructions printed,don't match the directories created in ./clj-kondo/clj-kondo. It created ./clj-kondo/clj-kondo/fulcro/config.edn The instructions say

Imported config to .clj-kondo/com.fulcrologic/fulcro. To activate, add "com.fulcrologic/fulcro" to :config-paths in .clj-kondo/config.edn. 
Thanks in advance!

pez14:11:27

Hello! It makes sense to start here with Calva. Have a look in this thread and see if you find some useful info. https://clojurians.slack.com/archives/CBE668G4R/p1636202877297800

pez14:11:43

Ah, you’ve already found it. 😃

😂 1
borkdude14:11:24

@U2LUY0P8B fulcro already has a configuration for clj-kondo

borkdude14:11:49

after your project is initialized by clojure-lsp, you should get a .clj-kondo/com.fulcro.bla/fulcro directory

borkdude14:11:04

all you have to do is add this to :config-paths in your .clj-kondo/config.edn

lance.paine14:11:54

thanks @U0ETXRFEW yes, I'd seen the thread, but it seemed to jump from "there's a problem" to "it now works" and I wasn't sure I could see what the resolution was 🙂

lance.paine14:11:08

oh, a typo! (for grumplet, maybe not mine 🙂

lance.paine14:11:40

hmm, so neither my project, nor @U0522TWDA fulcro-intro work ootb. Neither of them have a ./clj-kondo/config.edn I've tried creating one with

{:config-paths ["com.fulcrologic/fulcro" "com.wsscode/async" "com.wsscode/pathom"]}
And now @U0522TWDA intro project gives me
[Info  - 2:24:54 PM] Clj-kondo language server loaded. Please report any issues to .
[Error - 2:24:54 PM] java.lang.IllegalArgumentException: No implementation of method: :as-file of protocol: #' found for class: clojure.lang.Symbol
	at clojure.core$_cache_protocol_fn.invokeStatic(core_deftype.clj:583)
	at $fn__11366$G__11348__11371.invoke(io.clj:35)
	at $file.invokeStatic(io.clj:424)
	at clj_kondo.impl.core$sanitize_path.invokeStatic(core.clj:88)
	at clj_kondo.impl.core$sanitize_paths$fn__15867.invoke(core.clj:97)
	at clojure.core$keep$fn__8559.invoke(core.clj:7337)
	at clojure.lang.LazySeq.sval(LazySeq.java:42)
	at clojure.lang.LazySeq.seq(LazySeq.java:51)
	at clojure.lang.RT.seq(RT.java:535)
	at clojure.core$seq__5402.invokeStatic(core.clj:137)
	at clojure.core$map$fn__5866.invoke(core.clj:2746)
	at clojure.lang.LazySeq.sval(LazySeq.java:42)
	at clojure.lang.LazySeq.seq(LazySeq.java:51)
	at clojure.lang.RT.seq(RT.java:535)
	at clojure.core$seq__5402.invokeStatic(core.clj:137)
	at clojure.core.protocols$seq_reduce.invokeStatic(protocols.clj:24)
	at clojure.core.protocols$fn__8146.invokeStatic(protocols.clj:75)
	at clojure.core.protocols$fn__8146.invoke(protocols.clj:75)
	at clojure.core.protocols$fn__8088$G__8083__8101.invoke(protocols.clj:13)
	at clojure.core$reduce.invokeStatic(core.clj:6824)
	at clj_kondo.impl.core$resolve_config_paths.invokeStatic(core.clj:112)
	at clj_kondo.impl.core$resolve_config_paths.invoke(core.clj:106)
	at clj_kondo.impl.core$process_cfg_dir.invokeStatic(core.clj:86)
	at clj_kondo.impl.core$resolve_config.invokeStatic(core.clj:132)
	at clj_kondo.core$run_BANG_.invokeStatic(core.clj:107)
	at clj_kondo.lsp_server.impl.server$lint_BANG_$fn__16141.invoke(server.clj:132)
	at clj_kondo.lsp_server.impl.server$lint_BANG_.invokeStatic(server.clj:131)
	at clj_kondo.lsp_server.impl.server.LSPTextDocumentService.didOpen(server.clj:150)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:567)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$null$0(GenericEndpoint.java:65)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint$$Lambda$36/00000000E861ECB0.apply(Unknown Source)
	at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.notify(GenericEndpoint.java:152)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleNotification(RemoteEndpoint.java:220)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:187)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:847)

Jakub Holý (HolyJak)14:11:04

Hm, I guess I should add the kondo config. Though lsp-clojure perhaps auto-creates it? No idea about the exception :(

lance.paine14:11:05

ah the project loads, there's a blissful little moment where I've got no red underlining, but it's just because the lsp hasn't kicked in yet 😢 😆

borkdude15:11:48

@U2LUY0P8B Can you reproduce this with the original fulcro rad demo?

borkdude15:11:01

If you can make it so anyone of us can reproduce locally, I'm willing to take a look

🙇 1
lance.paine15:11:13

I'll give it a go!

lance.paine15:11:57

good news and bad news. Good news for you guys, it works (nearly) out of the box! Bad news for me. I've no idea what I've done differently. 😞 It didn't work on cloning, but i let the lsp/kondo/whatever create the .clj-kondo/ folders, and it wasn't working. But I manually added ./clj-kondo/config.edn with content {:config-paths ["com.fulcrologic/fulcro" "com.wsscode/async" "com.wsscode/pathom"]} , reloaded the window, and it works beautifully!

borkdude16:11:35

yes, that's how it should work

👍 1
lance.paine09:11:18

Thanks to @U0522TWDA we figured out where it was going wrong. A) the lack of .clj-kondo/config.edn B) for some reason we've not identified the .clj-kondo/com.wsscode/ paths aren't created in that project. I copied them over from the fulcro-intro-workshop and it's now working! 🙂

lance.paine09:11:10

@U0522TWDA did also note that my clojure-lsp takes an unusually long time to start. He mentioned some docs about turning on logging to see what's taking the time. I might look at that today.

lance.paine09:11:31

Thanks all for the help! I look forward to an even more enjoyable experience free from red underlining 🙂

lance.paine08:11:11

thanks @U9A1RLFNV I'll take a look 🙂

👍 1
zeitstein20:11:43

Ran into the same issue. Specifically, there was no .clj-kondo/config.edn; after adding it, all is well. Is this something that should happen automatically, or should I remember to do it when creating a new project?

zeitstein20:11:56

> @U0522TWDA did also note that my clojure-lsp takes an unusually long time to start. He mentioned some docs about turning on logging to see what's taking the time. I might look at that today. @U2LUY0P8B, did you find a fix for this? clojure-lsp behaves the same way for me on Fulcro projects, though not always. Memory and CPU usage go through the roof while this is going on.

lance.paine20:11:36

I've not dug into it yet. I think it's complicated for me as I'm on Windows with Ubuntu in wsl2. that's got some known issues on file watchers, and occasionally vs code node workers get into a cpu spin too.

zeitstein21:11:18

I'm on Windows too, but no WSL.

Jakub Holý (HolyJak)09:11:17

Yes, you must add the config file manually

👍 1
Jakub Holý (HolyJak)16:11:45

How does Calva and clojure-lsp behave wrt. clj-kondo? If I open a fresh clone of [email protected]:holyjak/fulcro-intro-wshop.git and delete the .clj-kondo/com.* files, it seems those configs get imported automatically (which is nice!) and kondo is able to lint the files using info from these even though I do not have .clj-kondo/config.edn How is that possible? As an author, what should I do? Should I include .clj-kondo/config.edn and the imported configs in the git repo? Or is it unnecessary since it works anyway (does it for everybody?)? Thank you!

1
ericdallo16:11:12

it's recommended that you commit everything inside .clj-kondo besides .clj-kondo/.cache

ericdallo16:11:15

the same for .lsp

ericdallo16:11:27

kondo will copy automatically those configs because clojure-lsp pass a flag telling to do it, but even so, you need to add to your .clj-kondo/config.ednsomething like

{:config-paths ["com.foo.bar/baz"]}
to lint those extra configs copied previously

Jakub Holý (HolyJak)16:11:35

That is what I thought but somehow it seems to work for me without that.

ericdallo16:11:52

maybe you have other .clj-kondo config somewhere? like ~/.config/clj-kondo/config.edn or something

Jakub Holý (HolyJak)16:11:41

Indeed, I do. Thank you!

👍 1
pez17:11:29

Here’s a summary of my first two weeks trying to bring Parinfer to Calva. https://twitter.com/pappapez/status/1461018167002734592 Enjoy! And please retweet. ❤️

🙏 1
lilactown23:11:04

is there a way to get go to definition/docstrings/etc. working for vars defined via macros?

lilactown23:11:40

if it matters, I'm using shadow-cljs and in a CLJS context

lilactown23:11:25

oh, it suddenly started working

1