Fork me on GitHub
#calva
<
2019-04-12
>
pez06:04:53

@lspector , it could be that the cljs repl fails to start in that cljs-quil repl. I have noticed that recently there seems to have changed something in regards to piggieback dependencies. This is why i prefer long beautiful command lines. They are more flexible than configuration buried in projects. But I'll try it myself and fix that project if I understand what is missing.

pez06:04:43

@somedude314 , if you are connected to a cljs project, Calva creates two repl connections for the editors to use. One for clj files and one for cljs files. So if you are editing a cljs file and do inline evals, it will be the cljs repl that handles the evaluation for you. And for clj files, the clj repl. Cljc files default to clj, but you can toggle it to cljs with a button in the status bar.

adam13:04:31

Thanks, I had to upgrade a couple of nrepl dependencies and it worked as you described.

metal 1
pez06:04:36

Calva also creates two vscode terminals and connect one to the clj repl server and the other to the cljs server. You select which one to use with vscode's terminal selector. (And for the “evaluate in repl terminal” commands calva uses the same logic as for the inline evaluations.)

pez07:04:00

@lspector, actually, the piggieback dependecies are correct in the project. Something else is going on. You might notice at the terminal prompt where you started the repl and did (fighwheel start) everything compiles and the app starts, but there is never any cljs-repl prompt appearing. So, even w/o Calva in the picture, something has changed. Totally strange, and you and I are both witnesses that this worked just a week ago. I'll try to figure it out, but right now I am just totally clueless.

pez07:04:02

@lspector: OK, so I didn't figure it out, but I found a fix that works on my machine. If I bump the figwheel-sidecar dependency up to 0.5.19-SNAPSHOT the cljs-repl starts and Calva can connect to it. I can't for the life of me understand why that wasn't needed a week ago, but, hey, at least now we get a cljs repl. I have pushed the change to the repo, so please pull and see if it works out there as well.

pez08:04:16

About those example code lines to practice how to inline eval in Calva that I put in core.cljs of that project. I used them the other day when my son asked about the unit circle. He knows that sin(PI/6) is 1/2, so he started laughing at (Math/sin (/ Math/PI 6)) => 0.49999999999999994. We then tried it in CLJ and he relaxed when it answered correctly. 😃

pez08:04:46

Hmmm, OK, so now I think I know what happened...

pez08:04:47

Yep. I was using a SNAPSHOT dependency on cider-nrepl, which then moved. Now fixed that in the repo, @lspector, so it should stay working now. Totally sorry for the inconvenience I caused.

👍 1
slipset08:04:00

So, a colleague is exploring Clojure and Calva, which is great, we found a little stumbling block:

slipset08:04:06

He started by asking:

slipset08:04:12

