This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-05-01
Channels
- # announcements (1)
- # babashka (73)
- # bangalore-clj (7)
- # beginners (295)
- # calva (128)
- # chlorine-clover (3)
- # cider (9)
- # cljsrn (10)
- # clojure (63)
- # clojure-europe (11)
- # clojurescript (1)
- # clojureverse-ops (3)
- # conjure (3)
- # emacs (7)
- # fulcro (13)
- # graalvm (8)
- # honeysql (16)
- # jobs-discuss (14)
- # malli (21)
- # meander (8)
- # onyx (1)
- # pathom (7)
- # portkey (2)
- # quil (3)
- # re-frame (4)
- # reagent (31)
- # reitit (2)
- # rewrite-clj (40)
- # shadow-cljs (29)
- # sql (20)
- # xtdb (13)
@borkdude I've tried new possibilities like :init
, :enter
, :leave
They are awesome and significantly reduced my scripts. Are they subject to change or stable in babashka?
BTW, :private
is not available in current-task
(bb v0.3.7)
Good to hear! Can you share your bb.edn?
Everything regarding :tasks
should be regarded instable, until this issue is closed:
https://github.com/babashka/babashka/issues/778
:private
should be available when the task is named like -foo
or is explicitly marked :private
. Else the private key might not be there.
Thank you.
Based on feedback things might still change, but I think we're heading into the right direction. I think in June or so it will be announced as stable.
@borkdude old version https://github.com/redstarssystems/rssyslib/blob/develop/resources/clj/new/rssyslib/bb.edn new version https://gist.github.com/mikeananev/c87c1596aed50b7bb095a816f6921737
I love the layout of your bb.edn, do you do this manually or using a tool? If that is a tool, I think I need it
it is Idea + Cursive + format code in Cursive
@ericdallo Can LSP do it that neatly, aligning the values on the same column?
Yeah, to make something generic I'd prefer doing that on cljfmt as there are already issues requesting that
Ha! This was the exact cljfmt issue that sent me on my meandering trek. Now that rewrite-clj v1 is released, maybe I should get back to it, eh?
If I remember correctly, the last thing I was thinking about was how to enable/disable alignment formatting. I expect that you’d have a general preference, but then you might want to enable or disable it for certain forms? Would a clj-kondo style inline work? Something like #_{cljfmt/align ...}
? Anyhoo probably wrong channel, if you want to discuss more we could start a thread in #rewrite-clj.
@borkdude you can achieve the same format using cljstyle
tool. But you need to rename file extension edn
to clj
You could also add edn
to the extensions if you wanted, or set a pattern regex to match just that filename if you don’t want it to apply to all edn files. https://github.com/greglook/cljstyle/blob/main/doc/configuration.md#file-settings
@U8XJ15DTK Since babashka now comes with rewrite-clj, is it possible to support (a subset of) clj-style as a bb script?
or just add to .cljstyle
:extensions #{"clj" "cljs" "edn"}
in :files section
well yeah that’s what it does 😛 - more asking, why do that instead of the standalone binary?
you could make cljstyle a dependency in your bb.edn
and then have a format
task and invoke it programmatically (e.g. on the bb.edn file itself)
hmm I see - it is written in such a way that you could use it as a library, but I’m not sure what would need to change to use it from bb instead of regular clojure
well, bb (currently) does not expose tools.reader for example and also doesn't have the google diff tool. I'm not sure why they are used in cljstyle?
there’s also the cljstyle pipe
command if you just wanted to shell out to it and use it on a specific block of text
diff is for cljstyle check
printing out the diff of corrections it expects / would make with fix
so if your formatting namespaces can be isolated from the rest, without bumping into these unsupported deps, it should already work
@borkdude what is correct dependency coordinates for cljstyle to include into bb.edn?
@U8XJ15DTK Running into this one:
> https://github.com/greglook/cljstyle/blob/main/src/cljstyle/format/zloc.clj#L9
bb doesn't expose that class (and should not have to, I think, it's an implementation detail). Are you ok with introducing a :bb
reader conditional?
I would love to have a better way to satisfy the string?
predicate it’s used in, referring directly to that class felt gross
and there's also an issue in rewrite-clj for this \cc @UE21H2HHD
Great. 🙂 I’ll be on the road for a couple weeks, but happy to look at the changes when I get back!
Now that rewrite-clj also supports CLJS I guess we could also have a cljstyle that works in the browser and nodeJS
@mike1452 @U8XJ15DTK Now I'm confused. I'm finding several open issues about vertical alignment: https://github.com/greglook/cljstyle/issues/61 https://github.com/greglook/cljstyle/issues/47
I believe I have cljstyle working now with babashka: https://gist.github.com/borkdude/d317308c66029452520e8bf4378be55e but it seems it just spits out the same source as it ingested all the time
Yeah @U8XJ15DTK I was looking for inspiration from cljstyle for cljfmt on how to specify when/what forms should be vertically aligned, but did not find anything yet.
cljstyle with babashka: https://gist.github.com/borkdude/d317308c66029452520e8bf4378be55e But it doesn't seem to do anything useful yet. Maybe I'm using the lib wrong?
Reasonable compromise: task name one one line, task on the next https://github.com/clj-kondo/clj-kondo.lsp/blob/master/bb.edn
@borkdude found strange behavior (v0.3.7)
If any task has name format
then see this
mike@mbp02 lib02 bb format
----- Error --------------------------------------------------------------------
Type: java.lang.IllegalStateException
Message: Attempting to call unbound fn: #'user1/format
What it could be?
if I rename task to formatt
everything works fine.Can't repro it with this:
$ bb --version
babashka v0.3.7
$ cat bb.edn
{:tasks {format (+ 1 2 3)}}
$ bb run --prn format
6
hmm. Can't repro in a small file. I'll publish bigger file to gist
clojure -X:new :template org.rssys.libtemplate :name com.example/lib02 :snapshot true
this will download my template and create lib02
folder
bb.edn
there contains format
task
it doesn't matter what :task body contains.
if I rename task to `formatt` everything works fine.
@mike1452 The issue here is that your :enter
expression uses format
as well and the program bb creates from your task goes something like this:
(def format (do <enter> <task> <leave>))
or define a function in :init
which uses format
, :init
always goes before everything else
@borkdude thank you!
interesting feature - intersecting names of tasks and core functions
I could see two ways to solve this: 1) generate let
instead of def
, 2) fully qualify all symbols in the global :enter
and :leave
first. But perhaps it's better to wait for more "interesting" cases like this.
Made an issue for it to track it: https://github.com/babashka/babashka/issues/814
I think the second solution is pretty straightforward to implement, like:
user=> `(format "%s" 5)
(clojure.core/format "%s" 5)
user=> (eval `(format "%s" 5))
"5"
I wonder about the override in doit
though:
{:tasks {:enter (load-string "`(prn (format \"%s\" 5))")
format {:task (+ 1 2 3)}
doit {:depends [format]
:enter (prn (format "%s" 1))}}}
I think in the case of doit
it would be reasonable to require people to use a fully qualified symbol for format
, since it's pretty clear that this is conflicting. Although you might still have access to that symbol if you indirectly depend on it.fully qualified symbols are simple and straightforward. no complex behaviour under the hood.