Calva version 2.0.156 is out! 🎉 :calva: • Fix: https://github.com/BetterThanTomorrow/calva/issues/969 • Fix: https://github.com/BetterThanTomorrow/calva/issues/976
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
@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.
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
.
Actually you don’t need to change the shortcut, but it does get more convenient.
I am now considering changing the default…
It is not possible to bind for example ctrl+alt+t
to Tap Current Form
snippet?
I don’t think so. Might be some extension that can help with it, but I somehow doubt it.
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? 🙂
No, nothing like that.
I think we could expose commands like Run Custom Snippet 1/2/3/etcetera, and then the user could bind those to whatever.
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 🙂
Let’s accept the 85% gain and you can file that as a separate issue? ❤️
Yes, I’ll do that ✌️:skin-tone-2:
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. 😃
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
Oh, definitely. I just merged that PR. Going to abuse it heavily myself. 😀
Great! ✌️:skin-tone-2:
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"
}
]
Super smooth to tap>
things to Reveal with those variables available. 🚀
That was fast! I’ll take this into use later today or tomorrow by latest :bananadance:
> 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.
Please report it as an issue using VS Code’s issue reporter, @claudius.nicolae.
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.
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. 😃
I’ll try to find some time to experiment with that template as well.
@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.I am sorry that Calva handles this a bit clumsily, but everything does seem to work once connected.
@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.)
Thanks much, and no apologies necessary whatsoever!
Thanks for showing me the template. TIL.
I learnt only yesterday, so you're at most a day behind. 😂
😃 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.