> Clojurians, is there a shortcut in Calva to say (in-ns '...) or do I have to type it out myself?

slipset08:04:32

and followed up with

slipset08:04:34

> I.e. when evaluating a form in the REPL, I would like it to infer what namespace I’m in from the file

slipset08:04:55

Turns out he’d found the wrong hammer:

slipset08:04:06

Calva has two quite similar commands:

pez08:04:42

Yeah, I've renamed them slightly in Calva 2.

slipset08:04:03

He was using Evaluate current form (or selection) in REPL terminal where he should have used Evaluate current top level form

pez08:04:03

There is a command for (in ns), though.

slipset08:04:13

I guess my point is, (and I see you’ve thought about this too), is that Evaluate current top level form should be renamed to Calva: evaluate-DWIM or some such 🙂

slipset08:04:52

Do What I Mean 🙂

pez08:04:04

Haha, yeah. I'd love that too.

slipset08:04:34

Just one data point though, and hopefully some food for thought.

pez09:04:54

So these are the names I use in Calva 2.

slipset09:04:52

I think one of the things that threw him off is the wording top level form

pez09:04:00

Also, the commands for sending forms to the REPL will evaluate them in the namespace of the file, regardless of what namespace the REPL window is using.

slipset09:04:15

In his mental model, the top level is the ns

pez09:04:26

Ah, interesting.

slipset09:04:32

I guess that’s not for you to solve, but it’s an observation none the less

pez09:04:28

paredit.js uses the name evalDefn instead of top level. That confused me, so I changed it.

slipset09:04:35

I’ve never looked at the name of these things when I use Cider, as I’ve always just used the keybindings.

slipset09:04:22

C-c C-c runs the command cider-eval-defun-at-point (found in
cider-mode-map), which is an interactive compiled Lisp function in
'cider-eval.el'.

pez09:04:22

In Calva the evaluation of top level forms take a front seat when it comes to key bindings.

pez09:04:38

That defn again!

pez09:04:50

Totally strange name.

slipset09:04:12

Which may or may not be precise, as I haven’t seen what happens if I do a C-c C-c on a top-level let-binding 🙂

slipset09:04:20

Hang on 🙂

slipset09:04:42

Yup, the name is lying 🙂

slipset09:04:09

it should be renamed to cider-eval-top-level-form-at-point.

pez09:04:30

^ @bozhidar 😄 ^

slipset09:04:30

I wonder if @bozhidar will accept a PR :thinking_face:

pez09:04:45

Haha, two spammers

slipset09:04:38

While I agree that some variation of eval-top-level-form is technically more correct, eval-current-defn might make more sense to new-commers

slipset09:04:59

or even redefine-current-defn

pez09:04:05

Also I think CIDER does not consider comment forms creating a new top level, by default. Which is a bit strange to me.

pez09:04:56

I think it risks causing confusion that redefine-current-defn would be the thing to use for evaluating the ns form and whatever top level form. It's not easy to decide about names, always someone will be confused. But certainly, something should be done to ease the path for newcomers.

Robert Nikander12:04:52

It doesn't appear to highlight #(...) as comments. Is that something I can enable, or is it not implemented yet?

Robert Nikander12:04:59

Also not seeing functions listed in the outline panel. Is that not implemented yet?

Robert Nikander12:04:14

I'm just trying it out (been using Emacs). It looks promising so far.

pez12:04:54

None of that is implemented yet. But you are reminding me about my branch which tries to fix that #_ highlighting. I spent a lot of time on it and I think I might be close even. But, not close enough for release. I should pick it up again: https://github.com/BetterThanTomorrow/calva/blob/wip/grammar-comment-expression/calva/calva-fmt/atom-language-clojure/spec/clojure-spec.coffee

pez12:04:01

About the outline, I think @alexander.minolta started to look at the symbols listing, which might be related.

Robert Nikander14:04:36

I'm guessing you have to parse Clojure yourself and the Clojure compiler gives you no help, the way some compilers have a "language server" or something like that?

guillaume14:04:53

Trying out the new calva clojure4vscode-2.0.0-SNAPSHOT.vsix

guillaume14:04:38

Is there a usage guide that explains what I should do to get the happy path? What’s the relation between jackin and connect?

guillaume14:04:14

Should I jackin AND connect or are they to be used mutually exclusive?

pez14:04:28

Very good question! I must make that relationship clearer. The answer is that jack-in will also connect you.

guillaume14:04:52

hmm does that mean I should also open a repl (like in a terminal window lein repl) prior to connect/jackin?

pez14:04:13

Somebody I trust a lot suggested to find another name than Jack-in. What it really does is start the repl server for you, correctly configured for Calva, and then connect. Thing is i am very find of jack-in. It sounds so cool! Maybe I should name Connect a bit more clearly...

guillaume14:04:35

How about: * open a local repl (jackin) * connect to a remote repl (connect)

pez14:04:52

If Jack-in works for you, then no need to lein repl anything. But if it's not (and right now it might not work for you) then you need to start the repl yourself and then connect.

pez14:04:49

Connecting to a remote might become most common use case for connect, but it is not exclusively for that...

pez14:04:37

Maybe: 1. Start a REPL and connect (jack-in). 2. Connect to a running REPL.

pez14:04:24

(Calva has a bit poor support for remote repls right now, so it probably shouldn't be promoted.)

guillaume14:04:09

I used the remote repl with some success debugging a remote onyx cluster 🙂

guillaume14:04:51

I found some issues with discoverability when stumbling on blocks using macros in general

pez14:04:32

I think we need some mapping of file paths.

guillaume14:04:48

Though you might already be aware of it, if not I should probably try to make a minimal reproducable case

pez14:04:16

Oh, please do and file it as an issue.

guillaume14:04:17

or perhaps the new beta is expected to fix some of those?

pez14:04:07

I was completely unaware until now. 😎

bozhidar15:04:25

> That defn again!

bozhidar15:04:51

The naming is weird on the outside, but defun is the Emacs Lisp terminology for a top-level form in most languages.

bozhidar15:04:06

@slipset @pez ^^

bozhidar15:04:52

Not sure who decided this was a good idea, but it’s such a strong convention at this point, that it’s extremely unlike it would ever be changed.

slipset15:04:04

:) I don’t really think I was serious in suggesting a change of name.

pez15:04:39

I suspected some age-old reason. 😎

bozhidar17:04:45

It’s really hard to let go of the past. 😉

pez17:04:14

It is. And > The naming is weird on the outside is telling. Calva is sort of there for people coming from the outside. Fortunately vscode is very good at surfacing functionality based on searching. So I need only include defun in the command names/descriptions and the insiders will be able to find them. Doing that right now.

pez17:04:23

Like so:

slipset19:04:41

That’s super nice!

slipset19:04:37

I would, however, and feel free to ignore, choose defn over defun, as defn is what it’s called in Clojure.

pez19:04:17

I think defun avoids it being fully confused with defn, and that that is a good thing.

hoppy23:04:00

In new snapshots, where does the standard output of the jacked in app end up going (aka (println))