Fork me on GitHub
#calva
<
2022-09-29
>
kdchabuk03:09:56

I may have found a bug in Calva; can anyone comment on this? Start with this function:

(defn foo
  ([]
   (+ 0))
  ([x]
   (+ x)))
Highlight (+ 0), push ctrl+. and select 'move to let'. You'll get:
(defn foo
  (let [new-binding (+ 0)]
   ([]
   new-binding))
  ([x]
   (+ x)))
This results in an error, because the let is around the arity-0 form. This is Calva 2.0.304 from open-vsx.

pez06:09:00

Interesting edge case! 😃 These refactorings are provided by clojure-lsp. And it could even be upstreams from there as well. I think posting this in #lsp will be a good start. @UKFSJSM38 will tell you if he wants an issue or where he thinks the issue should be raised.

ericdallo10:09:08

Yeah, looks like a issue on clojure-lsp, please open an issue on clojure-lsp

skylize16:09:27

What is the "correct" behavior here? You have turned a multi-arity function into a 2-arity function that tries to use let as a parameter name; and then also tries to use a vector and a function both as parameter names, and both of which contain the unresolved symbol new-binding.

pez17:09:41

It’s a refactoring. By definition it should not change behavior.

👍 1
cmdrdats06:09:21

does anyone know how I could supress kondo running until I actually save the file in calva? often stuff is in uncompilable state (particularly when messing about in let bindings), so it's mostly just very noisy until I'm done. I'd prefer not to have the noise...

👀 1
👍 2
cmdrdats06:09:17

alternatively being able to set a timeout for like a second or so after I'm done typing would also work 😄 right now, it's a bit too fast (particularly intense since I'm using the errorlens extension - it lights the place up like a christmas tree)

pez06:09:49

I'm not sure what kind of control Calva has on this behaviour. I know the ESLint extension can be configured to only lint on save, so seems that we should be able to do it as well. Summoning the Calva lsp experts: @U9A1RLFNV @UKFSJSM38

ericdallo10:09:01

Not possible ATM, it'd need a flag on clojure-lsp to post diagnostics only after didSave and not on didChange, not sure if we want to support that though

cmdrdats11:09:38

cool, thanks for the feedback 🙂

👍 1
skylize16:09:26

> not sure if we want to support that though -@UKFSJSM38 For difficulty reasons, or something else? This definitely seems like a desirable option. For me, the debounce variant is what I long for, not just for sanity, but also to save electricity. I am usually typing much faster than results can get piped through the bureaucracy of VS Code's internals. Results actually succeed in posting rather intermittently, and are immediately stale if my hands are still on the keyboard.

ericdallo16:09:51

For the sake of maintaining 2 differet ways of when to produce diagnostics, so, maintainability. We already need to call kondo to calculate analysis and diagnostics for lots of other features which are core of clojure-lsp, we would just not tell client about the diagnostics until save, so it won't save that much of "electricity"

👌 1
gratitude 1
ericdallo16:09:16

Even so, feel free to create a issue so if we can track upvotes and people interested on the same thing

ericdallo16:09:57

My personal opinion is that most servers don't do that and a faster feedback is always better

k3nj1g14:09:52

Hi! Is there configuration to remove commas when pretty-printing hash-maps? I remember time when it was by default.

pez15:09:30

I don't remember that time 😃 Since very recently there is a way, though. I've added a command Calva: Replace Current Form (or Selection) with Pretty Printed Form. It works from the REPL window as well:

{:foo 1, :bar 2}
clj:some.namespace:>
| 
Calva: Replace Current Form (or Selection) with Pretty Printed Form
{:foo 1 :bar 2}
clj:some.namespace:>
| 

👍 1