This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-07
Channels
- # announcements (4)
- # babashka (59)
- # beginners (26)
- # calva (34)
- # clj-kondo (3)
- # cljs-dev (1)
- # clojure (77)
- # clojure-austin (4)
- # clojure-europe (20)
- # clojure-nl (2)
- # clojure-norway (11)
- # clojure-spec (3)
- # clojure-uk (4)
- # clojurescript (103)
- # community-development (2)
- # cursive (15)
- # datalevin (12)
- # datascript (38)
- # datomic (1)
- # deps-new (2)
- # events (3)
- # figwheel-main (6)
- # fulcro (9)
- # honeysql (12)
- # jobs (4)
- # juxt (18)
- # kaocha (19)
- # lsp (42)
- # missionary (2)
- # pathom (14)
- # polylith (6)
- # portal (6)
- # reagent (8)
- # reitit (4)
- # releases (2)
- # shadow-cljs (17)
- # testing (1)
- # tools-deps (50)
- # vim (46)
- # xtdb (12)
for ts, there is https://github.com/rikukissa/typehole, could there be such a thing for Clojure? Both Spec and Malli have type providers. Not sure how useful this would be, but cool anyway.
Wow, that sure looked very cool! Would be interesting with an example with how it could look like using Malli and/or spec.
Hey @U055NJ5CC. Thanks for your work on malli . Are you referring to convenience editor support for this feature of malli? https://github.com/metosin/malli#inferring-schemas. So, basically a command / UI menu for generating a schema for a data structure at the cursor (or something like that)?
Yes, you could do typehole-thing with, malli, mallireika
in finnish 🙂 But, I’m not sure if that would be super useful, just cool I guess. But, If there is anything in calva where malli could be used to help, I’m all ears and happy to help.
Definitely could be a cool convenience feature for some users. Haven’t thought this through all the way, but with current Calva features, maybe a custom repl command could be used in conjunction with a malli call to generate a schema for the current form, and maybe the result could be printed in the file below the current form, or copied to the clipboard, or something like that.
(For more info: https://calva.io/custom-commands/)
if there is an easy way to do that with custom repl command, please write a "typehole with calva & malli" post and share it :)
@U0ETXRFEW Any interest in trying this? 😄
Typehole looks really awesome. (Even if I am actually struggling with understanding what is happening in that gif.) Building something like it for Clojure should be quite possible. It's a bit outside of Calva's scope but Calva's API could be leveraged by another extension. Or #joyride, of course. Might be that we need to expose some pretty printing facilities in that API.
Something simpler, yet probably useful, could probably be done with a custom command, as you are suggesting, @U9A1RLFNV. I'll have a look at it.
It's not a ”Typehole with Calva & Malli” so I didn't call it that. At least not in a way that most people can understand 😃 https://www.youtube.com/watch?v=MW-1Ov8ynWw
This is the Custom REPL Command keybinding definition:
{
"key": "ctrl+alt+m ctrl+enter",
"command": "calva.runCustomREPLCommand",
"args": {
"repl": "clj",
"snippet": "(require '[malli.provider :as mp]) (mp/provide $current-form)",
}
},
@U055NJ5CC it would be nice with a chat where we try to envision a more dynamic typehole-thing. At first to figure out if it is something within reasonable reach and worth some efforts.
Not strictly related to Calva, but to VSCode: When I navigate to a file from a JAR, sometimes I want to edit the code in order to reload it in the REPL. However VSCode doesn’t let me and says “Cannot edit in read-only editor”.
I've seen some discussion around this somewhere. Can't recall where right now... Anyway, what I do is that I load the file and then paste the code I want to change in the REPL window and edit and re-evaluate it there. Not super straight-forward, but anyway.
How could it be that it’s so hard to convince VSCode to let me edit a buffer?
I am not asking for saving my changes in JAR!
Here's an issue on a vscode extension discussing it a bit. It leads to another issue (on vscode) where the answer to your question seems to be able to find. (TL;DR: Because reasons). https://github.com/alefragnani/vscode-read-only-indicator/issues/20
btw. That extension has a toggle for readonly files. But it only works if they are loaded from the file system.
Does it work if the file is loaded from a jar?
No, only from the file system. It cheats. Since VS Code has no API for toggling readonly, this extension chmods the file.
Shouldn't be too hard to read the editor contents into a new editable file. https://github.com/BetterThanTomorrow/joyride if you want have a go at it. And this should help get you going. https://stackoverflow.com/a/41069687
If you actually have the code locally you could also connect into the REPL from that project. clojure-lsp would handle it correctly. (that’s what I do at work)
Instead of copy paste to the REPL window, another workaround is to simply copy the entire readonly document, open a new untitled document, paste the code there. cmd+a cmd+c cmd+n cmd+v
. Edit and re-evaluate at will. And like @U90R0EPHA says, Joyride can help in automating it:
(p/let [text (vscode/window.activeTextEditor.document.getText)
doc (vscode/workspace.openTextDocument #js {:language "clojure", :content text})]
(vscode/window.showTextDocument doc #js {:preview false, :preserveFocus false}))
Binding that to a shortcut can be done in some different ways, the most straightforward being:
{
"key": "alt+ctrl+r",
"command": "joyride.runCode",
"args": "(p/let [text (vscode/window.activeTextEditor.document.getText)\n doc (vscode/workspace.openTextDocument\n #js {:language \"clojure\", :content text})]\n (vscode/window.showTextDocument doc #js {:preview false, :preserveFocus false}))"
}
Hello, is there a way to print the “jackInEnv” key/value pairs to the repl?
My repl instances do a lot of communication with AWS and other systems to get tokens and such. Normally I export these from the shell. I “think” I got them in the jackInEnv settings, but would be good to have a way to confirm it.
Would it help if Calva printed the jackInEnv it uses before it executes the jack-in command?
that would be great