Fork me on GitHub
#calva
<
2023-04-06
>
seancorfield17:04:04

Not sure whether this is a recent Calva change or a recent LSP change but at some point, a few releases back, go to definition stopped working on qualified symbols that use the #' reader macro:

#'ctl-search/online-now ; go to definition does not work
ctl-search/online-now   ; go to definition DOES work
(and, weirdly, if you remove #', do go to definition, then put #' back, go to definition continues to work for that symbol)

👀 2
seancorfield17:04:50

Ah, a little more nuance: if you go to definition on any symbol like some-ns/some-var then future go to definitions work for all vars in some-ns even when they have #' in front of them.

seancorfield17:04:36

i.e.,

some-ns/var-one   ; go to definition works
#'some-ns/var-two ; go to definition will now work here too!

ericdallo18:04:44

We didn't have any changes related to that on clojure-lsp

pez20:04:42

I can’t reproduce this. Can you enable REPL message logging and share here? Maybe we can see what’s going wrong there.

seancorfield20:04:25

How do I "enable REPL message logging"?

pez20:04:15

There’s a command for that 😃

seancorfield20:04:12

Of course there is... facepalm

pez20:04:05

We should add that command to the REPL statusbar menu item, come to think of it.

seancorfield20:04:08

-> sent
{
  op: 'info',
  ns: 'user',
  symbol: "'ctl-web-site/get-profile-delete-reasons",
  id: '1525',
  session: '7b694f70-6cd6-4661-8673-dc81e26ab1b3'
}

<- received
{
  id: '1525',
  session: '7b694f70-6cd6-4661-8673-dc81e26ab1b3',
  status: [ 'done', 'no-info' ]
}

seancorfield20:04:24

So it's including the leading ' in the string...

pez20:04:49

And when you have tricked it to start working?

seancorfield20:04:30

The same thing, strangely.

seancorfield20:04:05

-> sent
{
  op: 'info',
  ns: 'ws.api.main',
  symbol: "'ctl-web-site/get-profile-delete-reasons",
  id: '1557',
  session: '7b694f70-6cd6-4661-8673-dc81e26ab1b3'
}

<- received
{
  id: '1557',
  session: '7b694f70-6cd6-4661-8673-dc81e26ab1b3',
  status: [ 'done', 'no-info' ]
}

-> sent
{
  op: 'info',
  ns: 'ws.api.main',
  symbol: "'ctl-web-site/get-profile-delete-reasons",
  id: '1558',
  session: '7b694f70-6cd6-4661-8673-dc81e26ab1b3'
}

<- received
{
  id: '1558',
  session: '7b694f70-6cd6-4661-8673-dc81e26ab1b3',
  status: [ 'done', 'no-info' ]
}
Oh, not quite. the first, failed one has ns: 'user'

pez20:04:07

Yeah, I just tried and it includes it for me too. And also no-info, so I guess clojure-lsp saves the day.

seancorfield20:04:13

So the only difference is that sometimes Calva sends ns: 'user' -- in which case it fails -- and subsequently Calva sends ns: 'ws.api.main' and it works.

pez20:04:40

I think it never really works with the repl. But it could be failing differently in Calva. In one case recognized as a failure, and falling back on clojure-lsp. In the other case failing in some way that Calva instead croaks on, and the fallback never happens. This is all guessing, but I wrote most of that code, so not completely out of the blue guesses. 😃 You might be able to see a difference in the developer console log.

pez20:04:00

I just made my dev Calva not include the ' in the repl info lookup. And then it starts to work. Please file an issue (if you have the time, I can do it otherwise). Not sure what the implications are if I fix it the way I have fixed it now. I think things like foo' will stop working then. VS Code is pretty crude in this area. But we can fix it in the nrepl client, instead.

seancorfield21:04:27

Thanks. Unlikely I'll get to try that until Monday tho' at this point.

pez21:04:35

I’ve tested it. Works. Will be in Calva when you get to it on Monday. 😃

2
pez22:04:08

Is in Calva now.

pez22:04:02

It’s still a mystery why the clojure-lsp fallback mechanism doesn’t work for you. Let’s check your clojure-lsp message logs on Monday.

seancorfield22:04:08

LSP logs for this:

2023-04-06T22:11:18.494Z  DEBUG [clojure-lsp.server:55] - [Trace - 2023-04-06T22:11:18.494Z] Received request 'textDocument/documentHighlight - (5692)'
2023-04-06T22:11:18.494Z  DEBUG [clojure-lsp.server:55] - [Trace - 2023-04-06T22:11:18.494Z] Received request 'textDocument/codeAction - (5693)'
2023-04-06T22:11:18.495Z  INFO [clojure-lsp.handlers:277] - :document-highlight 1ms
2023-04-06T22:11:18.495Z  DEBUG [clojure-lsp.server:55] - [Trace - 2023-04-06T22:11:18.495Z] Sending response 'textDocument/documentHighlight - (5692)'. Request took 1ms.
2023-04-06T22:11:18.517Z  INFO [clojure-lsp.handlers:437] - :code-actions 23ms
2023-04-06T22:11:18.518Z  DEBUG [clojure-lsp.server:55] - [Trace - 2023-04-06T22:11:18.518Z] Sending response 'textDocument/codeAction - (5693)'. Request took 24ms.
2023-04-06T22:11:18.711Z  DEBUG [clojure-lsp.server:55] - [Trace - 2023-04-06T22:11:18.711Z] Received request 'textDocument/codeLens - (5694)'
2023-04-06T22:11:18.712Z  INFO [clojure-lsp.handlers:449] - :code-lens 0ms
2023-04-06T22:11:18.712Z  DEBUG [clojure-lsp.server:55] - [Trace - 2023-04-06T22:11:18.711Z] Received request 'textDocument/codeAction - (5695)'
2023-04-06T22:11:18.712Z  DEBUG [clojure-lsp.server:55] - [Trace - 2023-04-06T22:11:18.712Z] Sending response 'textDocument/codeLens - (5694)'. Request took 1ms.
2023-04-06T22:11:18.732Z  INFO [clojure-lsp.handlers:437] - :code-actions 20ms
2023-04-06T22:11:18.732Z  DEBUG [clojure-lsp.server:55] - [Trace - 2023-04-06T22:11:18.732Z] Sending response 'textDocument/codeAction - (5695)'. Request took 21ms.
2023-04-06T22:11:21.581Z  DEBUG [clojure-lsp.server:55] - [Trace - 2023-04-06T22:11:21.581Z] Received request 'textDocument/documentHighlight - (5696)'
2023-04-06T22:11:21.582Z  INFO [clojure-lsp.handlers:277] - :document-highlight 1ms
2023-04-06T22:11:21.583Z  DEBUG [clojure-lsp.server:55] - [Trace - 2023-04-06T22:11:21.583Z] Sending response 'textDocument/documentHighlight - (5696)'. Request took 2ms.
2023-04-06T22:11:21.833Z  DEBUG [clojure-lsp.server:55] - [Trace - 2023-04-06T22:11:21.833Z] Received request 'textDocument/codeAction - (5697)'
2023-04-06T22:11:21.872Z  INFO [clojure-lsp.handlers:437] - :code-actions 38ms
2023-04-06T22:11:21.872Z  DEBUG [clojure-lsp.server:55] - [Trace - 2023-04-06T22:11:21.872Z] Sending response 'textDocument/codeAction - (5697)'. Request took 39ms.
2023-04-06T22:11:27.423Z  DEBUG [clojure-lsp.server:55] - [Trace - 2023-04-06T22:11:27.423Z] Received request 'textDocument/documentHighlight - (5698)'
2023-04-06T22:11:27.423Z  DEBUG [clojure-lsp.server:55] - [Trace - 2023-04-06T22:11:27.423Z] Received request 'textDocument/codeAction - (5699)'
2023-04-06T22:11:27.423Z  INFO [clojure-lsp.handlers:277] - :document-highlight 0ms
2023-04-06T22:11:27.424Z  DEBUG [clojure-lsp.server:55] - [Trace - 2023-04-06T22:11:27.424Z] Sending response 'textDocument/documentHighlight - (5698)'. Request took 1ms.
2023-04-06T22:11:27.464Z  INFO [clojure-lsp.handlers:437] - :code-actions 41ms
2023-04-06T22:11:27.465Z  DEBUG [clojure-lsp.server:55] - [Trace - 2023-04-06T22:11:27.464Z] Sending response 'textDocument/codeAction - (5699)'. Request took 41ms.
2023-04-06T22:11:27.634Z  DEBUG [clojure-lsp.server:55] - [Trace - 2023-04-06T22:11:27.634Z] Received request 'textDocument/codeLens - (5700)'
2023-04-06T22:11:27.635Z  INFO [clojure-lsp.handlers:449] - :code-lens 0ms
2023-04-06T22:11:27.635Z  DEBUG [clojure-lsp.server:55] - [Trace - 2023-04-06T22:11:27.635Z] Received request 'textDocument/codeAction - (5701)'
2023-04-06T22:11:27.635Z  DEBUG [clojure-lsp.server:55] - [Trace - 2023-04-06T22:11:27.635Z] Sending response 'textDocument/codeLens - (5700)'. Request took 1ms.
2023-04-06T22:11:27.662Z  INFO [clojure-lsp.handlers:437] - :code-actions 28ms
2023-04-06T22:11:27.663Z  DEBUG [clojure-lsp.server:55] - [Trace - 2023-04-06T22:11:27.663Z] Sending response 'textDocument/codeAction - (5701)'. Request took 28ms.
2023-04-06T22:11:28.932Z  DEBUG [clojure-lsp.server:55] - [Trace - 2023-04-06T22:11:28.932Z] Received request 'textDocument/definition - (5702)'
2023-04-06T22:11:28.932Z  INFO [clojure-lsp.handlers:246] - :definition 0ms
2023-04-06T22:11:28.932Z  DEBUG [clojure-lsp.server:55] - [Trace - 2023-04-06T22:11:28.932Z] Sending response 'textDocument/definition - (5702)'. Request took 0ms.

seancorfield22:04:25

So... nothing odd there...

pez22:04:27

You see any errors in the developer tools console that can be related?

seancorfield22:04:08

Nope. Nothing in dev tools.

seancorfield22:04:49

It used to work at some point in the past. I don't remember exactly when it stopped working.

seancorfield22:04:22

VS Code just nudged me about the updated Calva so I reloaded -- and can confirm it is working now. Thank you for that very swift fix!

pez07:04:19

You are welcome, Sean! Long lived bug.

Ben Lieberman21:04:31

I have a workspace root I connect to a repl from using "connect to a REPL running in your project". It's a shadow REPL with the configuration file a couple directories down from the root. When I try to connect, the drop down excludes any mention of connecting with shadow-cljs. If I type it in and press enter, the output window appears but it aborts the connection. But if I repeat the exact same command again, shadow-cljs now appears in the drop down and I can connect fine. Is this expected behavior?

pez21:04:18

Sounds wierd and not expected/intended.

pez21:04:49

I also wonder, is the shadow-cljs.edn file not at the root of the shadow project, or just not at the root of the workspace?

Ben Lieberman21:04:26

It's in the root of the project for sure, I always use the create-cljs-project template so I don't screw that up 😅

pez21:04:56

So, the project root is showing, but not the shadow-cljs option in the project type menu?

Ben Lieberman21:04:56

Sorry I'm not exactly a VScode power user so if I'm screwing up terminology here lmk. But I have my editor open in /var/www/html (the doc root of an apache server) and then the shadow project is in /var/www/html/cms/cljms

pez21:04:28

No probs. I’m still not clear about what happens. Can you describe, step by step, how you connect, which menus you see, what you select, and so on?

Ben Lieberman21:04:23

1. Open VSCode at directory above. 2. Start REPL in terminal with npx shadow-cljs watch app 3. Click REPL button in lower left hand corner to bring up connection panel. 4. Click on connection sequence type (shadow if it's there, first time it usually isn't)

Ben Lieberman21:04:58

*3.5 Click on "connect to a repl running in your project"

pez21:04:37

Thanks. I’m so used to having several projects in a workspace so I forgot that you don’t get the project root menu if you only have one.

pez21:04:34

Do you have some other clojure project file in the directory? deps.edn, bb.edn, etcetera

Ben Lieberman21:04:02

Nope, just the cljs stuff rn

pez21:04:19

What project/sequence types do you see in the manu?

Ben Lieberman22:04:23

Now that I've already connected once shadow-cljs shows up. But the other options are generic, clojurescript nREPL server, babashka, nbb, joyride

pez22:04:38

What OS are you using? And version of VS Code would be good to know as well.

Ben Lieberman22:04:08

Windows 10 running VSCode and Clojure etc through WSL

Ben Lieberman22:04:49

VScode version 1.77.q

pez22:04:28

OK. Maybe Windows 10 + WSL has something to do with it. Could be that the glob is slow. Can you check if you press esc on the project type menu and try to connect again, if shadow shows up then?

Ben Lieberman22:04:02

Yeah its there after I escape

pez22:04:54

Please file an issue. Do it from vscode’s help menu. Then some system info will get attached.

Ben Lieberman22:04:37

From this menu, yes?

pez22:04:21

Yes, like that.

2
pez22:04:04

Dear Calva friends, a bug is fixed: https://github.com/BetterThanTomorrow/calva/releases/tag/v2.0.348 • Fix: https://github.com/BetterThanTomorrow/calva/issues/2144 (Not that most of us notice the bug, because clojure-lsp has nrepl’s back here.)

👍 2