Fork me on GitHub

Dear Calva friends, I need help testing a change to how the formatter fetches its configuration. For use without the CLOJURE-LSP config option (see it should behave exactly as before. For the lsp use it should start working, but also might make formatting unresponsive while clojure-lsp initializes. In any case, the changes are of a nature that I might have introduced bugs, so your help with testing would be awesome. Thanks in advance! 🙏 gratitude ❤️ • VSIX to test:

👍 1

Alright, it turned out that the released Calva had a serious bug when it comes to formatting on save, so any bugs I introduced with the follow up will most probably be an improvement. I've just released Calva v2.0.246: • Fix: • Fix2: I'm terribly sorry for any mess the previous version created for people using Format on Save. Thanks @isac_asj91 for 246 testing, review and contributions to this fix! 🙏 ❤️

❤️ 5
👍 1
Grant Horner16:02:52

is there any way to integrate the additional docs provided by clojure.spec.alpha/fdef into the mouse-over tooltip in calva? It’d be great to be able to see that stuff.


I was about to say that there isn't, but then remembered that @U02EMBDU2JU added a way to add stuff to the hover recently. So there might be a way. Let's see what Lukas says about it.

Lukas Domagala16:02:22

I haven’t looked at the output of fdef, but if you can do something like (get-fdef-docs ’sym) and get what you want displayed, then Custom REPL hover snippets should do the trick


We might want to add some priority to these snippets, @U02EMBDU2JU. So that they can appear early in the hover.

Grant Horner16:02:49

@U02EMBDU2JU this is very cool. I think I’m missing something though. Given a snippet like the following:

(spec/def ::thing string?)

(spec/fdef my-foo
  :args (spec/cat :x ::thing)
  :ret ::thing)

(defn my-foo
calling (clojure.repl/doc my-foo) returns
  args: (cat :x :my-ns/thing)
  ret: string?
where I just get nil on hover. I think I have an error in my config, which I set like this:
"calva.customREPLHoverSnippets": [
            "name": "show doc on hover",
            "snippet": "(clojure.repl/doc $hover-text)"
in my settings.json . Do you guys see anything off here?


You might need to quote $hover-text


But that is not consistent with you getting nil. You would get nothing if that was the error, I think...

Lukas Domagala16:02:35

Calling doc apparently prints the result and returns nil, right? You'd need a function that returns a string you want to show


(with-out-string (clojure.repl/doc $hover-text))

Grant Horner16:02:38

You’re right - I tried replacing it with what you suggested @U0ETXRFEW (both with and without \“\” surrounding the $hover-text) but still no dice


I meant quote like '$hover-text 😃


Does my suggesting work in the REPL? I didn't test it myself. 😃

Grant Horner16:02:36

Woops. We overloaded the word quote by accident. Still is not working for me: I’m assuming the fn name is directly inserted into $hover-text, in which case we wouldn’t want to quote it (i.e. you want (doc fn) , not (doc 'fn) )

Grant Horner16:02:33

The "calva.customREPLHoverSnippets" property should go right into my settings.json file right? Do I need to restart my vs code or anything?


It hot reloads.


Try a really simple snippet. (str '$howver-text)

Grant Horner16:02:54

yeah still nothing… not sure what I’m doing wrong. It should just show up in the tool tip right? I don’t need to enable it or anything?

"calva.customREPLHoverSnippets": [
            "name": "show doc on hover",
            "repl": "clj",
            "snippet": "(str '$hover-text)"


It should just show up. That looks right to me. We have this in Calva's test-data directory:

"calva.customREPLHoverSnippets": [
      "name": "edn hover hover-text",
      "snippet": "(str \"**JSON edn hover hover-text** \" \"$hover-text\")"


You get nil, or you get nothing, btw?

Grant Horner16:02:44

I think nil is just the default output for a fn with no doc string. I tried replacing my calva.customREPLHoverSnippets with the above and I’m still not seeing anything, so I guess my calva is just borked

Grant Horner16:02:32

this should show that long snippet of text somewhere right? I’m really feeling like I’ve got an ID10T user error on my hands over here


It should....


I get something printed using

      "name": "Show doc string",
      "snippet": "(with-out-str (clojure.repl/doc $hover-text))"
No quote, and with-out-str.


However, so not quite there yet. 😃

Grant Horner17:02:38

ah… I got it to work using the .calva/config.edn route. Not sure why it wasn’t working with my settings.json .

Grant Horner17:02:53

but yes, it doesn’t like line breaks 🙂


Might be something we need to fix, but also might be something the snippet can fix...


Very strange that the JSON didn't work...

Lukas Domagala17:02:14

Yeah what ever is coming in is used as if it was markdown. So currently the easiest way would be to have a (doc-md …) function that you define in your own code and call it from the snippet

Grant Horner17:02:53

oh that is really good to know @U02EMBDU2JU

Grant Horner17:02:29

@U02EMBDU2JU how would we insert a newline? I’ve tried \n, <br>, etc. but haven’t figured it out. sorry to keep necroing this thread

Lukas Domagala17:02:45

all good, you’re the first user other than me and I didn’t get the chance to do more then simple tests, so it’s great that you give it a good kicking 🙂


Please keep the thread going!

Lukas Domagala18:02:34

mhh, not sure why it’s not handling newlines correctly. The code is just

const hover = new vscode.MarkdownString();
hover.isTrusted = true;
hover.appendMarkdown(_.trim(text, '"'));
But I don’t really have time to play with it until sunday. Any ideas @U0ETXRFEW? You seem to have done the same thing on clojuredocs.ts


Looks like you might need to double the newline character:

Lukas Domagala00:02:02

Nice find @U015879P2F8, thank you! I’ll play around with the MarkdownString possibilities when I find some time and probably add a :kind field to the snippets. That way you can do markdown if you want but also have an easier out if you don’t need the markdown stuff.


Funny that it was a Calva contributor who filed the issue, 😃


In the docs I see "This also creates a hover pane including the full results and a button which will copy the results to the clipboard." However when I evaluate some code I never see this. Is there a setting to get it back?


It populates the hover with the results. Try issuing the Show hover command after you have evaluated.


Ah, that's more like it. But the hover disappears the moment I move the mouse... unless I put the mouse where it's going to open 🙂


Is this related to the delay of the hover in general? Because I've set that to be the maximum...


Ohhh the hover window is a singleton? And it contains both the last eval results and whatever else the cursor happens to be on?


Yeah, I’m just checking that it works. The hover range is the range of the evaluated text. But VS Code is only showing hovers on something non-whitespace. And if you have disabled hovers, they won't show. Try using a delay of 1500 ms. It’ll give you time to avoid hovers when you don't want them.


OK that clarifies things. I will resume tomorrow. Thanks!


I think that if you place the mouse cursor where the hover will appear before you press cmd+k cmd+i you'll be able to inspect the hover contents.


Here's what happens when I evaluate a snippet that produces something long enough to wrap


Is this because you have pretty printing on, look down bottom right


@U7PBP4UVA Is this related to your previous message about the hovers? If so, it seems you’ve gotten some help there, right?


Yes, it's about hovers. In general it's because for me I can't really work without the output window being visible, since the hover is cumbersome to use, and the inline results show next to nothing.


I guess there's limitation to the UI that can produce the results...

☝️ 1

I'd like to be able to display richer inline results. But the vscode team is not prioritizing that kind of UI.


I was looking into notebooks but it seems a very heavy handed approach for REPL based development.