This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-05-24
Channels
- # announcements (27)
- # beginners (105)
- # calva (10)
- # clojure (2)
- # clojure-europe (10)
- # clojure-nl (1)
- # clojure-norway (11)
- # clojure-sweden (5)
- # clojure-uk (20)
- # clojurescript (7)
- # code-reviews (4)
- # community-development (2)
- # cursive (10)
- # data-science (2)
- # emacs (20)
- # events (1)
- # fulcro (1)
- # gratitude (1)
- # guix (1)
- # hyperfiddle (4)
- # off-topic (4)
- # overtone (24)
- # rdf (2)
- # releases (4)
- # ring (4)
- # shadow-cljs (26)
- # squint (76)
- # yamlscript (29)
is there an example somewhere for how to do this with calva? set up a keybind that evaluates some code in the active repl: https://github.com/robert-stuttaford/.emacs.d/blob/master/cider.el#L86-L104
we have one VS code user on our team who doesn't have this helper and i'd like to provide it to her!
Hi! The gist of this you would use https://calva.io/custom-commands/ for. Here’s an example:
{
"key": "ctrl+alt+c -",
"command": "calva.runCustomREPLCommand",
"args": {
"snippet": "(clojure.repl/pst)"
}
},
You will need to escape newlines, because JSON. (There is a way to configure this in an EDN file, but it gets a bit involved given that you want to combine with saving the file.)
To combine this with saving the file there’s a command for saving the file, workbench.action.files.save
. And there’s a command for running several commands in succession, runCommands
. I wrote a little something about runCommands here: https://blog.agical.se/en/posts/vs-code-runcommands-for-multi-commands-keyboard-shortcuts/
The check for wether the buffer has a filename I do not quite understand, but VS Code has a very expressive language for making keybindings conditional, using https://code.visualstudio.com/api/references/when-clause-contexts.
You should be able to get at least very close to the Emacs solution this way. There is of course also #joyride, but I think it’s overkill for this one.
Please don’t hesitate to ask more as you get more specific questions.
It all looks like stuff for a blog post of mine (or yours) once you have implemented it. 😃holy shit @U0ETXRFEW this is an amazing response, i feel honoured, thank you so much 😄
Oh, forgot, To find command ids for things you want to bind keys to, I recommend the Keyboard Shortcuts editor. Default keybinding on mac is cmd+k cmd+s. The search feature is quite powerful there. Right-click items to find actions like copying the command id and more.
You are entirely welcome, @U0509NKGK! 🙏
the save-buffer thing was a total red herring, i apologise - the thing i actually care about is preventing people from leaving lots of (comment (cognician.system/restart-systems!)) all over the countryside 😂
A thing with keyboard shortcuts in VS Code is that they are always either predefined or entirely personal. There is no way I know of to share them as project config. If you find that you want to support this restart-systems! as a project config, you can define custom repl commands in either .calva/config.edn
or in .vscode/settings.json
. There are a bunch of predefined keyboard shortcuts that you can bind to. And Calva also can bring up a menu with the snippets.
I know you said you were set, but anyway. And for anyone else finding this thread.
oh rad, this is valuable, thank you