Fork me on GitHub
#calva
<
2021-12-10
>
claynon09:12:06

is there any way to show documentation of a function using only the keyboard I usually hover the mouse over the function name and it pops up, but it will be a bit more practical for me if there is some keyboard shortcut to do it

pez10:12:04

There’s a VS Code command for showing the hover, I think it is named Show Hover. On Mac it is default bound to cmd+k cmd+i, maybe on Windows/Linux that’ll be ctrl+k ctrl+i.

claynon12:12:42

perfect! thank you!

pez13:12:44

This is also useful for inspecting the result of an evaluation.

Lukas Domagala13:12:57

@U0ETXRFEW vscode doesn’t allow “richer” tooltips yet, right? something like a table or graphic i mean

pez13:12:45

Actually there was a change recently to the markdown allowed in the hovers. It might have opened up for at least slightly richer content. I haven’t investigated yet.

Lukas Domagala13:12:51

nice, i’ll have to look into that, thank you!

pez14:12:37

Awesome. What I’d like to know first about that is if we can use detail/summary tags now. We couldn’t before, and it has stopped me from presenting data structures in a collapsable manner.

Lukas Domagala14:12:43

uh, i’m sure i don’t know enough about calva to tell you anything about that, but i’ll have a look at the new feature and come back to you

pez14:12:03

Yeah, it might take some digging in Calva to actually use it. But what you need to know is that we populate the hovers using markdown. And it used to be a pretty limited markdown, where the html tag <details> couldn’t be used. If that tag can now be used, a nice possibility opens. 😃

Lukas Domagala15:12:30

so according to this https://github.com/microsoft/vscode/blob/4bc25f73942dbaecaee345b5677f7164f268b193/src/vs/base/browser/markdownRenderer.ts#L360 these are our options: ALLOWED_TAGS: [‘ul’, ‘li’, ‘p’, ‘b’, ‘i’, ‘code’, ‘blockquote’, ‘ol’, ‘h1’, ‘h2’, ‘h3’, ‘h4’, ‘h5’, ‘h6’, ‘hr’, ‘em’, ‘pre’, ‘table’, ‘thead’, ‘tbody’, ‘tr’, ‘th’, ‘td’, ‘div’, ‘del’, ‘a’, ‘strong’, ‘br’, ‘img’, ‘span’], ALLOWED_ATTR: [‘href’, ‘data-href’, ‘target’, ‘title’, ‘src’, ‘alt’, ‘class’, ‘style’, ‘data-code’, ‘width’, ‘height’, ‘align’] no details sadly, but an optional “always details” hover effect, maybe switchable through a hotkey, for inline results would be something i’d use :)

pez15:12:47

We show all details today. The details tag is about hiding them 😃 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details

Lukas Domagala15:12:00

ah whups 🙂 i thought you wanted to display it in a rendered way, for example in a table

pez20:12:49

Yeah, it would be wonderful to present rich results. Just that I think it is almost impossible to consume large result data structures as it is now.

Lukas Domagala20:12:42

yeah I think most people that active already use portal or reveal for anything that’s not trivial, but that’s sad for any newbie that doesn’t know about them. having some middle ground between a basic repl and a full blow window would be helpful for the beginner experience

javi15:12:43

just getting a new macbook and rethinking my setup. i am a long time intellij user, but vscode+calva feel like a space where i could contribute more to the dev experience. Are there any roadmaps / docs on calva/vs code extension possibilities ( specially web views) that you could share? many thanks

bringe20:12:04

There’s not really a roadmap, but for contributing to Calva, see here: https://github.com/BetterThanTomorrow/calva/wiki/How-to-Contribute. For general docs on Calva, see http://calva.io.

Stuart16:12:04

