Fork me on GitHub
#calva
<
2022-11-09
>
amithgeorge08:11:07

How do I "jump to definition" for a clojure function defined in another library/jar? For eg, when I press F12 (windows vscode) on the function reitit.swagger/create-swagger-handler , I expect to jump to its definition. Right now I get a message, "no definition found".

amithgeorge08:11:22

my repl is connected, and the file is evaluated in the repl

amithgeorge08:11:35

does this functionality depend on the presence of certain nrepl middlewares? this repl is started by the application code, I haven't seen which middlewares it loads.

pez08:11:38

Calva should complain when it connects the repl, if the middleware (cider-nrepl) is missing. Is the app running in a container?

amithgeorge08:11:36

The app is running inside WSL2. I started vscode from inside WSL2.

pez08:11:59

That should work, afaiu.

pez08:11:05

Definitions work for symbols in your own code base?

amithgeorge08:11:28

The nrepl server is started using

(nrepl/start-server :port port :bind bind)
Connecting to the repl print this,
; Connecting ...
; No nrepl port file found.
; Hooking up nREPL sessions...
; Connected session: clj
; TIPS:
;   - You can edit the contents here. Use it as a REPL if you like.
;   - `alt+enter` evaluates the current top level form.
;   - `ctrl+enter` evaluates the current form.
;   - `alt+up` and `alt+down` traverse up and down the REPL command history
;      when the cursor is after the last contents at the prompt
;   - Clojure lines in stack traces are peekable and clickable.
; Evaluating 'afterCLJReplJackInCode'

amithgeorge08:11:36

> Definitions work for symbols in your own code base? You are right. Even this doesn't work.

pez08:11:43

Have you loaded the file?

amithgeorge08:11:24

Yeah. Ctrl + Alt + C, Enter

amithgeorge08:11:24

Evaluation succeeded, the namespace changed to this in the repl. I can call the functions in this ns from the repl.

pez08:11:48

You beat me to it. 😃

simple_smile 1
pez08:11:24

What do you see in the dev console? (VS Code Help menu -> Show Development Tools).

pez08:11:40

Which version of Calva are you using?

amithgeorge08:11:54

When I press F12 on a function in my own codebase, I see the dev console print the error message "ERR The server does not recognize or cannot perform the 'info' operation".

amithgeorge09:11:46

Welcome to Calva. Happy Clojure and ClojureScript coding! ??

Please check these resources out:
  Calva Documentation: 
  #calva at the Clojurians Slack: 
  Bug reports: 

If you like Calva, please consider how you can contribute: 

Calva is utilizing cider-nrepl and clojure-lsp to create this VS Code experience.
  nREPL dependencies configured:
    nrepl: 1.0.0
    cider-nrepl: 0.28.5
    cider/piggieback: 0.5.3
  clojure-lsp version configured: latest

If you are new to Calva, please consider starting with the command:
  **Calva: Fire up the Getting Started REPL**
  

(See `showCalvaSaysOnStart` in Settings to control the auto-showing of this message panel.)

clojure-lsp version used: 2022.11.03-00.14.57
clj-kondo version used: 2022.11.02
Not sure where is the calva version shown ...

pez09:11:26

You can see the Calva version in the Extensions pane.

amithgeorge09:11:42

Yeah, its an nrepl issue. I connected a new repl, started by Calva + Leiningen, once that is connected, everything works. If I use the nrepl started by the app, then F12 doesn't work

pez09:11:59

Yes, the repl probably lacks the cider-nrepl middleware. But Calva should fall back on clojure-lsp in this case. And it should inform you about the missing middleware when connecting the REPL. So I am hoping you are on an old Calva.

amithgeorge09:11:15

Using [cider/cider-nrepl "0.26.0"]. any tips on what all I need to change to this line, to enable proper Calva+Cider support? (nrepl.server/start-server :port 7000)

amithgeorge09:11:32

I am on Calva version v2.0.318

pez09:11:41

Hmmm, then something is wrong with the fallback mechanism...

amithgeorge09:11:50

The extension panel showed a message "Reload required". I clicked that. Also restarted VS code for good measure. This time when I connect to the built-in application repl, I was shown an error message notification, that asked me to visit the url "https://calva.io/connect/".

