Fork me on GitHub
#calva
<
2021-01-29
>
pez00:01:29

Anyone want to help me test this VSIX, adding some variables to custom command snippets? https://10533-125431277-gh.circle-artifacts.com/0/tmp/artifacts/calva-2.0.157-986-custom-snippets-variables-6783ff1a.vsix From the PR: • $current-form$top-level-form$current-fn (The symbol at call position) • $top-level-defined (The second symbol of the top level form) TODO: • Probably want to use the form at the call position, not just a a symbol • Documentation • Figure about the names of these variables

calva 6
pez00:01:02

Here’s a sample setting I am using for testing:

"calva.customREPLCommandSnippets": [
        {
            "name": "Call Current Form",
            "repl": "clj",
            "snippet": "($current-form)"
        },
        {
            "name": "Call Current Top Level Form",
            "repl": "clj",
            "snippet": "($top-level-form)"
        },
        {
            "name": "Tap Current Form",
            "repl": "clj",
            "snippet": "(tap> $current-form)"
        },
        {
            "name": "Evaluate Current Function Symbol",
            "repl": "clj",
            "snippet": "$current-fn"
        },
        {
            "name": "Call Current Top Level Defined",
            "repl": "clj",
            "snippet": "($top-level-defined)"
        },
        {
            "name": "Eval last result",
            "repl": "clj",
            "snippet": "*1"
        }
    ]

Janne Sauvala06:01:34

That was fast! I’ll take this into use later today or tomorrow by latest bananadance

❤️ 3
Janne Sauvala17:01:47

@pez works like a charm! Thanks you, this was just what I wanted 🙂 Was it that I cannot assign custom keybinding to these snippers because of limitations in vscode? It is a little tedious to select those snippets from the list. Luckily vscode remembers the last snippet I used so it is not too bad - I just need to hit enter in the snippet list.

pez17:01:24

I number the commands for this reason. So maybe remap the default keybinding to something like ctrl+alt+. Then, for running the first command in the list it becomes almost a chord: ctrl+alt+. 1 enter.

pez17:01:08

Actually you don’t need to change the shortcut, but it does get more convenient.

pez17:01:37

I am now considering changing the default…

Janne Sauvala17:01:24

It is not possible to bind for example ctrl+alt+t to Tap Current Form snippet?

pez17:01:17

I don’t think so. Might be some extension that can help with it, but I somehow doubt it.

Janne Sauvala17:01:23

In Clover that functionality was implemented as vscode “Tasks: Run Task” (https://github.com/mauricioszabo/clover#custom-commands) and it seems you can bind those individual tasks to a custom keybinding but you will not see them in the command palette when trying to search them. I don’t know how you have implemented this feature, do you use that Task approach? 🙂

pez17:01:49

No, nothing like that.

pez17:01:20

I think we could expose commands like Run Custom Snippet 1/2/3/etcetera, and then the user could bind those to whatever.

Janne Sauvala17:01:02

That would be great and would make me 100% satisfied. Now I’m ~85% since I can send tap’s easily but switching between different commands doesn’t feel as fluid as I would wish 🙂

pez20:01:40

Let’s accept the 85% gain and you can file that as a separate issue? ❤️

Janne Sauvala20:01:42

Yes, I’ll do that ✌️:skin-tone-2:

metal 3
pez20:01:05

That said, I think I am going to add a general Tap Current Form command. So maybe your particular use case won’t be dependent on the custom snippets anyway. 😃

Janne Sauvala13:01:46

That could also work 🙂 I hope you would still keep the new snippets “form api” there since it feels quite powerful for more complex stuff

pez13:01:18

Oh, definitely. I just merged that PR. Going to abuse it heavily myself. 😀

Janne Sauvala20:01:45

Great! ✌️:skin-tone-2:

pez00:01:36

Super smooth to tap> things to Reveal with those variables available. 🚀

clyfe15:01:55

> ERROR: Unhandled REPL handler exception processing message {:op complete, :ns riviera.core, :symbol goog, :id 11, :session ..., :context ... I keep getting these in the repl, and autocomplete hangs. Note I'm I have a folder opened and there are multiple projects in it, each with it's own deps.edn.

pez15:01:26

Please report it as an issue using VS Code’s issue reporter, @claudius.nicolae.

B Treebeard15:01:07

Hello all, newbie here. I'm trying to get Calva Jack-in working with Figwheel Main + Electron. I'm using the template from https://github.com/paulbutcher/electron-app. Without Jack-in, Figwheel Main launches an Electron instance when hooked up with build configuration option :launch-js ["npm" "start"] etc. But with Calva Jack-in, this start script configuration option appears to be ignored. Any pointers on how I can hook this up properly will be most appreciated.

pez15:01:25

Welcome @b.treebeard! I do think it is possible to get Jack-in to do it for you. It is a matter of providing an alias with the right main options. There might be people in the #cider channel who are familiar with what it takes to both launch the repl and something like Electron. And most often, what works in CIDER can be adapted to work in Calva, because Calvados is made from Cider. 😃

pez15:01:22

I’ll try to find some time to experiment with that template as well.

pez17:01:54

@b.treebeard I can get the repl connected. A bit quirky, but anyway. Here’s how. I added this alias to deps.edn:

:jack-in {:extra-paths ["src/main" "src/renderer" "src/config/dev" "src/test"]}
(That’s the :dev alias where I have removed :main-opts, because …. well, long story.) At jack in I choose this alias, and then when Calva says that the cljs repl is connected (untruthful, and together with some other misleading info) I open a second terminal in vscode where I run
npm start
Electron starts and when in the terminal I see something like:
[Figwheel REPL] Session ID: 186d3204-4d8e-436a-9332-9b3d025110df
[Figwheel REPL] Session Name: Glenn
Then the repl is connected. The prompt is not updated. But if I evaluate something like 1 there, I get the correct answer and the prompt now shows that it is a real cljs session we are connected to.

💯 3
pez17:01:13

I am sorry that Calva handles this a bit clumsily, but everything does seem to work once connected.

B Treebeard17:01:26

@pez Awesome, let me give this a go! (Yeah, I'd gotten as far as removing the :main-opts, because I wasn't seeing the -m nrepl.cmdline ... otherwise.)

B Treebeard17:01:51

Thanks much, and no apologies necessary whatsoever!

pez17:01:36

Thanks for showing me the template. TIL.

👍 3
B Treebeard17:01:01

I learnt only yesterday, so you're at most a day behind. 😂

pez17:01:27

😃 Slightly related is this example project of mine: https://github.com/PEZ/rn-rf-shadow I’ve actually had it target Electron a bit. Have had intentions to include that in the example, but need to figure some stuff out better first.