Clojure characters that are either \{ \[ \< \( seem to disturb the syntax highlighting, see:

pez17:12:10

If you post it as text it is much easier to try reproduce. Ask @U9A1RLFNV about it. 😃

😄 1
Stuart17:12:38

Yeah, I'll post the text, but the text wouldn't have shown the colours 😄 This

(defn get-remaining [open [c & r]]
  (if (nil? c)
    open
    (cond (#{\{ \[ \< \(} c)
          (recur (conj open c) r)

          (#{\} \] \> \)} c)
          (if (= c (matcher (peek open)))
            (recur (pop open) r)
            nil))))
Shows as :

pez17:12:42

Looks like so for me.

Stuart17:12:20

hmmm. could be my VS code theme?

Stuart17:12:53

Even a basic map shows wrong for me

(let [x {\{ \[}])
SHows as:

pez17:12:04

Maybe you have VS Code bracket colors on? I can’t fully reproduce, but this looks a bit funny:

Stuart17:12:06

I'll experiment with my chosen theme and see if that is it

pez17:12:01

I’m using Github Dark Default, btw. Though I doubt a bit it is about the theme.

Stuart17:12:11

you are right, I did have a bracket colorizer! Turned iff off and its perfect now

pez17:12:27

Awesome.

pez17:12:05

It should be reported on the VS Code repo, I think. There might be something Calva can do about it.

pez17:12:08

Though, even with Calva disabled it looks funny.

Stuart17:12:42

oh yeah, the \{ is blue, and its coloured the closing } on the set blue, when it should be purple

pez17:12:15

The cursor is on that empt line. Extra interesting that the bracket matching highlights a yellow and a blue paren. 😃

pez17:12:45

I’ll report it on VS Code. I’m curious if Calva can fix it.

emccue16:12:55

More fun that i am not entirely sure if its my machine

emccue16:12:00

Dec 10, 2021 11:25:56 AM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleCancellation
WARNING: Unmatched cancel notification for request id 155
Dec 10, 2021 11:27:46 AM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleCancellation
WARNING: Unmatched cancel notification for request id 339
Dec 10, 2021 11:27:46 AM org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer fireError
SEVERE: Unable to invoke no-args constructor for class org.eclipse.lsp4j.ShowDocumentResult. Registering an InstanceCreator with Gson for this type may fix this problem.
java.lang.RuntimeException: Unable to invoke no-args constructor for class org.eclipse.lsp4j.ShowDocumentResult. Registering an InstanceCreator with Gson for this type may fix this problem.
	at com.google.gson.internal.ConstructorConstructor$14.construct(ConstructorConstructor.java:228)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:212)
	at com.google.gson.Gson.fromJson(Gson.java:963)
	at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.fromJson(MessageTypeAdapter.java:329)
	at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.parseResult(MessageTypeAdapter.java:188)
	at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.read(MessageTypeAdapter.java:123)
	at org.eclipse.lsp4j.jsonrpc.json.adapters.MessageTypeAdapter.read(MessageTypeAdapter.java:55)
	at com.google.gson.Gson.fromJson(Gson.java:963)
	at org.eclipse.lsp4j.jsonrpc.json.MessageJsonHandler.parseMessage(MessageJsonHandler.java:119)
	at org.eclipse.lsp4j.jsonrpc.json.MessageJsonHandler.parseMessage(MessageJsonHandler.java:114)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:193)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)
	at org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.lang.Thread.run(Thread.java:829)
	at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:596)
	at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
Caused by: java.lang.reflect.InvocationTargetException
	at java.lang.reflect.Method.invoke(Method.java:566)
	at com.google.gson.internal.UnsafeAllocator$1.newInstance(UnsafeAllocator.java:50)
	at com.google.gson.internal.ConstructorConstructor$14.construct(ConstructorConstructor.java:225)
	... 19 more
Caused by: java.lang.IllegalArgumentException: Class org.eclipse.lsp4j.ShowDocumentResult is instantiated reflectively but was never registered. Register the class by using org.graalvm.nativeimage.hosted.RuntimeReflection
	at com.oracle.svm.core.graal.snippets.SubstrateAllocationSnippets.hubErrorStub(SubstrateAllocationSnippets.java:258)
	at sun.misc.Unsafe.allocateInstance(Unsafe.java:840)
	... 22 more

bringe20:12:42

Where are you seeing this information?

emccue21:12:23

just in the output window

bringe23:12:15

If you can provide an example project which we can reproduce the issue with then we could troubleshoot further.

Antonio Bibiano19:12:15

sorry peeps, not sure if this is calva specific, but I was wondering what is needed to show the source code of java stuff

Antonio Bibiano19:12:51

like I love checking the source of stdlib functions but sometimes they refer to clojure.lang.RT or java.lang.Number for example

Gerome19:12:12

According to the getting started repl it should be possible to peek the source of those too.

Gerome19:12:46

It was cmd + hover or alt + hover, I think. Just read it yesterday 😄

Antonio Bibiano19:12:31

i get a tooltip with "no definition found" but it might be an issue with my setup

bringe20:12:23

You need the Java sources installed, from what I know

bringe20:12:48

This happens by default on some systems, I think, but on others they have to be manually added

bringe20:12:05

I’ll make an issue to add info about this in the Calva docs.

bringe20:12:05

Oh, I added an issue for that already 😂

bringe20:12:26

Added it to my project board so it’s more visible

bringe16:12:40

Added a note in the docs pointing to that thread here: https://calva.io/connect/#go-to-definition-not-working-for-java-definitions

❤️ 1
Lukas Domagala21:12:42

mhh, I don’t seem to understand the linked comment. i have src.zip in the lib folder of the jvm install and have read access and cant “go to def” on java.lang.Number for example

bringe21:12:37

I’m not sure what the issue is, but go to def might have a bug from a recent change. See this thread: https://clojurians.slack.com/archives/CBE668G4R/p1639431002408900. I don’t think I’ve ever actually gotten that feature to work (don’t remember if I tried the suggestion in the comment). If it’s working for Clojure defs though, feel free to create an issue in the repo and we can troubleshoot there.

bringe21:12:22

Then we could try to nail down a solution and document it.

Lukas Domagala22:12:22

k, going into clojure jars seems to still work, i’ll create an issue. thanks

Lukas Domagala22:12:56

it’s the strangest thing, it just worked for two things, then i wanted to check my calva version, went back to the file and its broken for everything again, without a reload

Lukas Domagala22:12:43

https://github.com/BetterThanTomorrow/calva/issues/1436 very strange reproducibility, sometimes it partially works and sometimes not at all

👍 1
amithgeorge21:12:52

Not sure if this is a Calva question or a clojure-lsp question. How do I find all references of a specific arity of a function?. Right now in Calva, with the cursor on the function name, I can find all references of all arities of the function. I tried placing the cursor between the ( and [ for each arity and searching for references. That didn't show any references, I am guessing that doesn't work.

ericdallo21:12:40

there is no way ATM to achieve that via clojure-lsp

🆗 1
gratitude-thank-you 1
ericdallo21:12:00

it's possible to add that, but not sure how we would achive that following the LSP protocol