amithgeorge09:11:15

is this what you expected to happen?

pez09:11:25

Awesome. Thanks! Yes, that's what I expect.

pez09:11:29

You see in that ^ Calva says output, which versions of nrepl and cider-nrepl Calva prefers. You can also use the command Calva: Copy Jack-in command to clipboard, to see the command line Calva would use to start the repl.

pez09:11:07

Before you fix the repl middleware, can you confirm that the definitions work with the latest Calva?

amithgeorge09:11:59

This is awesome. Yeah, I connected to the applications repl. Got the error notification. Despite that F12 works for my code and library code.

pez09:11:35

Thanks again.

pez09:11:51

You should still fix the repl, of course. 😀

👍 1
amithgeorge09:11:09

Thank you for the prompt response, I feel silly for not checking the extensions panel sooner 🙂 Calva is awesome! Thank you team for your hard work!!

🙏 1
❤️ 1
pez09:11:31

You are welcome! 🙏 Please consider filing a review on the marketplace.

💚 1
pez09:11:41

We should print the version and advice to update in Calva says and/or the output/repl window.

👍 1
amithgeorge09:11:30

> Please consider filing a review on the marketplace. Done!

pez09:11:23

calva 🙏❤️

pez09:11:32

Have I mentioned that I have set VS Code’s hover delay to 1300 ms, and that it is blissful? What settings do you recommend? Please share! 🧵

pez13:11:02

Dear Calva friends, I've noticed lately that Calva's default on-type-indenter is in conflict with the formatter in certain situations. I haven't been able to pinpoint what it is about before, but today I realized it is happening when I work with garden, and also a bit about why it happens. Garden has a few def<something-something> macros, and when using them, the on-type-indenter indents like so:

(garden.def/defstyles styles
                      |)
While the correct indent position (given default cljfmt config) should be:
(garden.def/defstyles styles
  |)
And, indeed if you hit tab in this situation:
(garden.def/defstyles styles
                      |
  [:.foo])
You'll get:
(garden.def/defstyles styles
  |
  [:.foo])
This is because cljfmt default config has this rule:
#"^def(?!ault)(?!late)(?!er)" [[:inner 0]]
Which our on-type-indenter applies on the full symbol and it doesn't match garden.def/defstyles, of course. I know how to fix this particular family of cases, but I realize I'd like to know a bit more about this to get a proper fix in place. So, this is a call for help collecting instances where the indenter indents differently from the formatter. Please experiment with it a bit and report any findings here: • https://github.com/BetterThanTomorrow/calva/issues/1956 This is especially interesting if you have some custom indentation rules defined. If so, please include the rules of relevance with the report. Thanks in advance! 🙏 ❤️

Ben Lieberman17:11:29

Much gratitude for Calva in general but especially the Ctrl+Alt+Enter shortcut for eval'ing the form under the cursor. It's like a superpower! gratitude

🙏 1
gratitude 2
pez18:11:44

That’s not the default binding, have you rebounded it?

Ben Lieberman18:11:31

No, I'm just using the wrong terminology 😅 I mean the "Evaluate from start of list to cursor, closing brackets" binding

Ben Lieberman18:11:37

Which appears to be the standard

pez19:11:30

Indeed it is. 😃

pez19:11:25

We recently added a command for evaluating the selection, closing the opened brackets. Have you found that one?

Ben Lieberman19:11:16

No, which one is that?

dumrat01:11:00

Ctrl+Enter right? I also enabled "eval on save" which helps too. Calva is great. Unfortunately Calva can't download clojure-lsp due to corporate firewall. Wish it were bundled with calva like clj-kondo.

pez06:11:21

You know you can give Calva the path to your clojure-lsp binary and it will use that, @UC1DTFY1G?

dumrat06:11:25

@U0ETXRFEW I am aware. The trouble is my corporate firewall doesn't let me download nearly anything. So I really can't get the clojure-lsp zip file for windows. I can't even clone from github. It's messed up. I didn't mean anything against Calva. I was just venting 😄

pez06:11:44

No worries. I didn't take it as critique against Calva.

👍 1
pez20:11:44

http://calva.io is not Calva-colored for some reason. I wonder what's up with that...