Fork me on GitHub
#calva
<
2023-07-21
>
keychera03:07:48

is this a clj-kondo problem or calva problem? this is the suppress unused-binding quick fix on a multi-arity function Calva version used: v2.0.381 clojure-lsp version used: 2023.07.01-22.35.41 clj-kondo version used: 2023.06.02-SNAPSHOT

2
pez07:07:02

I think it needs to be fixed in clojure-lsp. Ask about it in #CPABC1H61 and see if they agree.

2
borkdude09:07:36

if you can reproduce the problem with clj-kondo only (on the command line) then I'll have a look. also please paste the code as a standalone repro and not only as a movie, then it'll be easier to repro.

keychera09:07:25

oh right, sorry, the smallest code would be this

(defn foo
  ([p1] (foo p1 "p2"))
  #_{:clj-kondo/ignore [:unused-binding]}
  ([p1 p2] (println p1 "not using p2")))

borkdude09:07:52

if you are not using p2 you can start it with an underscore:

_p2 

borkdude09:07:56

(defn foo
  ([p1] (foo p1 "p2"))
  ([p1 _p2] (println p1 "not using p2")))

borkdude09:07:21

feel free to post an issue about the above though

keychera09:07:18

oh I didn’t know that, I’ll be using that instead then I should post the issue in clj-kondo then?

borkdude09:07:32

on github please

2
pez09:07:23

I sometime use that _unused “trick” in destructurings, to inform myself about things that exist in the thing I am destructuring, or what the thing is that I am destructuring. Like:

(defn [{:keys [foo bar _baz] :as _thing}]
  …)

💡 2
damien15:07:15

Hi all, one nice thing in the Calva plugin is that upon saving my source file, the unit tests which reference that namespace are automatically run each time I save the source file (and are neatly highlighted by the lsp server as failures in the test file, which greatly speeds up my workflow since I can just hover over a test and see why it failed). However, this seems to only work when I jack-in using a lein project, and not with deps.edn. Is there a way to recover this functionality? I'm wondering if I am missing an alias or something, but couldn't find anything in the docs.

pez09:07:26

How do you start the REPL in these two projects?

damien23:07:40

@U0ETXRFEW in both cases I am executing Calva: Start a Project REPL and Connect (aka Jack-In). The project in question has both project.clj and deps.edn configs. When Calva asks for which project type to launch, selecting Leinginen project type causes the desired behavior (described above), whereas doing the exact same thing but selecting deps.edn project type causes nothing to happen. It just says "loading REPL" indefinitely and nothing else occurs.

damien00:07:36

FYI for further clarification, this is the public test repo (it's an exercism exercise): https://github.com/exercism/clojure/tree/main/exercises/practice/collatz-conjecture. Basically, launch the project in vscode with Calva/LSP/etc configured, and try to jack in. The unit tests will auto-load and run on every save when lein is the project type, but nothing at all happens with the deps.edn project type.

pez06:07:35

Thanks! I’ll try this myself and see what I can figure out.

pez11:07:52

I’m guessing that you not only select deps.edn, but also select the :test alias? That won’t work, because it doesn’t start an nREPL server for Calva to connect to. Try without selecting that, and I think it should work the same as with the Leiningen project.

pez12:07:41

Here’s a solution I just did for that exercise, btw:

(defn collatz
  [num]
  {:pre [(pos-int? num)]}
  (loop [n num
         steps 0]
    (cond
      (= 1 n) steps
      (even? n) (recur (/ n 2) (inc steps))
      :else (recur (inc (* 3 n)) (inc steps)))))
Similar to yours?

damien14:07:18

@U0ETXRFEW I hadn't done it yet, actually 🙂 but yes that looks quite good! I think unselecting the test alias did the trick. Thought I had done that once already, but could've easily been a mistake. Thanks for the assistance!

pez15:07:36

You’re welcome! And sorry if I spoiled the exercise! 😃

lodin07:07:25

Do you run any other plugin @U1EPFAJ1J? I don't have that the tests run automatically. I'm running Calva 2.0.381 and VS Code 1.80.1. I'm using kaocha as test runner.