This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-24
Channels
- # announcements (5)
- # aws (5)
- # aws-lambda (6)
- # babashka (6)
- # beginners (48)
- # calva (54)
- # clj-commons (12)
- # clj-kondo (39)
- # cljfx (3)
- # cljs-dev (11)
- # clojure (91)
- # clojure-europe (25)
- # clojure-uk (3)
- # clojurescript (16)
- # cursive (2)
- # data-oriented-programming (6)
- # datomic (8)
- # emacs (10)
- # events (3)
- # fulcro (2)
- # functionalprogramming (2)
- # graalvm (4)
- # graphql (2)
- # helix (1)
- # honeysql (4)
- # jobs (1)
- # malli (4)
- # nextjournal (21)
- # off-topic (5)
- # other-languages (4)
- # overtone (3)
- # reitit (17)
- # releases (2)
- # rewrite-clj (6)
- # ring (6)
- # shadow-cljs (37)
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 https://calva.io/formatting/#configuration) 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! 🙏 ❤️ • VSIX to test: https://18330-125431277-gh.circle-artifacts.com/0/tmp/artifacts/calva-2.0.246-1561-fix-clojure-lsp-format-config-16a7c9a4.vsix
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: https://github.com/BetterThanTomorrow/calva/issues/1561 • Fix2: https://github.com/BetterThanTomorrow/calva/issues/1556 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! 🙏 ❤️
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.
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 https://calva.io/custom-commands/ should do the trick
We might want to add some priority to these snippets, @U02EMBDU2JU. So that they can appear early in the hover.
@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
[x]
x)
calling (clojure.repl/doc my-foo)
returns
([x])
Spec
args: (cat :x :my-ns/thing)
ret: string?
nil
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?But that is not consistent with you getting nil
. You would get nothing if that was the error, I think...
Calling doc apparently prints the result and returns nil, right? You'd need a function that returns a string you want to show
You’re right - I tried replacing it with what you suggested @U0ETXRFEW (both with and without \“\” surrounding the $hover-text) but still no dice
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)
)
The "calva.customREPLHoverSnippets"
property should go right into my settings.json
file right? Do I need to restart my vs code or anything?
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\")"
}
],
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
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
I get something printed using
{
"name": "Show doc string",
"snippet": "(with-out-str (clojure.repl/doc $hover-text))"
}
No quote, and with-out-str
.ah… I got it to work using the .calva/config.edn
route. Not sure why it wasn’t working with my settings.json
.
but yes, it doesn’t like line breaks 🙂
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
oh that is really good to know @U02EMBDU2JU
@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
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 🙂
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.tsLooks like you might need to double the newline character: https://github.com/microsoft/vscode/issues/86291
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.
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.
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
@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'd like to be able to display richer inline results. But the vscode team is not prioritizing that kind of UI. https://github.com/microsoft/vscode/issues/3220