Hello guys, can someone help me setting up Intellij + cursive with babashka? I can't get it to recognise dependencies. Do I have to create a dummy lein project with babashka as a dependency to make it work?
@beltramo.ale If you want auto-completion things and have Cursive analyze the dependencies then probably it's enough to add a deps.edn with the deps you are using in your script(s)
Thanks, I'll try that! How does it play with pods? I would like to use lispyclouds/docker but my guess is that (require '[pod.lispyclouds.docker :as docker])
will never be accepted by cursive because the dependency from clojure should be: [clj-docker-client.core :as docker]
.
@beltramo.ale If you use the babashka nREPL server you can get auto-completions for this, but pods aren't dependencies that can easily be statically analyzed
Right, I see.. Is there a better IDE for developing babashka scripts? What do you guys use then?
I'm trying to run an nrepl (`bb --nrepl-server 1667`) with cider in emacs. This seems to work fine, usually, but this morning the repl just dies silently when I try to eval a buffer. I'm sure it's just an error in my code, but I don't get any error messages (either on the bb side, nor on the cider side). Is there a way to see what's going wrong? I tried --verbose
with no result.
Ah, I see what's happening. I'm trying to eval the whole buffer, so it's running the code and spitting out a usage message (i.e., because I don't have the required args). I didn't spot that amidst the "closed unexpectedly" message from cider.
Nevermind me.
I use emacs
@beltramo.ale Developing bb scripts should not require a lot from an editor. Just paredit + syntax highlighting maybe. Bb scripts start so fast that you usually barely need a REPL, although many people do prefer one.
If IntelliJ / Cursive gives you trouble for developing a script, maybe discuss it with the author to add better support for it.
Here's the commands I made to spawn and connect to a babashka repl, from emacs/CIDER: https://gist.github.com/llacom/f391f41cbf4de91739b52bf8bb1a6d54
I meant to improve them before sharing, but never took the time. It works for me at least :man-shrugging:
Yeah I just saw https://github.com/cursive-ide/cursive/issues/2452 the issue is that since it can't recognise imports just set everything as errors and it's unusable. I'm trying calva and it seems to do the trick. Thanks for the help, and the amazing work behind Babashka!
Calva uses both clojure-lsp and nrepl for the completions. And clojure-lsp also makes a lot of other features available. You can probably get a lot of the similar experience in Emacs using CIDER + lsp-mode. But with Calva it is out-of-the-box. Not possible to opt-out, even . 😃
“Oh no I can’t opt out of this very helpful feature”. Now that’s the kind of problems I want.
I think it's good to have opinions (defaults), but not to be stubborn: always give people a way out, unless your tool can't function without it
It might not be the right place, but is there any magic trick to have pprint with cider using bb --nrepl-server
?
@neo2551 There is an open PR for this in babashka.nrepl which is currently stalled. Maybe you could help out by reading the issue and seeing what remains to be done.
I think it's more or less done
Thanks! I believe you are too nice with respect to my skills!
But I will give a shot tomorrow.
Thanks for pointing me out to the solutoin.
Should that cause the nrepl to crash, though?
Nah, just exit normally, with a usage. Cuz that's what I asked it to do. I rewrote the script to have a -main function and then did something like this
(when (= *file* (System/getProperty "babashka.file"))
(-main))
So now I can eval the whole buffer and use the functions, but the script itself doesn't run.Is the issue just the pprint-fn
where with-out-str
should wrap it?
as in, the only remaining one? I can’t push to his branch and it would be a shame to have to open a new PR and lose the review history just to fix that one thing. Can you push on his branch?
Ah, makes sense
I can merge his PR to a branch and then you can open a new PR to that branch
I can do that
or i can open a new PR, your preference of course
if you remember, I only saw babashka yesterday, so getting set up with sci and everything might take me some time
I just wanted to encourage the PR to not die 🙂
@grazfather I merged to the pprint branch now. Feel free to continue with a new PR on that branch
I made a few comments in the old PR which have not been processed yet. Notable the one about *out*
So, I finished my first moderately-sized https://github.com/eamonnsullivan/backup-scripts/blob/master/src/eamonnsullivan/backup.clj. It will probably make any competent babashka user's eyes bleed, is basically a translation of a bash script, but it was fun to do. I originally had more actual Clojure (as opposed to calls to clojure.java.shell
) in it, but I stripped that back after I basically wiped a PC while trying to test it. 😮 (The problem turned out to be an incorrect exclude to rsync, so I was copying over a symlink to /
and when I tried to remove the directory using pure and naive Clojure, it went down that rabbit hole.) I am definitely hooked!
@eamonn.sullivan Looks like a legit script to me! Great job and hope you have recovered from your disk erasure well
it’s merged in now! just update your bb