calva

Wednesdays you might find @U0ETXRFEW in the Gather Calva space. Invite is https://gather.town/invite?token=GZqrm7CR and the password is `Be kind`.
flowthing 2021-04-15T11:05:29.495400Z

So related to my question yesterday: how does Calva determine whether ClojureScript evaluation via shadow-cljs is available?

flowthing 2021-04-15T11:19:42.498700Z

Hmm, well, I finally got it to work, so never mind I guess. 🙂

pez 2021-04-15T11:20:06.499500Z

First it needs to know it is supposed to be available. If so it clones the CLJ session and converts the clone to a CLJS session. Then it is a matter of shadow-cljs to connect the app to this session, which it will do once the app is running.

flowthing 2021-04-15T11:20:14.499700Z

Although only by connecting, not jacking in, but that'll get me started.

flowthing 2021-04-15T11:20:30.000100Z

Right, the first bit is what I was asking about.

flowthing 2021-04-15T11:20:38.000500Z

The rest I'm familiar with.

pez 2021-04-15T11:21:59.001800Z

It is the same, wether or not connecting or jacking in. The command Copy Jack-in Command line (or some such) will give you the command that Calva uses to start shadow-cljs.

flowthing 2021-04-15T11:22:32.002300Z

CIDER middleware won't (necessarily) be available if I connect. though, right?

pez 2021-04-15T11:23:01.002700Z

It needs to be injected or present in the project deps.

flowthing 2021-04-15T11:23:40.004Z

Yeah. Anyway, the question I'm interested in is how Calva knows ClojureScript evaluation is supposed to be available. 🙂

pez 2021-04-15T11:24:18.004100Z

Have I answered that, or are you still wondering?

flowthing 2021-04-15T11:24:36.004300Z

Still wondering.

pez 2021-04-15T11:24:43.004500Z

Tell me what you are trying to do and the steps you use and I might be able to help figure.

flowthing 2021-04-15T11:25:20.004700Z

I jack in -> Choose "Leiningen" -> start shadow-cljs watch from the REPL -> run (shadow.cljs.devtools.api/nrepl-select :app).

flowthing 2021-04-15T11:25:32.004900Z

Can't evaluate ClojureScript, because Calva won't let me.

flowthing 2021-04-15T11:25:42.005100Z

My question is, why not? 🙂

pez 2021-04-15T11:27:24.005300Z

Because Calva doesn’t know you want CLJS. You’ll need to use a project type which includes that knowledge. I know it failed with “Leiningen + shadow-cljs”, but you could try with only shadow-cljs or the lein-shadow one.

flowthing 2021-04-15T11:28:25.005500Z

Yes, so my question is, how does Calva determine whether I want CLJS? I'm asking so that I could dig into the Calva code a bit to figure out whether there's a way to make it work without changing the project configuration.

pez 2021-04-15T11:28:56.005700Z

It knows it by the project type you choose when connecting.

flowthing 2021-04-15T11:29:23.005900Z

Okay, I see, so that's the only thing it uses for making the determination. That won't help me, then.

pez 2021-04-15T11:29:31.006100Z

Is anyone using CIDER with the project?

flowthing 2021-04-15T11:29:34.006300Z

shadow-cljs presumably won't work, because the shadow-cljs nREPL server isn't running yet.

flowthing 2021-04-15T11:29:37.006500Z

No.

flowthing 2021-04-15T11:30:01.006700Z

Anyway, this is enough information for me to go on. Tack ska du ha! 🙏:skin-tone-2:

pez 2021-04-15T11:30:17.006900Z

Är du från Sverige?

flowthing 2021-04-15T11:30:31.007100Z

:flag-fi:

pez 2021-04-15T11:30:54.007300Z

Awesome.

pez 2021-04-15T11:31:17.007500Z

Why isn’t the shadow-cljs nREPL server running?

flowthing 2021-04-15T11:31:35.007700Z

Because we start it from the REPL.

pez 2021-04-15T11:33:29.008100Z

I see. Maybe you will need to configure a custom connect sequence then. https://calva.io/connect-sequences/

flowthing 2021-04-15T11:35:45.008400Z

Thanks! I'll give that a try.

pez 2021-04-15T11:36:10.008600Z

startCode would be where to put the (server-start!) (probably in a do with the require)

pez 2021-04-15T11:39:36.008800Z

Let me know how you fare. I’m curious.

flowthing 2021-04-15T11:40:27.009Z

Will do. Giving it a try now.

flowthing 2021-04-15T12:05:38.009200Z

All right! I got it to work by defining a connect sequence like this:

{
                "name": "App",
                "projectType": "Leiningen",
                "cljsType": {
                    "startCode": "(user/start)",
                    "connectCode": "(user/cljs-repl)"
                },
                "isConnectedRegExp": "To quit, type: :cljs/quit",
            }
It's not exactly what I want, because I'd prefer to leave the things startCodeand connectCode do up to the user. Based on the documentation, it sounds like isStarted: true should do what I want, but if I set that, I can't evaluate from the ClojureScript buffer.

flowthing 2021-04-15T12:06:24.009400Z

Anyway, this is good enough for me (my colleague, really). Thanks for the help!

pez 2021-04-15T12:09:56.009600Z

I don’t quite recall right now what isStarted is supposed to do, but maybe it is just that, that Calva expects it to be started.

flowthing 2021-04-15T12:10:40.009800Z

Yeah, that's how I understood it. However, if I set it, it seems to assume that ClojureScript isn't necessary.

flowthing 2021-04-15T12:14:27.010Z

Also, this is unrelated, but I just happened to notice that if you evaluate a form such as (do (Thread/sleep 5000) {:a 1}) in one view, then open another view before the sleep is done, Calva shows the inline evaluation result in the currently active view, not the view where you evaluated it.

pez 2021-04-15T12:15:31.010200Z

Please report as an issue.

pez 2021-04-15T12:16:54.010400Z

> Yeah, that’s how I understood it. However, if I set it, it seems to assume that ClojureScript isn’t necessary. It will still try to connect. So the repl really needs to be started. Which it isn’t in your case, iiuc.

flowthing 2021-04-15T12:17:30.010600Z

Oh, I see.

pez 2021-04-15T12:18:08.010800Z

When reporting the issue, “views” are called “editors” in VS Code.

pez 2021-04-15T12:37:54.011Z

If you really want it to be manual steps you might get away with something like

"calva.replConnectSequences": [
        {
            "name": "foo",
            "projectType": "Leiningen",
            "cljsType": {
                "dependsOn": "shadow-cljs",
                "startCode": "",
                "connectCode": ""
            }
        }
    ]
}

pez 2021-04-15T12:38:47.011200Z

Calva will lie about it being a cljs repl at first, but once the commands have been run it should be good.

pez 2021-04-15T12:39:22.011400Z

(I’m not sure about this, but from what I remember of the implementation, I think it might work.)

flowthing 2021-04-15T12:39:46.011600Z

All right, I'll give that a try.

flowthing 2021-04-15T12:45:09.011800Z

https://github.com/BetterThanTomorrow/calva/issues/1120

pez 2021-04-15T12:47:47.012100Z

Thanks!

pez 2021-04-15T13:21:22.012300Z

I think it makes sense to have some kind of “User managed” cljs repl, btw. So regardless if that trick I speculated about works or not, I’d appreciate an issue about making it a first class citizen option. Thinking it could work a bit like you expected it to work, but it would be choosen something like : > Project type: Leiningen + Manually started ClojureScript REPL

flowthing 2021-04-15T13:22:51.012500Z

Yeah, I think that might be useful. I don't use Calva myself, though, so I think I'll leave it to someone else to create the issue. 🙂 Only got so many hours in the day...

pez 2021-04-15T13:23:44.012700Z

Fair enough. 😃

flowthing 2021-04-15T13:26:17.012900Z

Unless it becomes a real pain point for the colleague I'm mentoring, that is. 🙂

pez 2021-04-15T13:54:44.013100Z

Then maybe your colleague will file the issue? 😃

flowthing 2021-04-15T13:55:19.013500Z

I can ask. 🙂

pez 2021-04-15T13:56:15.013700Z

To me the important thing is to have someone who’ll be willing to test any attempts to fix the issues. So it is nice with someone with stakes in it filing them.

flowthing 2021-04-15T13:56:56.014400Z

Exactly.

Thomas 2021-04-15T16:33:00.017400Z

Hi. I am using the "Getting Started REPL" in VSC. I'm trying to use the (source) function to find the code behind the (map) function. I understand that I am to type (source map) into the REPL. I have tried doing this into the output REPL, and into the bottom terminal. What REPL am I suppose to use? As you probably understand, I'm not only new to Clojure but very green in programming. So please keep it simple for me!

pez 2021-04-15T16:58:11.020200Z

In Calva you seldom need to use those functions. Just hover the symbol in the regular files. Use ctrl/cmd to see definitions. Ctrl/cmd-click to navigate to the source.

Thomas 2021-04-15T17:13:49.020600Z

@pez Thanks here, as well 🙂

1
pez 2021-04-15T18:09:37.021600Z

You are welcome, söta bror! 😀